Search Unity

[RELEASE] Easy Character Movement 2

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

  1. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi @JohnnyGo-Time,

    That's quite strange as actually ECM2 does not use any input unless your Character has its actions assigned, otherwise it simply ignores all input as it allows externally control of the character.

    Are you using the ECM2 included ThirdPersonCamera ?

    Regards,
    Krull
     
  2. Krull

    Krull

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

    Yes, with ECM2 being rigidbody based its collider requires a frictionless material.

    Please make sure your terrain is part of the character's walkable layer and the Character can collide with terrain (eg: collision layers matrix), otherwise the system won't 'see' the terrain and will try to slide the character off it. You can use the character's properties to completely tweak the movement (acceleration, deceleration, friction, etc).

    Additionally as a terrain can contain many small faces of different angles, it can exceed your current SlopeLimit causing your character's to slide as once again the system will see a non-walkable surface and cause the Character to slide off of it.

    To completely disable a character's movement, simply set its movement mode to None, and this will completely ignore movements (turns character into a kinematic rigidbody), additionally you can use the ApplyPushForce and Push Force Affects Characters to prevent a character push others, or even use the Snippet OnApplyPushForce method to selectively allow / disallow push others.

    Now to move a character by Animation, you will need to enable the Use Root Motion, just make sure your Animated model contains the RootMotionController component on it, as it is the one who feeds the animation velocity to the Character. Please refer to the include Root motion example for a complete working example of this.

    Cheers,
    Krull
     
  3. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hey @my_little_kafka

    Thank you for upgrate to ECM2 and happy to hear you like it!

    About your question, yes the system now treats the Monobehaviour functions as private and simply call its overridable On_ version, son in your case yes, comenting the Monobehaviour section will completely disable the system, so you will need to call the OnXXX versions, as those are where the code is actually implemented.

    Kind regards,
    Krull
     
    my_little_kafka likes this.
  4. JohnnyGo-Time

    JohnnyGo-Time

    Joined:
    Aug 8, 2021
    Posts:
    14
    Hi @Krull - yes I inherited ThirdPersonCharacter into my own class, so through that have a ThirdPersonCameraController.
     
  5. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi @JohnnyGo-Time

    Something I don't get it clear from the video is if you are using a ECM2 Character and with the new input system, as actually it checks if the mouse cursor is over a UI element before allow a cursor lock, as see here in the ThirdPersonCharacter input action handler

    Code (csharp):
    1.  
    2. /// <summary>
    3. /// Handle cursor lock InputAction.
    4. /// </summary>
    5.  
    6. protected virtual void OnCursorLock(InputAction.CallbackContext context)
    7. {
    8.     // Do not allow to lock cursor if using UI
    9.  
    10.     if (EventSystem.current && EventSystem.current.IsPointerOverGameObject())
    11.         return;
    12.  
    13.     if (context.started)
    14.         cameraController.LockCursor();
    15. }
    16.  
    Also an issue I noticed (not related to ECM2) is when the game window in editor is scaled down, the ui do not works as expected unless the game window is maximized or your Canvas Scaler -> Ui Scale Mode is set to Scale With Screen Size.

    Let me know if this solves your issue.

    Regards,
    Oscar
     
    JohnnyGo-Time likes this.
  6. SirDoombox

    SirDoombox

    Joined:
    Apr 16, 2018
    Posts:
    4
    Hey, I love the asset so far but I do have one major complaint.

    Currently the stack is so complicated and hard to navigate that I'm finding it very time consuming to learn and integrate my own current non-asset based input setup into the default Character implementations.

    Is there any chance in the future that Input handling will be split out to a separate component and a base class provided so you can quickly and easily intergrate your existing input setup without having to do a large amount of work?

    It would also prevent an excessive amount of null checking to see if it should use the provided Input assets or do nothing hoping that a "Controller" will pick up the slack.

    Ideally a base class such as...
    Code (CSharp):
    1.  
    2. public abstract class PlayerInputBase : MonoBehaviour
    3. {
    4.    public abstract void Initialise();
    5.    public abstract Vector2 GetLook();
    6.    public abstract bool GetCrouch();
    7.    // etc...
    8. }
    9.  
    which would result in the current implementation being structured as such...
    Code (CSharp):
    1.  
    2. public sealed class CharacterInput : PlayerInputBase
    3. {
    4.    public InputActionAsset actions;
    5.    private InputAction _lookAction;
    6.  
    7.    public override void Initialise()
    8.    {
    9.        _lookAction = actions.FindAction("Mouse Look");
    10.    }
    11.  
    12.    public override Vector2 GetLook() => _lookAction.ReadValue<Vector2>();
    13.    // etc...
    14. }
    15.  
    Providing fallbacks for the old input system should be far simpler in this case with preprocessor directives.

    Chances are this is more or less precisely the implementation I will end up with, but it's going to require a relatively large amount of work restructuring and rewriting in a codebase I'm not familiar with, which is a shame.
     
    Last edited: Sep 15, 2021
  7. Sapien_

    Sapien_

    Joined:
    Mar 5, 2018
    Posts:
    69
    Where is the code that deals with moving platforms? Could I not add an extra condition where instead of just "if(grounded)", Could I do "if(grounded || onWall)"? Not entirely sure how the moving platform physics works.
     
  8. Lekonia

    Lekonia

    Joined:
    Sep 18, 2019
    Posts:
    3
    Hey everyone, I wanted to say that this is an awesome asset to use.
    but i have come across a strange problem and only seems to happen with ECM2.
    When i try to upgrade the materials that exist in the Asset (to HDRP) so that the prefabs don't have that magenta colour, i come across these errors and i cannot upgrade any materials when i have ECM2 in my project.
    I am also using Unity 2020.3.5f1.
    I hope i have given enough information.
    Thank you.
    Screenshot 2021-09-17 102549.png Screenshot 2021-09-17 102620.png
     
    Last edited: Sep 17, 2021
  9. whitesnake

    whitesnake

    Joined:
    Aug 24, 2012
    Posts:
    1
    Hi, I bought the ECM2 a few days ago.
    I like ECM2 and I changed my game controller to ECM2.
    But ECM2 doesn't have the features I need.
    The camera offset.
    I'm making a third person shooter game.
    I really need the camera offset feature.
    Is there a simple way to do this?
    Or add the feature in the next version.
    Or using cinemachine is also good.
     
  10. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hello @SirDoombox,

    Thank you for your suggestion, it is a pretty good idea, and actually you can already use it!

    A Character won't use / process any input when you leave it action property empty this allows you to control your character from external files, AI, Visual scripting solution (like included Bolt examples) and so on.

    So you simply will call your character input action commands like SetMovementDirection, Jump, StopJumping, Crouch, Stop Crouching, Sprint, StopSprinting, etc.

    In the end with ECM2 you really only need to extend a Character class when you want to add custom functions but once again, you can simply ignore the input part and handle it externally like your suggested idea.

    Kind regards,
    Krull
     
  11. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi @Sapien_,

    Yes, that's a possibility too, however the character will only update the _activePlatformVelocity when it is on top of it (eg: from its ground hit info), so you will need to update it when grabbed, and not only when on top.

    This is managed in the CharacterMovement Move method and in particular its UpdateMovingPlatform method, where basically read the 'riding' platform velocity as the active platform velocity, after internal movement (collide and slide), add the activePlatformVelocity to the rigidbody velocity to move with the platform.

    Regards,
    Krull
     
  12. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hello @Lekonia

    Thank you for purchasing it and happy to hear you like it!

    About your report, I will perform a few tests, however could be an incompatible material case, as it uses older built in rendered form maximum compatibility across different unity versions as it is the common denominator.

    Additionally you can ignore the samples in your project so you wont need to convert to newer RP.

    Cheers,
    Krull
     
    Lekonia likes this.
  13. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hello @whitesnake,

    Thank you for purchasing it and for your kind comments about it!

    Yes, I suggest you use Cinemachine as this simply includes that and any other camera related functionality your game could need and IMHO the best option, after all Cinemachine has been created for this as much more ;)

    You can find the included Cinemachine to help you get started with it, just remember to install the Cinemachine package before uncompress examples to avoid any issues.

    Best regards,
    Krull
     
  14. FJF61

    FJF61

    Joined:
    Mar 19, 2021
    Posts:
    5
    Hi Krull,
    Instead of the example animation, why is the animation in motion different from the animation in 3DMax, especially the position of the feet?
     
  15. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    467
    Hello,

    Newcomer to ECM I'm currently reviewing scripts, examples etc. It seem to be quite a good and robust system.
    One thing that is bothering me at the moment is regarding the character rotation.

    It's currently based on an enum that is either Charcter movement, Camera view or RootMotion

    I'd like to request an additional option: Custom or Script based

    The reason is that when overriding the UpdateRotation() method, it would just make things easier to customize.

    Here is an example:
    Top down view, character primary rotation is set to movement. But if the character has a weapon (in my game at least) a reticle pops on the screen (that part is managed by my own class) and defines the weapon direction.

    In ECM that would be translate by a custom override where I define the character rotation based on the weapon rotation (or in short: my reticle)

    I looked at the twin stick shooter example but it's not really what I want as in that case the reticle is controlled by mouse and it's not firing or anything, it's just rotating the character based on mouse input basically.

    I guess I can also override the updateRotation and in case it's neither one of the 3 options it's my own.. I'm not sure if that is clean enough though :)

    I'll dig in more but wanted your point of view here.

    Also I've read that you get a lot of requests and some make it to your asset examples and some have to wait.
    I'm very interested to have some traversal options, I love your ladder example.
    I was thinking about: vaulting above an obstacle and what I'm struggling the most with: a cover system where the character can cover behind a small wall (or at the corner of a regular wall) and move along that cover.

    Maybe that was part of ECM 1 examples but I never owned it

    I do have one last question regarding RootMotion

    I do not want to use root motion for all the basic movements etc. But I do have some animation that use root motion for combat.
    Such as a kick which will make the character move forward and rotate.

    In such situation should I just have a toggle logic where I toggle root motion "on" when starting the kick and toggle it off at the end? or is that more complicated than that?
     
  16. JohnnyGo-Time

    JohnnyGo-Time

    Joined:
    Aug 8, 2021
    Posts:
    14
    Edit - fixed the issue I'd asked about here and it was not an issue with ECM2! ;)
     
    Last edited: Sep 19, 2021
    Krull likes this.
  17. Sapien_

    Sapien_

    Joined:
    Mar 5, 2018
    Posts:
    69
    What about Rotating platforms that rotate on the Y axis?

    Also I'm assuming that this line...

    "activePlatform = groundHit.hitGround && groundHit.rigidbody ? groundHit.collider : null;"

    Is whats setting the _activePlatformVelocity?

    I have the normal of the wall being hit. How do I add that to the line or make use of this (without breaking everything lol).
     
    Last edited: Sep 21, 2021
  18. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi @
    Honestly not sure, as I have not opened it with max and since included animation examples are authored by Unity, probably due to some unity import settings.

    However, keep in mind ECM does not implement any kind of IK as a character controller; it focuses on moving the character's volume (eg: its capsule), so depending on the size of your capsule volume, the character's foot could not correspond to its 'ground'.

    Regards,
    Krull
     
  19. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    The rotation is handled later after internal physical update in the CharacterMovement OnLateFixedUpdate method, in particular in the RotateWithPlatform method.

    This line is just using the result of the ground detection (eg: the groundHit) and if it has a rigidbody uses it as the current active platform.

    Another option is handle this outside of CharacterMovement, I mean, you can use regular unity OnCollisionXXX / OnTriggetXXX events and or raycasting to detect when your character is or should grab the wall, then an option is simply add your grabbed platform's velocity to character's current, but this is just an idea and not tested in any way.

    Regards,
    Krull
     
  20. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi @Necka_

    Thank you for your suggestion, as for custom it's already there yes, as you say in your custom character (the one extending the character class) you can extend or completely override a virtual method, in your case the UpdateRotation method and implement your game required functionality on top of the one given by ECM, think of the 3 default methods as that just a default functionality to use but if no fit you, is perfectly fine replace it with your own implementation, as the twin stick example does.

    Thank you, and yes I have planned as part of updates add more gameplay examples like wall grab, wall jump, vaulting, etc among fixes and or new features, however my goal with ECM is to remain as a general solution controller, just with enough different game genres examples so users can get easier to get started with.

    Yes with root motion, you just toggle as needed or if all your character's movement is driven by root motion you can leave it enabled all time. The included 2.3.- Root Motion Toggle example shows how to toggle root motion, in this particular example the character's grounded movement is root motion based so root motion is enabled as long as the character is in Walking movement Mode.

    Just remember, by default the character is constrained to ground and its vertical velocity (Y component) is ignored, so if your root motion attack requires to leave the ground, you must set the Movement mode to Flying otherwise it will not 'jump'.

    You can even use a StateMachineBehaviour to modify the character's state based on your animation's state, as you can see HERE

    Regards,
    Krull
     
  21. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    467
    @Krull thank you very much for all the details in your answer, that gave me some good overview and the StateMachineBehaviour is definitely something I'm going to use.

    I spent now some more days with your asset and I love it. Simple as that.
    Fun story is that I bought the Humble Bundle Unity pack and saw another Rigidbody asset in there that I wanted but was never so sure. Well, I didn't like it overall so I searched a bit and found your asset. I must say I'm not disapointed.

    The fact that you didn't provide a big mess of a Controller is great. Each of us developers can just use parts of your examples here and there, extend over them and create the perfect controller for our game.

    I'm not an expert coder, I know my way around, so here you are doing the heavy lifting of the base ground, give big hints with your examples and then we can build upon that.
    I'm definitely looking forward to more gameplay example especially around traversal.

    I have something working really good now in my project, I took some gameplay example here and there and removed stuff I didn't need. I also created my own animator script based on yours to have also forward and lateral speed to create an 8 direction blend tree when strafind with a weapon. I also integrated Rewired in like 20mn... God that was so easy I love it.

    I do have 2 little questions related to the animator in case there is already something existing or an example for it:

    1- Is there a simple way to tell the animator that a character is going from left to right so quickly that it can trigger an animation for this?

    What I mean is that if the character is running full left and suddenly the player push the movement key full right then right now the Character will snap turn. But it would be nice like in games such as Tomb Raider or Uncharted that the Character does a smooth turn with proper animation

    2- In place turning: I'm sure I saw that in your original blend tree but it doesn't work. Right now when my character has a weapon it will turn around based on the mouse position. It's an extremely simple script in the UpdateRotation() method:
    Code (CSharp):
    1. Vector3 targetDirection = _aimTargetPosition - GetPosition();
    2. RotateTowards(targetDirection);
    But I wished I could find a simple way to feed my animator with some angle calculation so when I turn around my IDLE character, it does a in-place rotation with its legs/feet if you know what I mean

    But no worries, I will try on my own too
     
  22. Lekonia

    Lekonia

    Joined:
    Sep 18, 2019
    Posts:
    3
    @Krull

    Hi Krull, i just wanted to say thanks again for replying and trying to answer issues and questions in the past, i made a mention of issues with upgrading the materials in ECM2 for HDRP and Unity not being able to do so in 2020.3.5f1.

    I did an experiment and upgraded to Unity 2020.3.18f1 and materials upgraded without issues, though the small previews display the magenta, in the scene it displays its materials without issues, so it works and that is good.

    I do not know if you will find this usefull but i wanted to update you on that and take opportunity to extend my appreciation as well.

    Lekonia
     
    Krull likes this.
  23. WeatherStone

    WeatherStone

    Joined:
    Jul 8, 2020
    Posts:
    3
    Hey Krull, how are you?

    i bought ECM2 yesterday, and liked it so much, that i scraped my own character controler in favor of ECM2

    i am doing my game using visual scripting, so it will take me a couple of days to figure everything out
    i'd like to thank you for this amazins asset, and also i wanna ask: have you ever considered doing a discord server?

    cheers from brazil
     
    Krull likes this.
  24. VR_Junkie

    VR_Junkie

    Joined:
    Nov 26, 2016
    Posts:
    45
    Hey, just started using your controller and love it so far. You have a scene called "Third Person Controller Example Scene" where you use ThirdPersonController.cs instead of ThirdPersonCharacter.cs to control the character. Do you have similar controllers for First Person and Agent. I tried to make one of each myself based on your FirstPersonCharacter.cs and AgentCharacter.cs but honestly its throwing me for a ride. The reason I need them is kind of convoluted but necessary for my game.
     
  25. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi @Necka_,

    Thank you for kind words, and happy to hear ECM2 is working for you!

    As you can see HERE, you can use the character's movement direction and a dot product to detect a sudden change in movement direction, once detected you can update your animator accordly

    Mmm, actually the included Animator and model are unity authored as I am not good at modeling and or animating anything hehe, I think one possible solution is implement a kind of dead zone, to separate the actual movement from a 'rotation radius threshold) but not really tested it, just an idea.

    By other hand you can use root motion for that, for example if you enable root motion AND orient with root motion the example character uses root motion to perform in-place rotation as the root motion movement and rotation can be used separately as can seen in the included root-motion example.

    Kind regards and thank you for your positive review on the asset page!
    Krull
     
    Necka_ likes this.
  26. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi @Lekonia,

    Awesome! thank you for the update regarding this issue!

    Best regards,
    Krull
     
  27. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hello @WeatherStone,

    Thank you for purchasing ECM2 and glad to know you like it!

    It actually includes some getting started examples using Bolt but I think can be ported to other visual scripting solution if needed, its just I add out of box support for first-party assets only but does not means its limited to it.

    About discord, yes its a frequent request, but honestly I am not much familiar with hosting one, so will need to get familiar with it first, but yes, definitely a planned feature.

    Thanks, and warm greetings from Mexico!
    Krull
     
  28. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hello @VR_Junkie,

    Mmm, I think I did not included a First Person controller example, you mean an externally controlled FirstPersonCharacter right?

    I can add one as part of next update, but in the meantime you can actually implement it, its just a mater of leave the Character action property empty so the character do not process / handle input, and from an external script, call the Character input action methods, just like the ThirdPersonController do.

    Cheers,
    Krull
     
  29. VR_Junkie

    VR_Junkie

    Joined:
    Nov 26, 2016
    Posts:
    45
    Yes, I do mean an externally controlled First Person Character (and an externally controlled agent character while you are at it). And I will give it a shot again today.
     
  30. VR_Junkie

    VR_Junkie

    Joined:
    Nov 26, 2016
    Posts:
    45
    Hello, I made this video so you can see a new issue I am having (link below). I took the unity character off of your thirdpersoncontroller from the demo scene and applied it to the twinstickcharacter on the Twin-Stick example scene. As you can see when moving both sticks the characters animations get messed up. I have found the issue is the forward parameter in the animator is always 1 even if the character is going backward by holding the up arrow key and S (I assume in this case it should be -1). Is there a way to fix this or am I misunderstanding something?

    Side note: the audio is from a video I was watching, disregard the audio
     
  31. WeatherStone

    WeatherStone

    Joined:
    Jul 8, 2020
    Posts:
    3
    Hey again =)

    my question on discord is cos Discord allow for people to share their experiences and troubleshoot between themselves, without the need of you to have to personally answer everyone, it is a win win situation, for you, the developer, and us users =)

    by visual scripting i meant bolt, but i upgraded to unity 2021, so its called just visual scripting now, yeah, confusing LOL

    by the way, i got into my first real "problem"... in the bolt examples i saw the use of the "set movement" unit for moving
    the thing is, everytime i used it with the new VS and new input system, the player dont stop after moving, it keeps gliding
    if i use the add force, it works just fine
    my question is, can i use the add force normally, and my settings like max walking speed, and max walk acceleration will work just fine, or i am doing something wrong? for everything else, it is working like a charm, but i got this "quirk", that i cant trace where of what i got wrong

    well, thanks again

    ps: i really wish to visit your country someday =)


    edit: nevermind, i got a bunch of stuff wrong here, now managed to make it work, sorry =)
     
    Last edited: Sep 25, 2021
  32. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi@VR_Junkie,

    The idea with the twin sticks demo, is to use the right stick to control the character rotation while receives input, otherwise it fallback to orient to movement (from left stick), however the included Animator do not have any kind of strade animation so if you are using root motion this could be the cause of the character moving 'strange' since it do not have that animation.

    In the same example, the left stick feeds the movement direction in world space, while the right stick feeds the fireInput direction, so movement and rotation are completely decoupled

    For example moving the character backwards if no right stick is receiving input, the character will rotate towards the movement backwards move direction, you can modify it, removing the If from the update rotation method.

    Best regards,
    Krull
     
  33. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi @WeatherStone,

    Yes, I forgot about the bolt -> Visual Scripting since I pass most of time on 2019 LTS version for most of my current development.

    Happy to hear you solved your previous issue, and back on track!

    Nice!, you will be very welcome!

    Cheers,
    Krull
     
  34. hhungria

    hhungria

    Joined:
    Apr 22, 2017
    Posts:
    1
    Hello!!!
    I have days working on a Wall Grabber System. And even though my character detects the collision with the wall, I cannot make the character fall slower while he is next to the wall.

    I have changed the acceleration Velocity in all ways possible and still, nothing happens. I have also tried applying VelocityBraking but nothing happens.

    Can somebody help me?
     
  35. VR_Junkie

    VR_Junkie

    Joined:
    Nov 26, 2016
    Posts:
    45
    That makes sense, for my game I am trying to get the forward parameter in the animator to give me -1 so I can add a custom backward walk animation to the animator controller and it will work. Right now it always gives 1, even when moving backward with TwinStickCharacter.cs. How can I achieve this?
     
  36. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    467
    I personally use custom remapped values of the movements to be able to build 8 directions animator blend tree.

    First I have a little math helper as a static method in an helper script (you can have it in your animator script of course)

    Code (CSharp):
    1. public static float Remap(float x, float A, float B, float C, float D)
    2.         {
    3.             float remappedValue = C + (x-A)/(B-A) * (D - C);
    4.             return remappedValue;
    5.         }
    Then in the animator script I use this code to feed my animator with the X and Z remapped values:
    Code (CSharp):
    1.            
    2. Vector3 move = transform.InverseTransformDirection(character.GetMovementDirection());
    3. _remappedX = MathHelper.Remap(move.x, 0f, 1, 0f, 1f);
    4. _remappedZ = MathHelper.Remap(move.z, 0f, 1, 0f, 1f);
    5. _animator.SetFloat(RemappedLateralSpeed, _remappedX, 0.1f, Time.deltaTime);
    6. _animator.SetFloat(RemappedForwardSpeed, _remappedZ, 0.1f, Time.deltaTime);
    Finally that's how my blendtree is setup using those values (it's actually 16 directions in that case as I can blend walk or run depending on the speed)
    upload_2021-9-27_20-37-1.png
     
    Krull and VR_Junkie like this.
  37. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi @hhungria,

    You can make use of the Character Max Fall Speed to make your character fall slower or modify its gravity magnitude

    Alternatively you can make use of a PhysicsVolume to set a Max Fall Speed this will only happen when the Character is within that volume (volumes can be nested) otherwise the character will use its MaxFallSpeed as default value.

    A common practice here is to override the GetMaxSpeed method and handle your custom movement mode, in your case WallGrabbed to return the max speed for each particular mode / sub-mode / state.

    Best regards,
    Krull
     
  38. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    467
    I'm not sure what you are asking here?

    If you speak about the 2 last lines of code, it's just setting the Animator parameters which are called that. They are set with the _remappedX and _remappedZ calculated just before

    The move variable before that is taken from the ECM2 ThirdPersonController directly
     
  39. VR_Junkie

    VR_Junkie

    Joined:
    Nov 26, 2016
    Posts:
    45
    Sorry I asked a question I didn't mean to ask (tired from coding haha). I meant to ask how can I get this to work after I rotate. It returns the correct values when facing global forward but when I rotate my character the values don't adjust. (i.e. when I look to my right and go straight the RemappedLateralSpeed parameter becomes 1 but it should be the RemappedForwardSpeed that becomes 1)
     
  40. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    467
    It needs to be used with RotationMode set to none and that you set the character rotation yourself (in my case I'm rotating the Character to the weapon aim)

    If the rotation is set to be relative to the Camera or the Character I guess that might have an impact and will give you opposites
     
    VR_Junkie likes this.
  41. onefoxstudio

    onefoxstudio

    Joined:
    Sep 28, 2016
    Posts:
    96
    Just wondering out ... will you be adding very basic traversals like ledge grabbing ? I think I remember it was planned some time in the future; maybe the future is now ;)
     
    dock likes this.
  42. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    473
    I would like to see ledge grabbing.
     
  43. daveofthemeep

    daveofthemeep

    Joined:
    Apr 14, 2021
    Posts:
    5
    Hi-- great asset! This is great character movement package. Saved me tons of time on 'basic movement' to work on the peripheral functions specific to my game.

    Question regarding the included CharacterAnimator. I'm struggling a bit to implement several layers of 'fall states', from medium height land-to-roll, to high up damage on landing, to low height just plain old landing.This is based currently on the y velocity value at a time close to impact.

    I've been mostly successful, in fact it works perfectly. I'm not confident in my method though. Here's my question:

    Is the 'Jump' value that's being passed into the CharacterAnimator:

    Code (CSharp):
    1. float verticalSpeed = Vector3.Dot(_character.GetVelocity(), _character.GetUpVector());
    2.                         animator.SetFloat(Jump, verticalSpeed, 0.3333f, Time.deltaTime);
    Combined with the velocity.y value a reliable way to determine vertical velocity at approximately the time of grounding?

    If I use the Grounded bool as my landing criteria, as soon as the player is grounded the y velocity is ~0 so it doesn't transition correctly. I tried using some variation of the built in WillLand method, that had the same issue.

    Odd to question something that's working, but not understanding completely how the value is calculated / used I'm afraid it could break further down the road.
     
  44. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    In short, yes, however :rolleyes: it will take some time to add extra mechanics examples as currently I am working on a two step major internal modification that I am pretty sure all of you would like.

    This is part of my goal to let ECM and ECM2 share a common 'CharacterController' (CharacterMovement component) so the main differences will be all the extra functionality ECM2 offers (a higher level layer) an ECM will remains as a lower level alternative to those who prefer a more-to-the-metal version but both with an equally capable character controller / motor.

    Regards,
    Krull
     
    Last edited: Oct 6, 2021
    onefoxstudio and RogDolos like this.
  45. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hello @daveofthemeep

    Yes you are correct, as internally it cancels the vertical velocity on landing, so when the event is triggered the velocity is already zeroed, so this needs to be fixed.

    In the mean time, using the fall damage as example, override the OnMove method, so you can cache a lastVelocity as follows:

    Code (csharp):
    1.  
    2. private Vector3 lastVelocity = Vector3.zero;
    3.  
    4. protected override void OnMove()
    5. {
    6.     lastVelocity = GetVelocity();
    7.  
    8.     base.OnMove();
    9. }
    10.  

    Later (e.g. in
    OnLanded) you can read the lastVelocity value to get a ~terminal velocity.

    regards,
    Krull
     
    daveofthemeep and RogDolos like this.
  46. VR_Junkie

    VR_Junkie

    Joined:
    Nov 26, 2016
    Posts:
    45
    Hello, I networked your controller but am having some slight issues. The gravity on the rigidbody turns off even if I turn it on in the prefab. Also frictionless gets placed into the collider as a physics material even if I delete from the prefab. The reason I am making these adjustments is because when networked the rigidbody velocity doesn't stop for clients that aren't owned by you. Is there a method you would advise for networked movement (keep in mind I have ThirdPersonCharacter.cs only on for the client but CharacterMovement.cs is on for everyone)? Or can you tell me what script changes the previous mentioned variables.
     
  47. daveofthemeep

    daveofthemeep

    Joined:
    Apr 14, 2021
    Posts:
    5
    What a simple solution, it works perfectly. Allowed me to eliminate a few bloating animation events, bools and floats. Much appreciated!
     
    Krull likes this.
  48. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Hi @VR_Junkie,

    Well the Rigidbody must have its gravity turned off as it is managed by the CharacterMovement, this also makes sure your capsule collider has a friction-less material.

    For example the CharacterMovement on its Snippet OnAwake method initializes the Rigidbody, collider and any other data used by the class. However as commented this settings are needed for correctly operation, additionally the Character velocity is the CharacterMovement velocity not the rigidbody velocity as in ECM2 the rb is used as a 'transport' basically to move physically move the character to its computed destination.

    Regards,
    Krull
     
    RogDolos likes this.
  49. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    473
    unity-ecm-jump.gif

    I'm implementing ECM2 right now and I'm running into the same problems from 15 months ago with ECM1.The character hits the ledge with a very unsatisfying capsule bottom behaviour and bounces backwards. This is specific to a near-miss jump. @Krull at the time you said there were some things about ECM2 that might make it better. Is there anything you can recommend? The only solution I can think of is to have horrible 45 degree platform edges.

    To clarify, I'm not asking for ledge grabbing or anything sophisticated, just a cylinder/cube type behaviour when airborne.

    ecm2-bounceback.gif

    I made a new GIF which highlights the problem. The character lurches foward and is then shoved backwards.
     
    Last edited: Oct 12, 2021
  50. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    366
    Well, that's inherent to how a capsule volume works, as in your GIF the bottom sphere of the capsule is colliding and depending on your perchOffset (eg: 0.5f) it will perch or slide down.

    What I refer about ECM2, is it exposes the full collision response projection so you can implement a kind of friction and custom projections to handle how resolve a collision (static or dynamic), while with ECM1 the projections are fully managed by PhysX and basically just a Vector3.ProjectOnPlane.

    In your case, the only real alternative to your desired behavior is to use a box based character controller, however this raises another kind of issue and unfortunately is not supported by ECM or ECM2.

    You and me ;), unfortunately only available on new Unity Physics through DOTS.
     
unityunity