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. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    611
    I see . Thank you very much
     
    reuno likes this.
  2. Boom_Shaka

    Boom_Shaka

    Joined:
    Aug 31, 2017
    Posts:
    141
    Maybe rotate the original model 90 degrees? Not the model container, but the model itself.
     
    reuno likes this.
  3. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @Boom_Shaka > The model container shouldn't be rotated, it's whatever you nest under it that should.
     
    Boom_Shaka likes this.
  4. Guilherme-Otranto

    Guilherme-Otranto

    Joined:
    Mar 12, 2014
    Posts:
    28
    Hi @reuno, great asset!
    I have been playing with it for a bit now and it is quite amazing!

    I do have a (hopefully) quick question:
    Suppose I want to have a 'nerfed' version of the current wall jump ability, where a player would not be able to climb up a single wall with the ability...
    (They would require two opposing walls to really climb)
    So, similar to Mario or Salt and Sanctuary, as opposed to what we have by default, which is similar to Celeste or Hollow Knight.

    I figured the best way to accomplish this would be to 'lock' the directional input for a bit, not allowing the player to push towards the wall (but still allowing them to push away further, if they choose). Is that the way you would go about it?

    Also, I could not find it easily, but is it something that is already implemented and I failed to see?

    Thanks a bunch!
     
    reuno likes this.
  5. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @Guilherme-Otranto > No, that's not built-in. And yes, locking the direction for a bit would be exactly how I'd do it :)
     
  6. Guilherme-Otranto

    Guilherme-Otranto

    Joined:
    Mar 12, 2014
    Posts:
    28
    Okay, thanks @reuno !

    In case anyone else is interested, I will document my first step here.

    By quickly studying the CharacterWallJump class I came up with a first solution, which is quick and dirty:
    Code (CSharp):
    1. //If we don't want the character to be able to climb a single wall, keep the input from being used for a while
    2. if (horizontalAxisBlockerTime > 0f)
    3.   StartCoroutine(KeepCharacterFromMoving(horizontalAxisBlockerTime));
    I add the above code at the end of the function WallJump (just before the return statement).
    The Coroutine simply does as follows:
    Code (CSharp):
    1. //Keeps the character in controlled movement for a little bit to avoid the user being able to walljump up  asingle wall (by pressing against it)
    2. private IEnumerator KeepCharacterFromMoving(float time)
    3. {
    4.   _condition.ChangeState(CharacterStates.CharacterConditions.ControlledMovement);
    5.   yield return new WaitForSeconds(time);
    6.   _condition.ChangeState(CharacterStates.CharacterConditions.Normal);
    7. }
    And, of course, horizontalAxisBlockerTime is defined as a public float on this class. Now the user can set a timer to stop all input after a walljump.
    I am using 0.25s and it does what I want: When my char walljumps, if I keep on pressing back to the wall, the characters arrives back a little bellow where he left the wall (Mario style).

    /************************************/

    The obvious problem with this solution: It ignores all other input (e.g., a shoot, a second jump, a movement to the other side, etc).
    My next step: Ignore only horizontal movement towards the wall.
    I did this with the following code:
    On WallJump:
    Code (CSharp):
    1. //If we don't want the character to be able to climb a single wall, keep the input from being used for a while
    2. if (horizontalAxisBlockerTime > 0f)
    3. {
    4.     CharacterHorizontalMovement hm = gameObject.GetComponent<CharacterHorizontalMovement>();
    5.     if (hm != null)
    6.     {
    7.         hm.IgnoreHorizontalInputSide(wallJumpDirection < 0f, horizontalAxisBlockerTime);
    8.     }                  
    9. }
    Then, on the HorizontalMovement class, right after movementSpeed is defined, on the HandleHorizontalMovement method:
    Code (CSharp):
    1. //Multiply for the inputMultiplier if we are moving towards the ignored side
    2. if (ignoringRight && movementSpeed > 0f)
    3.   movementSpeed *= inputMultiplier;
    4. else if (!ignoringRight && movementSpeed < 0f)
    5.   movementSpeed *= inputMultiplier;
    And finally, just anywhere in the HorizontalMovement class:
    Code (CSharp):
    1. //Ignores one side of horizontal movement for a while (called by WallJump to stop player from climbing up single walls)
    2. float inputMultiplier = 1f;
    3. bool ignoringRight = false;
    4. public void IgnoreHorizontalInputSide(bool right, float time)
    5. {
    6.     ignoringRight = right;
    7.     StartCoroutine(IgnoreInputForAWhile(time));
    8. }
    9. private IEnumerator IgnoreInputForAWhile(float time)
    10. {
    11.     inputMultiplier = 0f;
    12.     yield return new WaitForSeconds(time);
    13.     inputMultiplier = 1f;
    14. }
    Okay, this accomplishes what I wanted. I will still improve the code, and tweak it for my game, but this should get any interested readers ready to start with this implementation.
    I decided to leave the first 'solution' here because it might be useful to stop all input in some situations (e.g., getting hit).

    Cheers.
     
    Last edited: Nov 9, 2018
    Muppo and reuno like this.
  7. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    611
    Hi reuno,
    I am wondering is there some message tools for this case:
    I have a component for charater like this:
    upload_2018-11-9_11-34-51.png


    But sometimes I just want to listen some special message on corresponding objects like Role Character while this component would be added to all the character in the scene,so it that possible to send the message to some appointed objects instead of broadcasting? Thanks very much..
     
  8. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @Bagazi > I'm not sure I understand your question exactly. This is the recommended way of doing things in the engine, but it's Unity, and you can change that for whatever you prefer. You can use SendMessage for example, if that's your question.
     
  9. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    611
    Yeah, thanks very much ,but the Unity inner message is based on Reflection,which is valid but maybe not with high efficiency,I asked this question to check out if I had missed some existed function in this wonderful engine~
     
  10. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    611
    What I image that is just like the PlatfromMask,which can filter the unconcerned objects or characters during a message delivery
     
  11. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    611

    Maybe I should use some condition judgement on the receiver....
     
  12. Mindjar

    Mindjar

    Joined:
    Aug 13, 2013
    Posts:
    29
    Hi guys, I need some help, maybe someone already found a solution. I want to make an animated GUI windows (pause, level complete, etc.) and I've used leantween for this. But when you pause the game, Time.deltaTime = 0 and every animation stops. What is the proper way to do this?
     
  13. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
  14. Mindjar

    Mindjar

    Joined:
    Aug 13, 2013
    Posts:
    29
    @reuno Thanks for the Time.unscaledTime - that’s what I was looking for! I knew about unscaled property in the animator, but I’m not using it because of performance.
     
    reuno likes this.
  15. hanger102

    hanger102

    Joined:
    Jan 3, 2013
    Posts:
    13
    Hi,

    I just started using the corgi engine and I must say it's been great. But one thing I can't do or find(I should say) is having the player always face the direction of the mouse. I am having all the weapons aim towards the mouse but when I move the player the opposite direction it flips the player. I would like it to flip only with the mouse. Can anyone help? I'm using the 3d hunt scene to test this.

    Thanks!
     
  16. Boom_Shaka

    Boom_Shaka

    Joined:
    Aug 31, 2017
    Posts:
    141
    Quick question on temporary invulnerability player and/or enemy. I have two use cases:
    1. "brute" use case: object takes the hit and it does no damage. Using "invulnerable" = "true" boolean on the game object health component. No problems there.
    2. "evasion" use case: object avoids the hit altogether (projectiles and melee attacks should "pass through" the game object). Tried using the "invulnerable" layer but noticed AI won't target it. Slight problem there.
    Thought about disabling 2d collider but I don't want to interfere with platforms, so I'm looking at changing the damage layer on the weapons/projectiles themselves. Is there another built-in solution I haven't seen yet?
     
    Last edited: Nov 10, 2018
  17. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @hanger102 > That's not something that is built-in if that's your question. I'd recommend creating a new character ability to handle that. It can target the Face method to do that quite easily.
    @Boom_Shaka > Temporarily changing the layer is exactly how I'd do it.
     
    Boom_Shaka likes this.
  18. Meowx

    Meowx

    Joined:
    Oct 10, 2015
    Posts:
    33
    A feature request for you - ledge grabbing! IE if a character has jumped not quite high enough, they might grab onto the edge of a ledge and pull themselves up, either automatically or with a button press.

    Keep up the awesome work!!
     
  19. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @Meowx > Thanks for the suggestion, I'll add your vote to the todo list (it's already very high).
     
    Meowx likes this.
  20. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    I'm trying to replicate this platform behaviour now but I'm not success yet.


    I've tried a few things but I'm not sure wich method should I override; Move, GetPathEnumerator, Update, all of them?
    A bit of light in this will be great.
     
  21. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @Muppo > I think this would warrant an all new class, but I guess it can also be done by extending a MovingPlatform maybe. I can't guess what methods to extend like that though :)
     
  22. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Ouch. Will try again from scratch then.

    This kind of platform (single one, not paired like in the picture), where player weight push it down then it goes up again when player leaves. Can you add this to the suggestion list?
     
  23. Boom_Shaka

    Boom_Shaka

    Joined:
    Aug 31, 2017
    Posts:
    141
    One more advanced AI question: certain bosses will execute certain moves in a certain order/position in scene periodically in each battle. I'm initiating that by adding "marker" game objects to my scene and having the AI move towards those markers and perform the appropriate action.

    That said, I also noticed several references to _brain.Target, which seems to default to the player? If I set that Target to one of my markers would I then need to set it back to the player for the rest of the scripts to work properly? It might end up being more work than my original solution, but I figured it's worth asking.
     
  24. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @reuno So I was wondering how easy it is to undo the changes that importing the Corgi Engine into a project does? For example, I know that importing the Corgi Engine makes change to the layers and how those layers interact with physics so those are relatively easy to revert since I know what changed there however I am unsure of what else might have changed that should be reverted if I decide I don't want to use the Corgi Engine for this project anymore.

    Is there some sort of way to figure out all the changes and how to revert them or would I be better off creating a new project and just copying over all the code that is not related to the Corgi Engine?
     
  25. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @Muppo > Sure, I'll add this to the list!
    @Boom_Shaka > The brain's Target is set by some decisions (target in range, etc) and used by others (shoot at target, move towards target, that kind of things). So sure, if you have other scripts modify that target, it'll have an impact :)
    @ryanzec > The best way would be to use version control and diff the changes to selectively revert to one or the other. Or if you're not using version control, you can indeed just import fresh settings.
     
    Boom_Shaka likes this.
  26. Boom_Shaka

    Boom_Shaka

    Joined:
    Aug 31, 2017
    Posts:
    141
    Got it thanks.

    You can also add my vote to Muppo's platform request - it would make for some interesting timing-puzzles.
     
    Last edited: Nov 13, 2018
    reuno likes this.
  27. tathibana9999

    tathibana9999

    Joined:
    Sep 4, 2017
    Posts:
    3
    I'm trying to make 2D platformer games using "CorgiEngine" and "Spine" now.
    I set a character created with "Spine" as a player.
    In addition, we set "SpineEvent" to player character using animation tool "Spine" so that footstep sounds.
    When "Spine" is played with "Unity", footsteps are output accurately, but player characters who set "CorgiController" will not output footsteps.
    Does "CorgiEngine" support "SpineEvent"?
    If an example is included in the demo scene, where is it?

    I am using "CorgiEngine" version 4.5.1.
     
  28. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @tathibana9999 > No, there is no support for SpineEvents. That is something you'd have to implement, it's very specific.
    The engine is compatible with Spine, as it is with any animation system that works with Unity's native Mecanim, but there is no specific implementation of any proprietary additional layers that Spine or other systems may have.
     
  29. tathibana9999

    tathibana9999

    Joined:
    Sep 4, 2017
    Posts:
    3
    Thank you for your reply.
    I understood.
     
    reuno likes this.
  30. Boom_Shaka

    Boom_Shaka

    Joined:
    Aug 31, 2017
    Posts:
    141
    Getting deeper into AI and mapping out a process for the enemy to jump up onto a one-way platform if the player is on one and in range. Workflow is:
    1. AI Decision: detect player (done)
    2. AI Action: move towards player (done)
    3. AI Decision: check if player is in range, where range < jump height (done)
    4. AI Decision: check if player is on one-way/moving one-way/mid-height one-way platform (?)
    5. AI Action: execute jump (done)
    I think the answer for step 4 is in Corgi Controller controller script lines 807-815:
    // if what we're standing on is a mid height oneway platform, we turn it into a regular platform for this frame only

    Instead of just checking if the player is on a mid-height oneway platform, I'd also check for the other oneway platforms as well:

    if (MidHeightOneWayPlatformMask.Contains(StandingOnLastFrame.layer))

    if (OneWayPlatformMask.Contains(StandingOnLastFrame.layer))

    if (MovingOneWayPlatformMask.Contains(StandingOnLastFrame.layer))


    and then execute the jump if either of those conditions for the player object (or any object tagged "player") returns true?

    Do I need to include the code on line 810 too? _savedBelowLayer = StandingOnLastFrame.layer;

    Thanks in advance.
     
  31. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @Boom_Shaka > That sounds right, yes. I don't think you need line 810, but I'd say the best way to know would be to try it :)
     
  32. bravery

    bravery

    Joined:
    Mar 26, 2009
    Posts:
    270
    Hi,
    If I want to make the following behavior for an enemy:
    - The enemy is stand-still and if you touch it you will get Damage.
    - If you fire once at the enemy the enemy Damage will get disabled for a 2 seconds only (during this 2 seconds you can use him to jump) and after that the Damage ability will be activated again and his health will be full again.
    - If you fire twice on the enemy the enemy will be destroy.

    any idea how to achieve this using Corgi engine?
     
  33. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @bravery > You'll need to create a specific component for this, as it's quite specific.
    Create your enemy, add a DamageOnTouch on it and configure it properly (target layer mask, damage applied, etc).
    Add a Health component to it, same thing, have its health point match twice the damage applied by your weapon.
    Then create a new class that will register to the Health component's OnHit event. OnHit, have it disable the DamageOnTouch for 2 seconds and restore its health after that.

    Alternatively you could use the Brain system for this but it sounds overkill for something that simple.
     
  34. bravery

    bravery

    Joined:
    Mar 26, 2009
    Posts:
    270
    Thank you reuno for the quick reply.

    by the way can you point me to any tutorial or article that can have more elaboration on how to do what explained in this sentence you wrote:
    "create a new class that will register to the Health component's OnHit event"
    as according to my limited knowledge there is an event system that come with corgi engine start with MM and can help me on doing this, right?
     
  35. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @bravery > I don't have a dedicated tutorial for that, but there are examples throughout the engine. This uses Unity's regular delegate system, not the custom events (which is used for more complex stuff). You can learn more about delegates at https://unity3d.com/fr/learn/tutorials/topics/scripting/delegates

    Basically you'll want something like this :

    Code (CSharp):
    1. protected virtual void MyOnHit()
    2. {
    3.    // do something here when you get hit
    4. }
    5.  
    6. protected virtual void OnEnable()
    7. {
    8.   _health.OnHit += MyOnHit;
    9. }
    10.  
    11. protected virtual void OnDisable()
    12. {
    13.   _health.OnHit -= MyOnHit;
    14. }
    15.  
    16.  
    Where you'll have grabbed _health somewhere at Awake or Start.
    So at OnEnable/OnDisable you register/unregister for OnHit, and say that when _health's OnHit gets fired, you want to run your MyOnHit method, in which you can run whatever code you want (in your case that'd be disabling the DamageOnTouch zone and triggering a countdown.
     
  36. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242

    About this, I found a workaround: just replace box collider with circle collider. Didn't reproduce this issue on my tests.
     
    reuno likes this.
  37. Askins

    Askins

    Joined:
    Jul 3, 2017
    Posts:
    15
    Is that the box collider on the Jumper? I've just tried a circle collider on the RetroJumper and it's still having the issue weirdly. Though this was just by playing in the game editor, I'm not testing with a build or anything.
     
  38. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    @Askins > Yes, all I did was lower the Y offset a bit in order to not let player go between this and platform collider. Didn't test in a build too.
     
  39. Meowx

    Meowx

    Joined:
    Oct 10, 2015
    Posts:
    33
    Feature request - could we get a third trigger mode, "charged"? Like Link's sword or Mega Man's buster; hold down to charge with a separate animation state and then release to fire (if you've held the button long enough).
     
  40. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @Meowx > That's already doable, that's what the DelayBeforeUse on weapons is for. You can decide whether you want that to be interruptible or not, and you can have separate animations play at every step of the attack cycle :)
     
  41. Meowx

    Meowx

    Joined:
    Oct 10, 2015
    Posts:
    33
    Oh, great! I thought that was for the attack having a delayed start after it got the command to start. Thanks!
     
  42. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @Meowx > It's also for that :)
     
  43. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    @reuno , I'm trying to achieve this kind of platforms:


    At first I thought on using Auto Rotate as a base but it seem as a bad idea now. Can you add this to the features list if you don't mind? I'll continue working on it, tho.
     
    Boom_Shaka likes this.
  44. Boom_Shaka

    Boom_Shaka

    Joined:
    Aug 31, 2017
    Posts:
    141
    @Muppo - have you tried a custom AI action? Transition/decision would either be a timer (time in state) or player proximity (distance to target)....or both?
     
  45. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,916
    @Muppo > I'll add them to the list, thanks for the suggestion!
     
  46. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    @Boom_Shaka > In fact, a real coder helped me with this, writing this code, but platform goes nuts before the first rotation and I'm trying to figure out how to fix it.

    Edit: code rewriten by the coder, all working nice now.

    @reuno > Thank you.
     
    Last edited: Nov 19, 2018
    Boom_Shaka likes this.
  47. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    192
    Hey folks! I'm wondering if I can slot this plugin into a little project I'm working on. I have a question first...

    Does this support 3D movement on the Z-axis? Or is it something I can add?

    The game I'm making would benefit from all the jumping & platforming mechanics, but I also need to be able to move back and forth along the Z axis.

    Here's what I mean: https://imgur.com/TfDT1SD
    (it's a Half-Life demake :D )

    Can Corgi use 3D colliders and rigidbodies?
     
  48. Qianfulong

    Qianfulong

    Joined:
    Mar 15, 2017
    Posts:
    7
    Hi all,
    does anyone have experience with cinemachine and the corgi engine? I managed to incorporate the "LevelManagerCinemachineBased" script made by Prog-Maker from the extension Git (https://github.com/reunono/CorgiEngineExtensions). Though it is generally working the parallax somehow is not working properly. Some of the parallax elements jitter / lag relative to the other elements while others behave like expected, though all elements are setup the same way. Did anyone else try out that script yet in conjunction with the corgi parallax feature? Maybe Prog-Maker himself might give me a hint here? Cheers in advance folks!

    Edit: All right, i found the problem even though i do not understand it. I added the Cinemachine Cameras after building the level so all parallax elements already were in place. For some elements this worked but like described above for some it didn't. So i tried to remove the parallax component from the problematic gameobjects and immediately added the parallax component again, using the exact same settings as before. Magically that fixed the problems. Parallax behaving like it should. So mind integrating your cinemachine brain into your levels before adding parallax elements :)

    Edit2: Hopes up too soon. Even thought problems were gone for a short moment, after starting the editor play mode again problems reappeared... I have no idea what's happening here. It does not behave deterministic here. So returning to my initial request: If anyone has experience with cinemachine in general or within corgi i'd be happy to get a hint on this...
     
    Last edited: Nov 19, 2018
    Boom_Shaka likes this.
  49. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Well, I found this today using polygon collider 2D



    I can't reproduce it with default characters so I'm sure this is not a bug and only happens with mine. My player have Level Bounds component disabled, but already tried on enable and this still happens.

    It seems player is rocketed up in the air when trying to jump in corners, no matter how many degrees the angle have. The game object is located on the Moving Platforms layer and it doesn't have any Tile Map components at all, is just a regular moving platform.

    Any clue on how to fix this?
     
  50. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Answering to myself: it was just the wrong setting on Detach Method.