Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] Corgi Engine - Complete 2D/2.5D Platformer [new v6.5 : fall damage, crush detection...]

Discussion in 'Assets and Asset Store' started by reuno, Dec 18, 2014.

  1. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @morganwk > Physics would react like they would in any Unity project. Everything's fixable if you implement it, but if you plan on having a lot of physics interactions (stack, push), I'd recommend going with a physics based solution. Right now stackable pushable blocks are not part of the immediate plans. I can add that to the todo list if you'd like, but that's never been requested before, so it'd be low priority.
     
    morganwk likes this.
  2. morganwk

    morganwk

    Joined:
    Oct 13, 2015
    Posts:
    3
    I appreciate your quick replies and eagerness to help out. I recognize that interactions between pushable blocks is both a very difficult problem to solve with raycasting, and a problem that very few other people are likely to have. It would probably make sense to plan on implementing it eventually, but I wouldn't expect somebody to prioritize it over anything more commonly requested or important. I appreciate your input either way.

    I'll probably have to experiment with a number of potential solutions, but I'll figure it out eventually.
     
  3. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @morganwk > I don't think it'd be very difficult to solve with what's already there, you'd just have to add that feature, and decide on what use cases you want to support, but it's quite doable, I'd say the hardest part is already done. But I don't like saying something is easy or hard, it really depends on one's skills! As I said, I can add it to the todo list if you'd like :)
     
  4. piccolodmq

    piccolodmq

    Joined:
    Jan 7, 2020
    Posts:
    29
    Hi Reuno, just one quick question regarding pickable objects. I setup a character to be able to have this ability, he can do everything ok, (picks the box over his head and everything, but if the player dies while he is holding this pickable object, the player respawns with the object in a random position, still attached to the player (in my case to his right). I am doing something wrong?
     
  5. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @piccolodmq > That sounds like a bug. Don't hesitate to use the support form and provide a bit more info on how and where I can repro it, and I'll be happy to fix it.
     
  6. Alexflame108

    Alexflame108

    Joined:
    Sep 24, 2019
    Posts:
    23
    Actually, @reuno, we have the same problem with slopes and quick falling and it looks like this:

    https://yadi.sk/i/nz3et67hjm-xcA

    Especially take a look at 15-20 sec.

    On 15 sec it's too quick falling, whereas i do EXACTLY THE SAME on 19 sec and it's all fine.
     
  7. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @Alexflame108 > Then likewise, please use the support form, and provide repro steps to your issue, in any of the demos, no changes made. Some context (Unity version, asset version) will also help.
     
  8. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    85
    Hello Reuno,

    Is there a way to make the player grab a ladder automatically? We don't want the user to be required to press up to get on the ladder. I was looking for a checkbox on the ladder but there's none. There's none on the CharacterLadder either. Would it be difficult to implement this or can I do this myself? I've read through the code but can't really find a place or function I can use to attach the user to a ladder. I was thinking of a way like: OnTriggerEnter -> Attach player to ladder.

    Kind regards
     
  9. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @Cambesa > Right now there isn't, but I can absolutely add that to the next release, it's a good suggestion (surprised it never came up so far). Note that it should already be doable, the ladder ability exposes a LadderColliding bool, and a StartClimbing method you can call to start climbing the ladder.
     
    Cambesa likes this.
  10. TiredFox

    TiredFox

    Joined:
    Feb 24, 2020
    Posts:
    3
    With the Character Dash Ability is there a way to set it so the character can only dash a limited number of times before it lands (very much like Celeste)? I've been scratching my head over how to do it. I've tried creating a counter but it seems very difficult to get it to work with the coroutine :(
     
  11. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @TiredFox > Right now there's no built-in limit, but you could of course add one. You can look at how other abilities do it for reference. It basically comes down to checking if you still have dashes left before letting the user dash once more. That could be done in StartDash, for example, no need to touch any coroutine for that.
     
    TiredFox likes this.
  12. TiredFox

    TiredFox

    Joined:
    Feb 24, 2020
    Posts:
    3
    Thanks Reuno awesome stuff and I put it in the StartDash function as you suggested. I got it but now just struggling to reset the variable back to 0 when player is grounded. I suspect I need to add an if character grounded then reset dash counter. Thanks for your help!
     
    reuno likes this.
  13. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @TiredFox > You can do something like :
    Code (CSharp):
    1. if (_controller.State.JustGotGrounded)
    2. {
    3.     // reset your counter here
    4. }
     
    TiredFox likes this.
  14. TiredFox

    TiredFox

    Joined:
    Feb 24, 2020
    Posts:
    3
    Spot on, you saved a lot of head scratching for me there. I put it under ProcessAbility. Reuno, you're a top guy thanks!
     
    reuno likes this.
  15. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @TiredFox > Yeah I forgot to mention it but ProcessAbility is where this check should go, good job!
     
  16. NamraGame

    NamraGame

    Joined:
    Feb 17, 2019
    Posts:
    15
    @reuno oh thanks! I thought it was a splash screen :confused: I'm gonna be more diligent and watch all the tut vids.

    Another question, purely out of curiosity; is it possible to combine several more mountains engines? Like, let's say, you want a game where you would need to go by car to a point A to a point B (car engine) to then continue the adventure (corgi engine) ?
     
  17. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @NamraGame > No, the splash screen would be the scene called SplashScreen.
    As for combining multiple engines, you'll find the answer to that question in the FAQ. Short answer : it's not out of the box, but possible.
     
  18. NamraGame

    NamraGame

    Joined:
    Feb 17, 2019
    Posts:
    15
    thanks
     
  19. Morriekken

    Morriekken

    Joined:
    Jan 5, 2016
    Posts:
    1
    I need similar functionality and I'm going to publish whatever I come up with on github.
     
    morganwk likes this.
  20. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    85
    A small question: I have made a custom slide ability and I'm not sure what's the best way to add momentum to the controller. I'm using:
    Code (CSharp):
    1. _controller.AddForce(moveVector);
    Do I need to implement Time.deltatime in the value I pass to the controller? So it would result into something like:
    Code (CSharp):
    1. _controller.AddForce(moveVector*Time.deltaTime);
    In both cases we can assume I don't use time.deltaTime to calculate the appropriate moveVector.
     
  21. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @Cambesa > If you're doing it one time, you can go with no delta time, you're applying a force (like a punch) once. If you're doing it every frame (or over a certain period of time), then you'll want to have deltaTime as a factor, otherwise how much force you'd add would entirely depend on your framerate.
     
    Cambesa likes this.
  22. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    85
    I'm trying to figure out why I have slower sliding speed at higher framerates. I'm not applying friction with my code anymore, only calculating the slide speed every frame and adding this as force to the _controller. Do you use any friction at all in Corgi? Could it be that Corgi decreases the speed every frame which causes a stronger slowdown on higher framerates? My moveVector is calculated based on the (rotated normal of the surface) * slideSpeed * time.deltaTime. This resulting vector is added to the controller using _controller.AddForce(moveVector); which now includes time.DeltaTime. I'm not asking you to fix my code but I just want to know more about what's going on in Corgi so I know where to look for the problem.

    Update: I found HandleFriction in CharacterHorizontalMovement.cs -> line 257
    This one is also executed 8 times a second in a small window in the editor and 177 times a second in build. It does implement time.deltaTime so I think it works fine, I'm just not sure if either 8 times in 177 times in one second deviates much in the long run even though time.deltaTime is used.

    I'll try a very simple test case where I add a horizontal force of 1 every second and see if that's different with different framerates.
     
    Last edited: Aug 6, 2020
  23. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @Cambesa > There's only friction if you use SurfaceModifiers. Now if you're adding force every frame, it might be better to Set a force (using SetForce) than to add it, that'll give you more control, AddForce is more for punctual uses. You can look at the dash for an example of how to use it.
     
    Cambesa likes this.
  24. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    85
    SetForce is quite difficult to use for this case, it seems to block jumping and moving left and right.
    I'm not aware what SurfaceModifiers are and do yet, i'll read the documentation. I don't think we are using them.
     
  25. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @Cambesa > If you want to retain control then neither Add or SetForce will likely do, if you're after pure inertia I'd implement that at a deeper level, it would have to be added to the controller directly, there's no inertia notion at the moment.
     
  26. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    85
    I don't think it's inertia I'm after. I'm mainly trying to set the speed in the direction down the slide but keep the ability to jump off while keeping momentum(momentum works), and speeding yourself up or slowing yourself down by pressing left/right. So basically all the controls and movement of Corgi should keep working and just an added momentum in the direction of the slide which is why I think AddForce is the perfect function to use.

    I just now tried to use the SurfaceModifier which seems like a component that also does something similar and setting the AddedForce property to the direction based on the slope of the slide. The character just does not move at all when touching the slide. I see the character controller is assigned OnTriggerEnter, It's not a trigger but a non-trigger box collider in the platform layer so that might be the problem.
     
  27. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @Cambesa > You'll find examples of SurfaceModifiers in use in the FeaturesPlatform demo scene, among others. IIRC there's mud and ice somewhere near the middle of the level. They really just impact your current speed though, that won't make you slide down a slope.
     
    Cambesa likes this.
  28. ViperBoy

    ViperBoy

    Joined:
    Mar 27, 2020
    Posts:
    6
    I have character with a sword and bow animations. I was wondering if there's a way to have the bow and sword simultaneously equipped. So if I click a button one animation plays and If I click another the other will play.
     
  29. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @ViperBoy > If you're not using the inventory, that's very easy to setup, you'll need two abilities : CharacterHandleWeapon (where you set let's say the Sword as the InitialWeapon) and a CharacterHandleSecondaryWeapon, where you set the Bow as the InitialWeapon. Both have different bindings, that you can change of course. Then on your weapons make sure you specify different and unique animation parameters (maybe BowStart, SwordStart, etc), setup your animator's transitions with these, and you're done.
     
    ViperBoy likes this.
  30. ViperBoy

    ViperBoy

    Joined:
    Mar 27, 2020
    Posts:
    6
    Hello again. I had a question about the health system. Is there a way to use hearts as health. For example, you start the game with three hearts, every time you get hit you lose a heart. When all hearts are gone you die and have start over. You can also pick up hearts to get one back. Is there a way to implement this in the engine? If not, could you add it in the next update? I feel it is a common way health is in Platformer games. Thanks.
     
  31. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @ViperBoy > That's already doable, it's just a matter of displaying your health in a different way. It can be done natively in Unity UI (which I'd recommend), or you can use the HeartsGUI class.
     
  32. Samdo342

    Samdo342

    Joined:
    Aug 9, 2020
    Posts:
    1
    Hi, I am trying to implement a currency system in my game. For example, during the levels you pick up coins. The total coins collected will be visible in the main menu. Here you can buy upgrades for your weapons with coins you have collected. How would I go about implementing this? Specifically how do I show the total coins in the main menu? Is there a class for this?
     
  33. ViperBoy

    ViperBoy

    Joined:
    Mar 27, 2020
    Posts:
    6
    For the health class when I unselect "destroy on death", the plays still gets destroyed on death. Is this a bug or am I using it incorrectly?
     
  34. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @ViperBoy > I suppose you must be doing something wrong. You can see it in action in the RetroAI scene, the first few enemies remain after death. If the issue persists please use the support form, thanks.
    @Samdo342 > No, there's no currency system right now. You'd have to implement it. How you decide to do it is up to you, it'd be a completely separate system so there's nothing specific to the engine there.
     
  35. ViperBoy

    ViperBoy

    Joined:
    Mar 27, 2020
    Posts:
    6
    Sorry for bothering you. Do you mind if you could help me get started on the heart health system? Just first steps and where I should start? Thanks again.
     
  36. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @ViperBoy > Not sure if you saw my previous message, but there's a (commented) class you can use, or, and that'd be the recommended way you can use Unity UI for that, it's native, you don't need the engine :). Again if you have more questions please use the support form, thanks.
     
  37. ScaryRobotGames

    ScaryRobotGames

    Joined:
    May 2, 2007
    Posts:
    55
    Hello! A question about the input manager: it seems to be binary, either touch input or joystick/keyboard. And it can only be chosen at initialization, not switched during the game. If this is the case then how would you suggest handling a situation like the Nintendo Switch where either input system can be used at any time?
     
  38. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @ScaryRobotGames > Right now it's indeed binary, but you could extend the InputManager to have it handle both if you'd prefer. I have to admit I'm not aware of any Switch game where both input methods would be used at once (like moving a character with the physical stick AND a virtual one. UI buttons or actions certainly, but two sticks I've never seen that before :) If you have an example I'm curious!
     
  39. ScaryRobotGames

    ScaryRobotGames

    Joined:
    May 2, 2007
    Posts:
    55
    Thanks for that. I don't necessarily mean simultaneously but being able to switch to either on the fly. Playing with the joy cons but then switching to touching the screen for input instead, mid-gameplay.
     
    reuno likes this.
  40. Cunny-Lang

    Cunny-Lang

    Joined:
    Jul 30, 2019
    Posts:
    15
    Methinks that first of all you need to think about hearts as a HP numbers. Like 3 hearts = 3 hp, not 100 like now. Then you need to replace default Helathbar to Hearts and check ho it works.
    Personally I want to make health system like in Boogerman (SEGA MD2) where your hp displays as maincharacter cloak and it glitter with full hp, becomes red at 2hp and yellow at 1hp. But ofc I dont know how to make it, just thoughts)
     
    reuno likes this.
  41. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    259
    Hopefully quick question:
    I'm using Corgi as a player controller in a sidescroller that has a fair bit of physics objects. For example, the the player can craft boxes and move them around and stack them on top of each other (creating joints between them), and they have to be physics-based as they need to interact with other physics things in the game, and be affected by gravity etc.

    I was delightfully surprised to find that the "experimental" 2D physics stuff in the player controller seems to work quite well (it adds force to objects when you push them around, rather than having to rely on the scripted Pushable components).

    Where I'm having trouble is how the controller behaves when the player moves around while standing on top of these physics object boxes. When those boxes are flat and totally steady, everything is A-OK. When they're moving around slightly because of physics, things become very unpredictable - ie when jumping the player character might suddenly fly to 20x his normal jump height, I guess just because the jump is timed with a tiny per-frame physics movement of the thing he is standing on, just enough to add a sudden huge momentum, or something like this?

    Or, when just moving horizontally, if two physics boxes happen to squish the player slightly from above and below, the player might suddenly be launched way too fast in the direction he was moving.

    My question is where are the most obvious places for me to start digging around in Corgi's controller to look at and possibly refactor to try to fix these behaviours, and how the controller interacts with things that might be moving unexpectedly? I'm willing to put a fair bit of time and effort into re-jigging the controller to make it all work, so I'm hoping it's not an entirely lost cause which would force us to go to a physics-based player controller, when I'd prefer to see if we can keep the tightness of Corgi's controller somehow. Just hoping to be pointed in the right direction so I don't spend an enormous time trying to find where the problems might be happening.

    Thanks!
     
    Last edited: Aug 11, 2020
    reuno likes this.
  42. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @dasbin > I wish there was a quick answer to that question! Unfortunately physics and the corgi controller are two very different systems, so there simply isn't a short answer. In general I'd recommend going either full physics, or full controlled, it's gonna be easier. The engine is designed for tight gameplay, and generally more "classic" situations. There is the experimental options you found, but they are very much experimental, or risky :)
    And if you want to keep pushing in that direction, it'll have to be on a case by case basis. My recommendation would be to "cheat" by locking physics into place as soon as you can, the engine won't behave nicely if your platforms wobble a bit as physics tend to, and that can indeed cause a collider to suddenly get "inside" the controller's collider, which will cause it to react like you describe.
    So it's not necessarily a lost cause, or to rephrase that, it really depends on how many cases you want to handle, how much effort you want to put into it, and how much you're ok with "faking" to get more stable situations.
     
    dasbin likes this.
  43. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    259
    Thanks for the reply.

    After some finer testing I'm a bit surprised to see that most of my problems actually aren't coming from physics objects moving and imparting strange forces, but instead from Corgi's handling of slopes behaving in unexpected ways.

    For example, when I make a static non-physics (kinematic) collection of boxes that are angled in various odd ways like what happens with my physics boxes when they get bent over around their joints, and then get my character to walk over them, I get all the same problems I was having before.
    I'm especially having a hard time with the Max Slope Angle setting. It doesn't seem to have any effect at all - even when set to a tiny value (like 1) my character tries to walk up anything that isn't a completely vertical wall, and of course behaves badly as a result. The Slope Angle Speed Factor curve *does* affect my character's speed when attempting slopes, but doesn't prevent him from trying to walk them in the first place, or from standing on slopes that are too steep. If Additionally, if I jump next to a few weird slopes, even though they are not physics objects anymore, sometimes the jump sends me off into oblivion.
     
  44. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @dasbin > That's bound to happen if you create "spikes" that are smaller than the raycasts of the controller, and they can fit between raycasts (which tends to happen if you create random odd angled box platforms). As I mentioned earlier, the engine is designed for tight gameplay, and situations and colliders you'd find in games of that genre. If you plan on having chaotic geometry, a physics based approach would be more suited, as that's one of the reasons physics engines were created for. The engine encourages a certain type of level design, one that you'd find in most platformer games, but not all for sure.
     
  45. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    And just to add to that, that doesn't mean you need to stick to Megaman-like extremely geometric levels visually. Most modern platformers (thinking of Ori right now) have very organic looking environments, but if you look at the colliders, they're carefully crafted and quite simple as far as shapes go, no spikes or anything :)
     
  46. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    259
    Yeah, I've been seeing what happens when I crank up the number of raycasts.
    I still have trouble with the Max Slope setting even on regular long platform slopes though (like in your demo levels). The Max Slope doesn't seem to have any effect when traversing them that I can see.
     
  47. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @dasbin > The Max Slope setting should prevent you from walking on slopes that are above the specified angle (relative to a horizontal line in your character's referential). You should still be able to stand on them (there's no slide down slopes feature at the moment, although it's getting higher on the todo list). If you can walk on them regardless, then it looks a lot like a bug, don't hesitate to use the support form to report it with a bit of context info so I can repro it and fix it :)
     
  48. ViperBoy

    ViperBoy

    Joined:
    Mar 27, 2020
    Posts:
    6
    Does the inventory system support mobile controls?
     
  49. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,776
    @ViperBoy > You can tap the buttons on mobile with the demo assets, yes :)
     
  50. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    259
    Figured out my problem with slopes. Corgi Controller's Ray Offset setting is closely related to slope detection. The default setting (0.05) doesn't work to properly stop movement on slopes any shallower than about 30 degrees. Increasing the offset will stop on shallower slopes better, but will stop you farther away from walls. I had mine decreased somewhat to get tighter into spaces, and that made it not work for anything less than 60 degrees or so. Tricky balance to find.
     
unityunity