Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Corgi Engine - Complete 2D/2.5D Platformer [new v8.0 : advanced damage system]

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

  1. reuno

    reuno

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

    NamraGame

    Joined:
    Feb 17, 2019
    Posts:
    31
    @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) ?
     
  3. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
     
  4. NamraGame

    NamraGame

    Joined:
    Feb 17, 2019
    Posts:
    31
    thanks
     
  5. 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.
  6. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    119
    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.
     
  7. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
  8. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    119
    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
  9. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
  10. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    119
    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.
     
  11. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
     
  12. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    119
    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.
     
  13. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
  14. ViperBoy

    ViperBoy

    Joined:
    Mar 27, 2020
    Posts:
    7
    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.
     
  15. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
  16. ViperBoy

    ViperBoy

    Joined:
    Mar 27, 2020
    Posts:
    7
    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.
     
  17. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
     
    LuckyMisterSleven likes this.
  18. 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?
     
  19. ViperBoy

    ViperBoy

    Joined:
    Mar 27, 2020
    Posts:
    7
    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?
     
  20. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
     
  21. ViperBoy

    ViperBoy

    Joined:
    Mar 27, 2020
    Posts:
    7
    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.
     
  22. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
     
  23. ScaryRobotGames

    ScaryRobotGames

    Joined:
    May 2, 2007
    Posts:
    57
    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?
     
  24. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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!
     
  25. ScaryRobotGames

    ScaryRobotGames

    Joined:
    May 2, 2007
    Posts:
    57
    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.
  26. KOPEW

    KOPEW

    Joined:
    Jul 30, 2019
    Posts:
    27
    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.
  27. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    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.
  28. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
  29. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    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.
     
  30. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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.
     
  31. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    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 :)
     
  32. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    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.
     
  33. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @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 :)
     
  34. ViperBoy

    ViperBoy

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

    reuno

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

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    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.
     
  37. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @dasbin > I'm glad you figured it out. The "stop farther away from walls" thing has been improved for the next version though, it should make that setup easier.
     
  38. Jak54s

    Jak54s

    Joined:
    Aug 12, 2020
    Posts:
    6
    Great engine. Do you have plans for a crafting system to go with the inventory engine? That would help with my game. Just curious.
     
  39. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @Jak54s > Not in the immediate future, but it's on the todo list :)
     
  40. piccolodmq

    piccolodmq

    Joined:
    Jan 7, 2020
    Posts:
    34
    hi Reuno.

    I am trying to make a sound repeat 3 times, when a enemy (boss) dies. I am using the MMfeedbacks, with the sound options setup set to Number of repeat 3, and repeat sequence set to 0.5. The result I am getting when the enemy dies its just the sound playing 1 time. I know this must be something easy, on my part, but I cant see it. Thanks!

    https://drive.google.com/file/d/1Pn1GTkyv2Ig80mhWdxj5KSZe06Vt7tb5/view?usp=sharing
    https://drive.google.com/file/d/1Pn1GTkyv2Ig80mhWdxj5KSZe06Vt7tb5/view?usp=sharing
     
  41. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @piccolodmq > Probably your feedback getting destroyed when your enemy dies.
     
  42. piccolodmq

    piccolodmq

    Joined:
    Jan 7, 2020
    Posts:
    34
    I setup delayed destruction to 5 second, on the Enemy.
     
  43. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @piccolodmq > Then I'd need more info to guess what your issue is. If it persists, don't hesitate to send more via the support form, I'll be happy to have a look.
     
  44. piccolodmq

    piccolodmq

    Joined:
    Jan 7, 2020
    Posts:
    34
    Redid everything from scratch, and it worked. I am loving your work, Reuno. Quality of life right here. Keep up the good work.
     
    Last edited: Aug 13, 2020
    reuno likes this.
  45. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    The best kind of fix!
     
  46. Jak54s

    Jak54s

    Joined:
    Aug 12, 2020
    Posts:
    6
    I am trying to implement a simple crafting system. I know it's a specific question but would you mind showing some basic code for the following mechanism?

    To craft a potion, you need three leaves. If you click craft, the script checks if you have three leaves in your main inventory, then it checks if there is space in your potion inventory. Then If potion inventory wasn't full the leaves quantity decreases by 3 and the potion gets added to potion inventory.
     
  47. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @Jak54s > There's no crafting system in the engine at the moment, I don't have example code for this.
    You'd have to target the InventoryEngine's API, you'll find methods there to check if you have a certain quantity, check if there's space, add items and remove items. They're all detailed in the documentation, don't hesitate to check it out!
     
  48. Sofiel

    Sofiel

    Joined:
    Aug 6, 2017
    Posts:
    60
    @reuno thanks for pointing me in the right direction with the multiplayer scene and AI issue I was having. Got it all to work.
    Now I was going for a character selection for the multiplayer. I got it to take the chosen character to the multiplayer level, but the other characters were not instantiated. I know I have to extend the characterselector and in the storecharactetselection I should call the other selected”” characters, but with my limited knowledge I’m stuck. Should I go for a (I’m probably lost here) IEnumerator or a for each? Pointing me in the right direction will be great.

    thanks.
     
  49. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @Sofiel > I'm also a bit lost, not sure I see what you mean with the IEnumerator or for each thing :)
    Basically what you'll want to do is feed the multiplayer level manager the characters you want to instantiate. You can certainly extend the character selector, or simply create a new class, it's just a matter of setting that public array (on Awake, before it instantiates anything).
     
  50. Sofiel

    Sofiel

    Joined:
    Aug 6, 2017
    Posts:
    60
    Jajajaja I WAS lost. Thank you! I’ll get to it
     
    reuno likes this.