Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

[RELEASED] Easy Character Movement 2

Discussion in 'Assets and Asset Store' started by Krull, May 5, 2021.

  1. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @mookfasa,

    Well you can simply interpolate your transform position and rotation respectively, however worth note the character will only resolve its continuous collision based in its given velocity (the one passed to the CharacterMovement Move method) so while it will still resolve discrete collisions depending of your usage it can be enough or not.

    A more robust implementation when interpolating position should be passing the interpolation resultant velocity to the Move method so it performs the fully continuous collision along your given interpolated position.
     
  2. bvonline

    bvonline

    Joined:
    Feb 27, 2021
    Posts:
    85
    Thank you very much for your effort doing that tank script. Great help! Could be used for a demo video in the store, that it works also with tanks :) Have a good weekend.
     
    Krull likes this.
  3. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @bvonline,

    Glad I could help :) and thank you for the suggestion, it's a great idea, I'll add a basic example in the following update!

    Regards,
    Krull
     
    bvonline likes this.
  4. LuiBroDood

    LuiBroDood

    Joined:
    Mar 13, 2019
    Posts:
    84
    any estimate how long full Fishnet integration is coming along?
    this controller is amazing !
    thanks
    i guess Fishnet updating alot recently too
     
  5. Asarge

    Asarge

    Joined:
    Jun 2, 2018
    Posts:
    26


    Hi Krull,

    I have a grapple in which I take off the constrainToGround when attached. When grounded & grappled ideally you would enter a water ski behavior but not entirely sure if these should be their own movement modes or are there some grounded check functions I can access while in falling mode for situations like the pic above (where I could reapply the ground constrain at this point)?
     
  6. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @LuiBroDood,

    No estimated release date yet, sorry. Having said that, the development is progressing well and hopefully won't take too long to release the update.

    Regards,
    Krull
     
    LuiBroDood likes this.
  7. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @Asarge,

    First of all let me tell your game looks great! :D

    About your question:

    You could use the PauseGroundConstraint method to temporarily disable the ground constraint, it will automatically re-enable it after its timer completes. This is what jumps do.

    The disable pause constraint (i.e: characterMovement.constrainToGround = false) is mostly used for movement mode changes, like flying, swimming so the constraint is disabled / re-enabled as mode changes.

    Regards,
    Krull
     
  8. Hukha

    Hukha

    Joined:
    Aug 12, 2013
    Posts:
    61
    Hello Krull!
    I'm having a bit of a problem with ECM2. I'm using it for all that my character movement needs and it's awesome, but not sure the next thing that I want to do is possible with it. I would like in a specific movement mode to have everything climbable/walkable, that means that walls can be ground also under certain circumstances.
    The problem with this is that when that happens, the character should be snapped to where is walking/climbing no matter what the gravity is, shouldn't be able to jump or "fall". (Easy to understand if you think in a ball sitck to the wall)

    Also the rotation of the capsule should change and that can be a problem too with ECM2, but can be fixed easier.

    This needs to be done because I want the character to move around edges etc

    Do you think there is a possible way to achieve this without disabling everything about the controller and writing my own?

    Thanks!
     
  9. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @Hukha,

    ECM2, while it includes default movement modes, one of its many strengths is its ability to be extended and let users build their own custom mechanics on top of ECM2.

    For cases like yours, I think a custom movement mode is the way to go, as what a movement mode does is set the rules on how a character will be moved and it can include sub-states (if needed) as you can see in the ladders examples.

    In this custom mode, your character won't be affected by gravity or be able to jump (unless you want), a custom movement mode basically lets you control how the character's velocity is modified as you can see in the included default modes

    Let me know if I can help you any further.

    Regards,
    Krull
     
  10. Asarge

    Asarge

    Joined:
    Jun 2, 2018
    Posts:
    26
    Hello and thank you Krull,

    I tried using PauseGroundConstraint as well and could likely toggle it to velocity so I could launch off jumps while grappling but it does function very nicely currently while in falling mode and sliding along ground.

    Ideally I would like to be able to access whatever ground check functionality so I can have it work in other movement modes and also match the same detection used in ECM2. I can't find the exact reference chain or documentation to do this properly if you know how I can achieve this.
     
  11. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    121
    I've tried a few different things to make the character launch without it being a Jump, I think this is correct:


    Code (CSharp):
    1.                     Character.PauseGroundConstraint(5f);
    2.                     Character.LaunchCharacter(velocity, true, true);
    3.  
    But it doesnt work. The velocity Vector3 definitely has a Y component, all values are set, but it still moves on the plane of the ground.

    I also tried:
    Character.AddForce(velocity, ForceMode.VelocityChange);

    And I tried setting the `Movement.constrainToGround` manually, and none of them let the character leave the ground. The default movement is walking, but with the Pause I thought this would work.

    What am I missing?
     
  12. VeryHotShark

    VeryHotShark

    Joined:
    Mar 11, 2017
    Posts:
    13
    Hi I wanted to ask how does ECM2 compare to the kinematic character controller asset made by Philippe st Amand? https://assetstore.unity.com/packages/tools/physics/kinematic-character-controller-99131#publisher

    I'm wondering which one to buy and both seems pretty similar

    Thank you
     
  13. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    121
    Krull and Pixelith like this.
  14. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @Asarge

    ECM2 through its CharacterMovement component offers a great amount of valuable data to retrieve, from your Character you access collision info (CollisionResult struct) overriding the OnCollided event and to retrieve ground info (FindGroundResult struct) overriding it's OnFoundGround method. Alternatively, you can directly subscribe to the CharacterMovement Collided and FoundGround events to retrieve the same data.

    The CharacterMovement also exposes this info through its currentGround property, and lets you iterate through collisions found during last Move call if preferred using the GetCollisionCount() and GetCollisionResult() methods.

    Lastly, the CharacterMovement component exposes the internal methods used to perform ground detection so you can use those same methods when implementing custom mechanics (vault, climb, etc) to ensure proper ground detection continuity, the methods are FindGround and ComputeGroundDistance methods, this highly flexible functions let you override the character's position so you can use those to validate desired positions, sample a position, etc.

    I suggest you take a look at the API Reference for the CharacterMovement component, as it offers a great amount of functions to ease your development with it.

    Regards,
    Krull
     
  15. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @ge01f

    That seems correct to me, as it's exactly the same approach used in the Jump method, bouncers, etc.

    Worth note the PauseGroundConstraint is only needed when your character is in walking movement mode, as other modes, like flying and swimming, disable the ground constraint and re-enable when the mode is changed.

    Worth noting a character, (being a kinematic character) won't do anything unless you call its CharacterMovement.Move method, possibly the missing piece of your code?

    I suggest you take a look at the Character Move() method and its DoJump() method to see the PauseGroundConstraint use during the jump.

    Regards,
    Krull
     
  16. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @VeryHotShark

    First of all thank you for your interest in ECM2!
    About your question:

    They are similar as both are character controllers, pretty much like unity's built-in character controller , i.e: A specialized component aimed to perform collision constrained character movement.

    While they share the same category and some features, they also differ a lot in features and implementation. ECM2 it's basically two products in one, the CharacterMovement component, this like KCC, it's the character controller used by ECM2 and works as a direct replacement for unity's built in character-controller and follows the same ease to use approach, a single Move method call, once again just like built-in CC.

    ECM2 adds a higher level Character based on top of its character controller (the CharacterMovement component), this Character based classes implements a highly configurable friction based movement model and built in common character movement modes and mechanics like walking, sprinting, falling, flying, swimming, crouching, jumping, root motion support, etc.

    ECM2 includes specialized Character classes like, FirstPersonCharacter, ThirdPersonCharacter, AgentCharacter, etc, to serve you as a strong foundation to build your game mechanics on top of it as it has been developed to be ease to work with (as-is) and easy to extend.

    Hope this helps you, however if you have any further questions, please let me know.

    Best regards,
    Krull
     
  17. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    121
    Yes, thats what I was missing. Thank you.
     
    Krull likes this.
  18. angellnetwork

    angellnetwork

    Joined:
    Feb 8, 2018
    Posts:
    4
    Is not working at all with Unity 2021.3.3f1 LTS i get 29 errors about the input system all though it is installed, i also provided you with a screenshot so you can help me, thanks.

    this is one of the 29 errors i get.
    Assets\Easy Character Movement 2\Characters\Source\Characters\AgentCharacter.cs(3,19): error CS0234: The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
     

    Attached Files:

  19. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hello @angellnetwork ,

    This is strange, as it definitely seems to be missing the input system but you already have installed and enabled it...

    I suggest you create a new clean project and import the ECM2 package, (it will show errors since the input system package will not be installed), once ECM2 package has been installed, please install the unity input system (1.3.0 Release), it should fix the missing input system errors.

    I did a quick test using the same unity version and it worked following the above procedure.

    Let me know if I can help you any further.

    Regards,
    Krull
     
  20. NexonVision

    NexonVision

    Joined:
    Aug 30, 2018
    Posts:
    8
    is there a way to replicate moving on a slippery surface. ex: you run on ice and after you stop pressing any movement keys you will slide for a little bit.
     
  21. LunaTrap

    LunaTrap

    Joined:
    Apr 10, 2015
    Posts:
    120
    Hello! I bought this beautiful asset to make my 2.5d platformer and I'm loving it! I might come back with some questions on how to achieve certain tricks, like moving sand to make my character sink slowly but I think I can achieve the effect with physics volumes if I'm not mistaken, will report back if I fail to do it
     
  22. LunaTrap

    LunaTrap

    Joined:
    Apr 10, 2015
    Posts:
    120
    I also think I know how to achieve jump thru platforms, Using the one-way platform example I can just use another trigger on the other side to trigger only on a button press to make the character ignore the platform so it drops thru the platform. I think I know how it's done, otherwise I will ask here if I fail to do it on my own, Loving the asset!
     
  23. LunaTrap

    LunaTrap

    Joined:
    Apr 10, 2015
    Posts:
    120
    Update! I was able to implement the 2-way thru platform and I even added a background camera to render the platform behind the character. I love this asset!

     
    Krull likes this.
  24. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @NexonVision,

    Sure, the character's movement (when on walkable ground) is modeled using the Max Walk Speed, Max Acceleration, Braking Deceleration Walking and Ground Friction. From this, you can set braking deceleration to zero and tweak your movement usini the Max Acceleration (velocity rate of change) and the Ground Friction (affects changes in direction).

    To model a slippery movement, try setting the Braking Deceleration Walking to zero, the Max Acceleration (i.e: 8) and the Ground Friction to a lower value (i.e: 1), this will simulate a slippery surface.

    Regards,
    Krull
     
  25. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @LunaTrap,

    First of all thank you for purchasing ECM2 and happy to hear you like it!

    About your question(s):

    Sure thing, feel free to post questions here (or through support email) while I prefer email support, posting here will help others in the same situation.

    The physics volume at great sight is a just trigger with the difference the character enters / leaves this volume until the character's center is in or out of it, unlike regular triggers, and obviously the addition to modify the character's state.

    Yes, the included example is jump-up only, but as you commented you can use another trigger to do the jump-down part in a similar way.

    Looking great! pretty clean implementation. Let me know if you need further assistance.

    Cheers,
    Krull
     
  26. AqueductGames

    AqueductGames

    Joined:
    Dec 18, 2018
    Posts:
    2
    Hello,

    How would I go about making it so the character moves relative to it's parent instead of relative to the world? Currently, if I parent the player to a moving and rotating platform it does not work as intended. I would want the player to use it's local coordinate to handle movement instead of using the world coordinates.

    Is there any way to achieve that?

    - Zachary
     
  27. Zultron

    Zultron

    Joined:
    Dec 26, 2012
    Posts:
    59
    Hi, there how would I go about detecting which foot is in a walk cycle is currently off the ground?

    The goal is to have the character naturally stop with the same foot that was ahead in the animation cycle at the moment the player wanted to stop the character.

    Ideally, I need to play the animation depending on the foot and inputmagnitude in the walk cycle. Any input would be appreciated @Krull

    I see there is jumpleg method which is close to what I am trying to do but not quite would it be better to use animatorpivotweight?
     

    Attached Files:

    Last edited: Jul 22, 2022
  28. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi Zachary,

    ECM2 automatically handles the moving / rotating platform for you, I mean, you no need to do anything in particular (no need to parent it), just make sure to set the impart platform movement, impart platform rotation and impart platform velocity properties to true.

    Additionally, it allows you to explicitly attach this to a moving 'platform' so it does not depend on ground state using the CharacterMovement SetPlatform function and SetPlatform(null) to detach from 'platform'.

    Regards,
    Krull
     
  29. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    494
    Hi, in my game I want to play different landing animations based on whether my character jumped before landing or he just fell from higher ground and landed. The most obvious way for me was to check in OnMovementModeChanged callback if the current mode is Falling and if IsJumping() is true or not. But this hasn’t worked because _isJumping variable are set after movement mode is set to Falling so when the callback is firing isJumping is always false. I placed movement mode after isJumping and it’s working now but I would love to not have to change Character.cs because I'd need to manually copy all the changes when a new version of this script is released. Maybe there is another way to check this?

    Also I've found that IsJumping is always true while you hold the jump button. This seems strange because there’s another variable for this — jumpButtonPressed and because of this you can’t actually check if you are truly jumping or not.

    Btw, in fall damage example landing callback is not firing consistently if the character is jumping in place. I suppose it's because of the float precision when you compare fallenDistance with zero. You can easily check this by opening fall damage example and jump in place a few times — Debug.Log will not show in console on every jump.
     
  30. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @Onigiri ,

    For this, you can use Character events such as OnJumped, OnReachedJumpApex, OnLanded, etc, and use the characterMovement.landedVelocity to determine how fast it landed and react accordingly. You can find the working example in the 3.1 Character Events folder (Easy Character Movement 2\Characters\Examples\3.- Events\3.1.- Character Events) .

    The OnMovementModeChanged it's basically a FSM enter / exit method triggered when movement mode is changed.

    About the fall damage example, I'll need to review it as it could be a bug. Thanks.

    Regards,
    Krull
     
  31. Asarge

    Asarge

    Joined:
    Jun 2, 2018
    Posts:
    26
    Hi Krull,

    I'm having troubles resetting my transform smoothly, if I do if (transform.up = Vector3.up) { originalRotation = true; } the character will sometimes lock up and freeze. If I do this angle check and then apply a safety reset it will prevent the lock but look a bit snappy (perhaps due to the custom OnLateFixedUpdate?).

    How can I properly reset the transform smoothly?

    Code (CSharp):
    1.     protected override void UpdateRotation()
    2.     {
    3.         base.UpdateRotation();
    4.  
    5.         if (originalRotation == false)
    6.         {
    7.             Quaternion r0 = transform.rotation;
    8.             Quaternion r1 = Quaternion.LookRotation(transform.forward, Vector3.up);
    9.             Quaternion lerpRotationReset = Quaternion.RotateTowards(r0, r1, 2.4f); //120f * time
    10.             if (!grappleAttached)
    11.             {
    12.                 transform.rotation = lerpRotationReset;
    13.             }
    14.             if (Quaternion.Angle(r0, r1) < Mathf.Epsilon)
    15.             {
    16.                 transform.up = Vector3.up;
    17.                 originalRotation = true;
    18.             }
    19.         }
    20.     }
     
  32. FGRivera

    FGRivera

    Joined:
    Jun 3, 2013
    Posts:
    16
    Hi Krull!
    I am absolutely loving ECM2 and am so impressed with how comprehensive and flexible it is. I have a couple of questions if you don't mind:
    1) What is the difference between Braking Deceleration Falling and Falling Lateral Friction. They both seem to do the same thing in increasing how quickly you stop moving laterally while in the air.
    2) Is there any way we can tweak friction for the the Collide-and Slide? Particularly, I want to reduce sliding while in the air. Increasing Falling Lateral Friction gives me this result, but I want to be able to maintain the momentum of having little to no friction when not colliding.

    Thanks!
     
  33. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776

    Hi @Asarge,

    The LateFixedUpdate is used so the character is in sync with physics and moved / updated using a fixed timestep and most important to be interpolated (please make sure your character's rigidbody has interpolation enabled) that's the only difference of using the LateFixedUpdate method, and actually the built-in CC behaves the same way IF moved inside the LateFixedUpdate, it will be in sync with physics using a fixed timestep AND interpolated.

    To reset the character's rotation to world-up I suggest you update the characterMovement.rotation instead of the transform.up, as internally it update collider rotation too, i.e:

    Code (CSharp):
    1. // To instantly set character's up
    2. Vector3 targetNormal = Vector3.up;
    3. characterMovement.rotation = Quaternion.FromToRotation(GetUpVector(), targetNormal) * GetRotation();
    Or
    Code (CSharp):
    1. // To smoothly align the character's up-axis
    2.  
    3. Vector3 targetNormal = Vector3.up;
    4. Quaternion targetRotation = Quaternion.FromToRotation(GetUpVector(), targetNormal) * GetRotation();
    5.  
    6. characterMovement.rotation = Quaternion.Slerp(characterMovement.rotation, targetRotation, 5.0f * Time.deltaTime);
    Regards,
    Krull
     
    Asarge likes this.
  34. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @FGRivera

    Thank you, happy to hear you like ECM2! :)

    About your questions:

    Braking Deceleration Falling is a constant deceleration value applied only when no input is detected, most of the time this should be set to zero, however if you want a more instant 'stop' you can use it.

    Falling Lateral Friction is the friction applied when character is falling, this at its default value (0.3) works as air drag, however the friction affects the change in movement direction where a higher friction value offers a more snappy movement.

    No without modifying the CharacterMovement core code, however, you can simply modify the character's velocity as needed this should give you the effect you are looking for, for this you can override the Character CalcVelocity method as this is the method responsible of compute a new velocity for the given state, applying the effects of friction or braking friction and acceleration or deceleration.

    Let me know if you need any further assistance.

    Cheers,
    Krull
     
  35. NJ333

    NJ333

    Joined:
    Jan 31, 2021
    Posts:
    5
    Hi, I want to create AI movement with perfectly synced animations. What is the best way to do it? As my current understanding there are 2 ways to achieve it:
    1. I can turn on root motions and animation will take control over movement.
    2. I can turn off root motions and use navmeshagent's velocity to correctly set animation parameters (imagine I have movement x and movement z float parameters). on the animator controller side inside "2D Freedom Directional Blend Tree" I can use compute positions feature and correctly compute pos X and pos Y for my custom animations.
    I am struggling which is the better way to go. I see there is Top-Down character example but that character uses pre defined values in Agent Character component such as Rotation Rate, Max Walk Speed... I don't know from were you got those values. Thanks!
     
  36. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @NJ333,

    You are right as there is no specific way as ECM2 does not use animations or requires your animation be authored in a particular way. With ECM2 you are free to author your animations as you prefer, but you use your character state data (i.e: its speed, is grounded, is jumping, is falling, etc.) to sync your animation with the required data for animations, be it using an animator or any other solution like animancer for example. Please take a look at the API reference to check all the data available to read from your character.

    You can get a lot of character state information from the Character class and the CharacterMovement (analogue to unity's built-in CC).

    Hope this helps, however if you have any further questions please let me know.

    Best Regards,
    Oscar
     
  37. Nate_Osso

    Nate_Osso

    Joined:
    May 24, 2022
    Posts:
    2
    Heya, Krull. Is there still a discounted upgrade path?
    Thinking about starting a side project and upgrading to ECM2.
     
  38. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @Nate_Osso

    Sure, you can upgrade from ECM1 or CharcterMovement to ECM2, just make sure to log in with your account owning one of the other assets so the upgrade discount shows.

    Regards,
    Krull
     
    cursedtoast likes this.
  39. cursedtoast

    cursedtoast

    Joined:
    Apr 27, 2018
    Posts:
    62
    Thanks! Didn't realize I was still on my work account.

    The current discount threw me off, but i see it goes down three more dollars when on the correct account haha. I gather the asset went up in price a bit (understandably so, seems a lot has gone into ECM2) so it makes more sense now!

    I'm a big fan of the original and used it quite a bit, so I'm excited to check out the new system when I can upgrade.

    Cheers, and thank you!

    Edit: okay I upgraded and spent a few hours reading the docs and sample code. This is pretty nice! It feels very UE inspired, which is a great thing imo.
     
    Last edited: Aug 9, 2022
  40. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @cursedtoast

    That's great! Thank you for the upgrade and happy to hear you like it.

    Very true ::D, big fan of Unreal Engine CharacterMovement component so decided to base mine from it BUT following the easy to use Unity workflow we all love!

    Regards,
    Krull
     
    cursedtoast likes this.
  41. TheMK-_-

    TheMK-_-

    Joined:
    Feb 8, 2018
    Posts:
    26
    Hi @Krull I was wondering if i could pick your brains as for the best way of implementing the following using ECM2?

    I would like to be able to do stun and knock back effects on my player character. For the knock back I'm currently experimenting using impulse forces applied in various directions, I was wondering though how to stop inputs on a stun effect and possibly also slow down effects?

    Any help will be much appreciated, and thanks again for your asset.

    Many thanks,

    Mike.
     
  42. NJ333

    NJ333

    Joined:
    Jan 31, 2021
    Posts:
    5
    Hi,

    I want to make ECM2 work as First Person Controller with full body character, is there an example of this? I tried to move camera inside eye pivot point but then moving didn't work correctly
     
  43. Asarge

    Asarge

    Joined:
    Jun 2, 2018
    Posts:
    26
    Hi Krull,

    I'm having troubles integrating your third person cinemachine example. It doesn't have the same features as the normal ECM2 third person camera and combining them is difficult as ECM2's ThirdPersonCameraController is using lots of calculations that conflict with cinemachine such as the target following (and potentially dampening and clamping?). Could you update the third person cinemachine example script so it includes the same basics ThirdPersonCameraController contains and is compatible with cinemachine? Controller, cursor lock, and whatever movement is necessary that doesn't conflict with cinemachines.

    Also I saw some post from last year asking for a Discord and that you wanted to but had to look into setting it up. It's very quick & free to do (couple minutes) and would be a huge help for everyone using ECM2 as users can help each other easier with problems. If not I could even start a temporary user ran community for it if you would allow us to post it around as it would make the workflow of this asset a lot easier.
     
  44. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @TheMK,

    For the knockback you should use the Character AddForce method, this works just like Unity's counterpart. Worth note the character's movement is affected by its friction and deceleration values, so those will affect the force effect. I suggest you set the deceleration to zero and model your character's movement with friction as this will simplify things.

    For the input, you need to manage the 'stun state' and prevent input, for this, in your custom character (i.e: the one extending Character class) you should override the HandleInput method, this will let you modify the character's input depending your character's logical state, as follows:

    Code (csharp):
    1.  
    2. protected override void HandleInput()
    3. {
    4.     if (isStunned)
    5.     {
    6.         // do not handle inputs  
    7.     }
    8.     else
    9.     {
    10.         // Handle default inputs
    11.  
    12.         base.HandleInput();
    13.     }
    14. }
    15.  
    Regards,
    Krull
     
  45. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Using the included Unity Character Model, parent the the First Person Root node to the included Unity Character Head game object, and it carry the animation while allowing to control the camera as the regular first person rig.

    It works very well, but the included example animation is not the best for this, as it would need to correctly handle backwards and strafe movement like a First Person.

    The modified structure looks as follows:

    upload_2022-8-13_18-59-25.png

    Cheers,
    Krull
     
    NJ333 likes this.
  46. Asarge

    Asarge

    Joined:
    Jun 2, 2018
    Posts:
    26


    I'm trying to make the character float when on a hoverboard and tried offsetting the transform to achieve the start of this video. The value shows that it is changed in the inspector but the character won't move up. How should I properly be changing this on runtime? Or if you have another method for hovering instead I can try that.

    Code (CSharp):
    1.     //this one sets it to 1 in inspector but no visual result of character being offset
    2.     Vector3 snowboardHoverHeight = new Vector3(0, 1, 0);
    3.     //tried this as well but still 0,0,0
    4.     Vector3 snowboardHoverHeighttest { get { return characterMovement.rootTransformOffset; } set { characterMovement.rootTransformOffset = new Vector3(0, 1, 0); } }
    5.  
    6.     private void StartSnowboarding()
    7.     {
    8.         _isSnowboarding = true;
    9.         snowboardObject.SetActive(true);
    10.         leaningAnimator.Parameters.SideSwayPower = 2f;
    11.         characterMovement.rootTransformOffset = snowboardHoverHeight;
    12.     }
    13.  
    14.     private void EndSnowboarding()
    15.     {
    16.         _isSnowboarding = false;
    17.         snowboardObject.SetActive(false);
    18.         leaningAnimator.Parameters.SideSwayPower = 1f;
    19.         characterMovement.rootTransformOffset = Vector3.zero;
    20.  
    21.         //jump off board
    22.         PauseGroundConstraint();
    23.         LaunchCharacter((transform.up * 8.0f) + (transform.forward * 20.0f), true, true);
    24.         animator.Play("Jump_Slide");
    25.     }
    Edit Note: After snowboarding starts there is also a PauseGroundConstaint() running while _isSnowboarding is true. Maybe this is causing a return somewhere where the final rootTransformOffset isn't going through despite showing in the inspector?
     
    Last edited: Aug 14, 2022
  47. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    Hi @Asarge,

    When using cinemachine you should not use the ThirdPersonCharacter and instead extend the regular Character class, as we want to add extra functionality to the Character class, in this case, implement a typical third person camera system using cinemachine, this is what the cinemachine example shows, just a basic integration example so users can develop on top of it.

    Also I saw some post from last year asking for a Discord and that you wanted to but had to look into setting it up. It's very quick & free to do (couple minutes) and would be a huge help for everyone using ECM2 as users can help each other easier with problems

    Yes, that's a good point and something I planned to do, unfortunately ECM is not my full time job and due to time constraints it's really hard for me to manage and support a discord server, not to mention asset license validation integration, etc. That's something I definitely want to do, but hard to do right now honestly speaking.

    If not I could even start a temporary user ran community for it if you would allow us to post it around as it would make the workflow of this asset a lot easier.

    Sure, that would be great, thanks! and once I finally launch the 'official' we could merge it along the road if needed.

    Regards,
    Krull
     
    Asarge likes this.
  48. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    776
    The Root Transform Offset offsets the model only (your character's visual representation), however the character's capsule (its real position on world) is unaffected, a mere visual thing.

    For your hoverboard, if it's just an animated model the offset approach should work well just make sure its collider does not collide with your character's capsule or its collision layers, otherwise it would interfere with the character's movement and ground detection algorithm.

    By other hand, if your hoverboard is a kind of physically animated object you could use it as a dynamic platform where the character rides a separate object or treat it like a vehicle where the character is disabled and mounted to the 'vehicle'.

    Cheers,
    Krull
     
  49. FGRivera

    FGRivera

    Joined:
    Jun 3, 2013
    Posts:
    16
    Hi Krull,

    I'm doing some slope detection for custom movement and running into an issue where walking off the edge of some ramps finds a normal on the edge. You can see in the picture two yellow debug ray's drawn on the normals of the corner when the ground normal registers the corner of the collider as a slope. Character is using flat base. Any ideas how I might be able to avoid registering the corner as ground like this? Thanks.

    Edit: I tried detecting slopes with ground.surfaceNormal and am still getting the same result

    upload_2022-8-15_22-53-21.png
     
    Last edited: Aug 17, 2022
  50. Asarge

    Asarge

    Joined:
    Jun 2, 2018
    Posts:
    26
    Hi Krull,

    Sorry if I didn't explain well but it's more that I'm not able to properly change the offset in runtime as the y value changes but he doesn't move up (likely a coding error on my part).

    Right now the boarding functions exactly how I want it I just need to move it up a bit but am unsure how. If I make it a separate controllable vehicle object how would I go about that with this controller? At the moment it's just a visual object childed to his foot and the logic is additional forces on top of the existing controller. I saw your video/post on imparting platforms to ride vehicles but do you have an example of how to integrate the controller to switch from controlling the character to vehicle?

    Here is how it is working and my goal is just to move it up but it's hard with how much collision solving logic is used under the hood, I'm unsure how to approach this.