Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] Easy Character Movement

Discussion in 'Assets and Asset Store' started by Krull, Apr 21, 2016.

  1. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hello,

    A new updated version for Easy Character Movement has gone live! The version 1.7 among other features adds support for crouching behavior, Pause / Resume character physical interactions, 2D Example, FPS Headbob example, etc.

    Asset Store Link
    Updated Documentation

    Here I attach the list of full changes:

    *** PLEASE BACKUP BEFORE UPDATE.

    - Added crouch support.

    - Added SetCapsuleDimensions method to CharacterMovement component. This make easy to modify capsule dimensions at run-time (eg: scale, crouch, etc).

    - Slightly modified FPS Camera hierarchy, added Camera_Pivot, and Camera is now child of this Camera_Pivot. This allows to perform camera animation easily. The HeadBob example make use of this Camera_Pivot to animate camera.

    - Added FPS HeadBob example. This shows how to perform headbob animation.

    - Added 2D Example. This shows how configure an ECM character for a typical 2D sidescroller.

    - BaseCharacterController Move method is now virtual.

    - BaseCharacterController Jump, MidAirJump and UpdateJumpTimer are now virtual, this allows to modify default jump mechanics.

    - Fixed a bug related to mid air jump. This caused the character to get stuck if mid air jump occurs near ground.

    - Fixed a bug in MouseLook component when the smooth option is toggled. This caused the camera bypass the clamp settings.

    - Updated documentation.


    Please don’t hesitate to post any questions, doubts or issues on the package. I’ll be happy to help you.
    - Krull


    ----------------------------------------------------------------------------------------------------------------------


    Hello, I am really happy to share with you this new MAJOR UPDATE (v1.6) for Easy Character Movement ,this has been submitted to store so should be available in a few days.

    In this new version (v1.6) I have completely reworked the ground detection component, adding support for a set of new great features, such as support for steps, the character can walk (if desired) on any surface up to 89 degrees; flat-base capsule bottom, Configurable ledge offset, Ground-snap, You can now query at any time the character's distance to the ground plus additional grounding info, and many more!

    In fact, this is the biggest update to Easy Character Movement ever! so expect some braking change, so please backup before update.

    Worth note that I have tried to minimize the upgrade process, as result of this all you must do to update your characters to v1.6 is replace your character's SphereGroundDetection component (which has been deprecated) with the new feature-rich GroundDetection component, and configure its new features.

    If you have any question please feel free to post it here or message me to support email, Ill be happy to help you :)

    Asset Store Link
    Updated Documentation

    Demos







    Here I attach the list of full changes:

    CHANGE LOG

    Version 1.6

    *** MAJOR UPDATE, BREAKING CHANGES. PLEASE BACKUP BEFORE UPDATE.

    - Added support for steps and completely improved ground detection / character movement components. Eg: The character can now walk (if desired) on any surface up to 89 degrees.

    - Replaced the ground detection component. The new implementation (BaseGroundDetection / GroundDetection) is a much more robust and feature-rich component, capable of detect, report and query multiple grounding cases.

    - The abstract class GroundDetection has been renamed to BaseGroundDetection.

    - The previous SphereGroundDetection, BoxGroundDetection and RaycastGroundDetection has been replaced with a new feature-rich GroundDetection component and marked as obsolete. This obsolete components will be removed in a following update.

    - The new GroundDetection component, automatically configures from your character's capsule collider.

    - Improved ledge handling, the new GroundDetection allow to configure a desired ledge offset, this set how close / far a character can stand on a ledge without fall down.

    - Implemented flat-base feature. When on a ledge, the CharacterMovement component will treat the bottom of your capsule as flat instead of rounded. This avoids the situation where characters slowly lower off the side of a ledge (as their capsule 'balances' on the edge).

    - Implemented ground-snap feature. This help to maintain the character on ground no matter how fast it is running and not launch of ramps.

    - As part of the new ground-snap feature, the platform support is much more stable on moving platforms, the character will maintain the platform no matter how fast it moves, or its friction settings.

    - CharacterMovement now correctly apply platform angular velocity when on rotating platforms. Exposed platformAngular velocity property.

    - Added new methods (ComputeGroundHit) to allow query 'ground' info at any time.

    - Implemented continuous collision detection, this greatly improve the character landing, no matter how fast the character is falling, it will always land safely.

    - Refactored all BaseCharacterController private fields to protected. This allow derived classes access them an implement custom jump logic, etc.

    - Added a new method UpdateRotation to BaseCharacterController, this helps to easily modify the default ecm rotation method (rotate towards movement direction).

    - New gizmos, GroundDetection now show if character is on a step, on a ledge 'solid' side, on a ledge 'empty' side, on valid ground, on invalid ground, and not on ground. Please reffer to documentation for a fully description.

    - Removed OnCollisionXXX events dependency.

    - Minor Bug Fixes.

    - Code refactored and cleaned comments and tooltips fixes.



    MINOR UPDATE (v1.5)

    - Unity 2017 support

    - MouseLook class can be extended, just like other Base controllers.

    - Minor bugs fixes.


    MAJOR UPDATE,
    the whole package has been refactored and restructured to be much more organized and easier to work with.

    NEW! Greatly improved physics behavior model.

    NEW! More robust BaseCharacterControllerfeaturing friction based movement, unlimited mid-air jumps, a stronger root-motion support, and more!

    NEW! AgentCharacterController, base controller for NavMeshAgent based characters.

    NEW! BaseFirstPersonController, base controller for classic FPS control.

    NEW! The whole package has been refactored and restructured to be much more organized and easier to work with.

    NEW! Examples and more!

    - Major update, the whole package has been refactored and restructured to be much more organized and easier to work with.

    Easy Character Movement is a powerful yet incredible easy to use Physics-based character controller, designed for vertically-oriented characters.

    Easy Character Movement can be used for any character, from NPCs to Enemies, to Players, and for a wide range of games like, platformers, first person, third person, adventure, point and click, and more!

    If you looking for an easy, efficient and flexible character controller for your next project, please let Easy Character Movement be there for you.


    Features

    • Rigidbody-based character controller.
    • Support for Capsule and Box-based character colliders.
    • Move and Rotate on dynamic platforms.
    • Stay still on slopes.
    • Keep same speed on straight and slopes.
    • Slide on steep slopes.
    • Orient to ground slopes.
    • Supports Nav Mesh Agents.
    • Supports root-motion.
    • Easy integration into existing projects.
    • Fully commented C# source code. Clear, readable and easy to modify.
    • Mobile friendly.
    • Garbage-Collector friendly.
    • and more!

    Getting Started Guide



    Demo



    Please don’t hesitate to post any questions, doubts or issues on the package. I’ll be happy to help you.
     
    Last edited: Sep 24, 2019
    makaka-org and carking1996 like this.
  2. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Easy Character Movement

    v1.1 Update (Jun 01, 2016):


    - Fixed a minor bug related to demo scene lightmap size.
    - Added a simple demos scene, to faster start.
    - Exposed all ground info from movement component.
    - Improved character braking, braking is composed of friction (velocity-dependent drag) and constant deceleration.

    Regards,
    Oscar
     
  3. 2dgame

    2dgame

    Joined:
    Nov 24, 2014
    Posts:
    83
    Hi Krull,
    when standing near an edge with a base controller or an fps controller the character gets slowly pulled back onto the ground. I assume this is intentional to prevent falling off the edge. I don't want this behaviour though. I don't see any option for this nor do I see anything in the documentation about this.
    Can you tell me how to prevent this behaviour?

    Thanks!
     
  4. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hello 2dgame,

    Thats right, it happen with the SphereGroundDetection component and is caused by the way Unity's SphereCast returns the hit normal, when a edge is detected, the hit.normal that is returned is the interpolation of the two normals of the faces that are joined to that edge.

    You can minimize it reducing the SphereGroundDetection radius and check if is enough for yourgame, worth note that even Super Mario Galaxy present a "similar" behavior when on edges.

    Another fast solution is to REPLACE the SphereGroundDetection component with the included BoxGroundDetection which internally use a BoxCast, this approach should give you the best results, more if your game is 2D.

    Another simple solution, is to create a custom ground detection component extending the base GroundDetection, using a raycast instead of a sphere or a box, thats the beauty of Easy Character Movement, it allows you to extend the system to fit your game needs no the other way ;).

    If you interested in this custom ground detection, please email me to support email, Ill be happy to sent it to you.

    Hope this helps you,
    Krull
     
  5. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Easy Character Movement

    Version 1.2


    - Added a jump tolerance time property to base character controller.
    This helps to manage how early before hitting the ground you can press jump, and still perform the jump.

    - Added a new Raycast ground detection component.

    - Added a CustomCharacterController example.
    This shows how to create a custom character controller to perform the movement relative to camera.

    - Fixed a minor bug where some of the controllers were not applying braking drag.

    Regards,
    Oscar
     
  6. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Black Friday 2016 Deals Are Here!

    ==================================
    40% OFF SALE! (Regular Price: $25)
    ==================================

    Until Tuesday!
     
  7. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    284
    Really enjoying using this awesome asset :)

    Had a question about freezing the player- I need to have the player freeze(disable player input and not move/rotate) in place so it can interact with a computer terminal and things like that- what is the proper way to do that with this asset?

    Right now I'm disabling the CharacterController script, then making the RigidBody kinematic- this works in almost all cases except when playing my characters fall down animation when falling from high places- the player will fall through the floor some times-

    Right now I'm just doing this to "freeze" the player

    "script" is PlayerCharacterController"
    "rb" is the RigidBody

    script.enabled = false;
    rb.isKinematic = true;

    I'm switching it back on like this

    script.enabled = true;
    rb.isKinematic = false;

    What is the proper way to do this? Should I set the CharacterMovement velocity to Vector3.Zero when freezing it as well? Thanks!
     
  8. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hello mdotstrange,

    First of all thank you for choosing ECM!

    Now about your questions, your pause method seems right, however I suggest to save and restore the rigidbody velocities too.

    Here I attach you a function to properly pause / unpause a rigidbody:

    Code (csharp):
    1.  
    2. private Vector3 _savedVelocity;
    3. private Vector3 _savedAngularVelocity;
    4.  
    5. private void OnPause(bool paused)
    6. {
    7.     if (paused)
    8.     {
    9.         // Save rigidbody state, and make it kinematic
    10.  
    11.         var rb = GetComponent<Rigidbody>();
    12.  
    13.         _savedVelocity = rb.velocity;
    14.         _savedAngularVelocity = rb.angularVelocity;
    15.  
    16.         rb.isKinematic = true;
    17.     }
    18.     else
    19.     {
    20.         // Restore saved rigidbody state
    21.  
    22.         var rb = GetComponent<Rigidbody>();
    23.  
    24.         rb.isKinematic = false;
    25.  
    26.         rb.AddForce(_savedVelocity, ForceMode.VelocityChange);
    27.         rb.AddTorque(_savedAngularVelocity, ForceMode.VelocityChange);
    28.         rb.WakeUp();
    29.     }
    30. }
    31.  
    Now regarding your issue with the player passing through the floor, it seem to be a problem with physics collision detection where sometimes when the speed of an object is too high (in this case as a result of a force added to the rigid body) the collision won't be detected,

    Possible solutions:

    You can limit the character fall speed adjusting the Max Fall Speed property of the CharacterMovement component to effectively limit the character falling speed.

    Also please, make sure that your Rigidbody has "Is Kinamatic" == False and more important its collider is not a Trigger ("Is Trigger" == false).

    Another possible solution is to adjust your Fixed Timestep, the unity's default value (0.02) or even (0.033333) should be enough.

    Hope this helps you.

    Best regards,
    Oscar
     
    imaginationrabbit likes this.
  9. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    284
    Thank you so much for the detailed explanation and the code snippet! I used your function and lowered the max fall speed as you recommended and now it is working properly- thank you:)

    This really is a great asset! If anyone reading this is thinking about buying it, do it! Its great!
     
  10. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Excellent! glad I was able to help you.

    Thank you for your comments, and remember if need further assistance, please do no hesitate in message me, or post here ;)

    Regards,
    Oscar
     
    imaginationrabbit likes this.
  11. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    284
    Hello again!

    How would you recommend I approach limiting the +Y speed of the player? Something like a MaxRisingSpeed? Here's my situation...

    The player uses grenades which use an explosive force that does not affect the player but affects physics objects in the scene which the player can interact with- if the player is standing on one of the physics objects when the explosion force is applied to the object- the player is thrown really high into the air/sometimes out of the level-

    The only solution I can think of is to limit the +Y speed of the player- like the opposite of the MaxFallSpeed on the CharacterMovement script but I don't want to interfere with jumping- would you recommend this or is there a better way?

    Thank you :)
     
  12. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hi M!

    Mmm, before modify the CharacterMovement component, I would like to try adding some drag to the rigidbody, a low value of 0.1 could help, and not interfere with your jump / movement.

    Another possible solution is, to apply a drag using the CharacterMovement ApplyDrag function for some amount of time after the character is reached by the explosion (a coroutine could help here), just make sure you set its variable (onlyXZ == false) so the drag affects the vertical velocity component too; however this method requires a little more 'housekeeping'.

    For last Here attach you a function to replace the CharacterMovement component's LimitFallSpeed function, this as you comment use a MaxRisingSpeed to limit the rising velocity, just make sure its value is higher than your initial jump velocity or indeed, it will interfere with your jump.

    Code (csharp):
    1.  
    2. public float MaxRisingSpeed = 15.0f;
    3.  
    4. private void LimitVerticalVelocity()
    5. {
    6.     if (_groundDetection.isGrounded)
    7.         return;
    8.  
    9.     var verticalVelocity = velocity.y;
    10.     if (verticalVelocity < -maxFallSpeed)
    11.     {
    12.         var verticalVelocityChange = -maxFallSpeed - verticalVelocity;
    13.         _rigidbody.AddForce(0.0f, verticalVelocityChange, 0.0f, ForceMode.VelocityChange);
    14.     }
    15.     else if (verticalVelocity > MaxRisingSpeed)
    16.     {
    17.         var verticalVelocityChange = MaxRisingSpeed - verticalVelocity;
    18.         _rigidbody.AddForce(0.0f, verticalVelocityChange, 0.0f, ForceMode.VelocityChange);
    19.     }
    20. }
    21.  
    Please let me know which method work the best, because if needed I will add the LimitVerticalVelocity to the following ECM update.

    Hope this helps you, however if need further help, please do not hesitate to ask

    Best regards,
    Oscar
     
    imaginationrabbit likes this.
  13. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    284
    Adding drag didn't seem to affect the issue and I didn't try the ApplyDrag solution as I'm scared of using CoRoutines as I don't understand them yet :D

    I did use the LimitVerticalVelocity function you made and it fixed the issue perfectly :) Thank you so much and I do think it would be a good feature for users too have.

    Thank you again!
     
  14. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Excellent!, glad the LimitVerticalVelocity function worked for you, and yes it will be a good feature to add to the following ECM update, thanks! :)

    Regards,
    Oscar
     
    imaginationrabbit likes this.
  15. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Just a little note for everyone else who is wondering if the character is sliding through the whole map without any interaction. If your character wears a weapon on his back which contains an collider + rigidbody it will interfere with the characters capsule collider.

    @Krull So far your character controller is working great, thank you.
     
    Last edited: May 9, 2017
  16. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    What I'm struggling at the moment is too keep the character grounded when sprinting over ramps. It seems setting gravity to 100 works fine, but well, jumping doesn't work with such a strong gravity. Any ideas?
     
  17. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hello Silentneedle,

    First of all, thank you for your purchase of ECM!

    Now regarding your issues, about the weapon + rigidbody, thank you for sharing your solution about it, and yes, Unity advise about not parenting a non-kinematic rigidbody to other non-kinematic rigidbody, thats why the strange behaviour occurs as you pointed.

    For all interested, here can read more about it.

    Now about the ramp issue, you are right, thats a side effect of being a rigidbody based character, in current version, you can try tweak the ground detection distance a bit, trying to reduce the ground loosing, by other hand I do not recommend setting such high gravity, however if you would like a strong gravity, please set the extra jump power to the same gravity value, this will makes the jump work better.

    Last but not least, I am happy to share with you, that I am about to release a major update to the system (hopefully this week) wich among many fetures, it introduce a NEW physical model behaviour wich solve this 'ramp' issue plus the use of friction (drag and grip) values, allowing a much more tight and responsive controls, even with low acceleration values, so please bear with me, I am sure you will like this new update :)

    If need further assistance, please let me know it, ill be happy to help you.

    Regards,
    Oscar
     
    silentneedle likes this.
  18. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Awesome, then I'll wait for the update. Thanks for the fast reply. :)
     
  19. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    I'm almost done with replacing unity's character controller with yours, it was easier than I thought.

    I still have a question.

    Currently I'm rotating our character with the Rotate function from CharacterMovement inside FixedUpdate, which is working fine:

    Code (CSharp):
    1. characterMovement.Rotate(transform.right * horizontalInput, rotatingSpeed * 100);
    Usually our camera follows the characters back, but when holding the left mouse button the camera will hold it's current rotation, it's a typical mmo style camera behaviour. What we're doing now is to subtract the rotation of the character from the cameras X position, which should result the camera not following the characters back anymore:

    Code (CSharp):
    1. horizontalInput * rotatingSpeed * 100.0f * Time.deltaTime
    But the camera is jittering and doesn't hold it's rotation.

    So my question is how would you counter the character's rotation so that the camera stays in place in LateUpdate?
     
  20. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    First of all, sorry for late response, but currently I am out of town.

    Now regarding your issues, I suggest you rotate the character, in the update, instead of the FixedUpdate, this is the approach I use in all demos, and the correct way in order to avoid any jittering. However worth note that the Rotate method will rotate the character towards the given direction.

    Mmm, sorry but I dont really understand your camera issue, do you want the camera stay on character' back? If you could I appreciate if could post your camera code, or if you preffer email me to the support email, in order to fully help you.

    Best,
    Oscar
     
  21. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Easy Character Movement

    Version 1.4


    MAJOR UPDATE, the whole package has been refactored and restructured to be much more organized and easier to work with.

    NEW! Greatly improved physics behavior model.

    NEW! More robust BaseCharacterControllerfeaturing friction based movement, unlimited mid-air jumps, a stronger root-motion support, and more!

    NEW! AgentCharacterController, base controller for NavMeshAgent based characters.

    NEW! BaseFirstPersonController, base controller for classic FPS control.

    NEW! The whole package has been refactored and restructured to be much more organized and easier to work with.

    NEW! Examples and more!

    - Improved and more extensive documentation.

    - Removed the use / requirement of Resources folder.

    - Revised / optimized code, and improved in-code comments and tooltips.

    Regards,
    Oscar
     
    silentneedle likes this.
  22. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,178
    Hi! I just bought the package and am having trouble with terrains. I seem to go up and down my 45 degree slopes just fine, stopping on them and all. But when I go onto terrain even at 30 degrees or so I slide all over the place. The character won't go straight forward either, zig zagging across the lumps in the terrain. Am I missing something?

    I've got the sphere ground detection, character movement, and custom controller scripts attached.

    Thanks.

    oops! It was my ground mask, ignoring the terrain, nevermind!
     
    Last edited: Jun 6, 2017
    Createman likes this.
  23. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hello malkere,

    Excellent! Glad you was able to fixed it, however if need any further assistance, do not hesitate to message me.

    Regards,
    Oscar
     
    malkere likes this.
  24. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Hey Krull,

    thanks for the update, but I receive the following error after the import of your asset:

    It's because I have the MouseLook class from the standard assets imported.

    Changing it to ECM.Components.MouseLook at line 50 and 214 fixes the problem.
     
  25. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hey Silent,

    Thanks for the fix! Ill add it to the following update.

    Regards!
     
  26. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Hey Krull,

    I'm almost done with the implementation of ECM. I still have a problem when it comes to slopes, especially steep slopes. Currently, it's possible to climb them up by jumping over and over again, it's also possible to slide over by run + jump on them. Is this maybe fixable by tuning the friction values?

    My current fix is to disallow jumping when the character is sliding, but this also disallows jumping when sliding down a slope, which I want to permit.
     
  27. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hello Silent,

    The CharacterMovement component, offer the option to set a slope limit (slopeLimit), this is the angle (in degrees) of a 'valid' slope, or in other words, a walkable slope (no slide). This component also control how fast or slow the character will slide off 'invalid' slopes (slideGravityMultiplier). You can try to tweak this properties to your needs.

    By other hand, if the above do not work, the best way to fully prevent this behavior, is as you suggest, disable the jump, BUT only when character is on a 'invalid' slope (angle higher than slopeLimit), to do this please add the following code to the BaseCharacterController component:

    In the Jump method, replace the following code (located at line 449)

    Code (csharp):
    1. // If not grounded, return
    2. if (!movement.isGrounded)
    3.     return;
    with the following one:

    Code (csharp):
    1. // If not grounded, OR not valid slope, return
    2. if (!movement.isGrounded || !movement.isValidSlope)
    3.     return;
    This will prevent to jump, but only on invalid slopes, and make sure the character slides down on steep slopes as should.

    Please be in touch if you need further assistance.

    Take care,
    Krull
     
    silentneedle likes this.
  28. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Yes, that's what I've tried. But it doesn't seem to help. I think the major problem is when jumping/sliding up a slope the sphere ground detection turns red until the character slides down, no matter how big the radius of the sphere is.
     
  29. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    To recap, you want to prevent a character to climb steep slopes, right? As I commented the general approach is force the character to slide down off the steep slope, and ECM offer this feature, however as I understand, you want to prevent the character climb steep slopes, but at same time allow the character to jump on steep slopes? I am afraid there's no easy solution for this, not a ECM fault, but a very specific game problem.

    However, you can follow what Mario 64 does, when Mario is on a steep slope, mario is LOCKED in a slide animation, and he can't do any but slide down, just as you commented, this disable the jump and force the character to slide down off steep slope.

    Another solution to prevent your character to climb steep slopes without disable the jump, is use an 'invisible wall' in your collision geometry (another widely platform games solution), this way you can limit the height your character can climb the steep slope and still can jump while he is sliding down.

    Regards,
    Krull
     
  30. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    I see, well then I'll just prevent jumping when sliding is active like you've described in your last post, thanks for clearing this up.

    Now to my other problem, I've made a little video which shows the problem:

    https://streamable.com/xaj9k

    Here are the settings used in the video: http://imgur.com/a/QZiXZ

    The problem I see here is that there doesn't seem to be any friction handling when sliding up a slope, especially when doing a runjump. Modifying the ground friction doesn't seem to help, and the slide gravity multiplier only seems to affect downsliding.

    Any idea how I could limit the speed/amount when sliding up?
     
  31. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hi Silent!

    Thank you for the video and the settings, finally I was able to reproduce the issue. This effectively is a bug in the Jump method, that's why you noted the RED ground sphere, no matter how big you set it.

    To fix this, please add the following code to the BaseCharacterController:
    Code (csharp):
    1.  
    2. private void OnCollisionStay(Collision collisionInfo)
    3. {
    4.     // If ground detection is enabled, return
    5.  
    6.     if (movement.detectGround)
    7.         return;
    8.  
    9.     // If ground detection is diabled (eg: Jumping), and we have a collision...
    10.  
    11.     // Check if the surface is a valid slope, if not, re-enable ground detection
    12.     // This will fix the sliding bug.
    13.  
    14.     var slopeAngle = Vector3.Angle(Vector3.up, collisionInfo.contacts[0].normal);
    15.     if (slopeAngle > movement.slopeLimit)
    16.         movement.detectGround = true;
    17. }
    18.  
    Please let me know if this helps you, so I could add it to the following update.

    Regards,
    Krull
     
    silentneedle likes this.
  32. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Thanks Krull, that works! There is still a small bug, but I'm not sure if it's easy to fix. If you stand directly in front of an object (e.g. a cube) it's not possible to jump.
     
  33. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Excellent! I will need to generate a more robust function to solve this issue once at home. Because it need to perform a further tests and make sure the collision is 'ground' (eg: insde characters 'ground' detection area).

    Thank you for your patience an understanding,
    Krull
     
    silentneedle likes this.
  34. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    As promised, here I attach the new function. ***Please remove the previous function from BaseCharacterController

    Please, add the following code to CharacterMovement component:

    Code (csharp):
    1. private void OnCollisionStay()
    2. {
    3.     // If ground detection is enabled, return
    4.  
    5.     if (detectGround)
    6.         return;
    7.  
    8.     // If ground detection is diabled (eg: Jumping), and we have a collision...
    9.  
    10.     // Allow and perform our regular ground detection
    11.  
    12.     detectGround = true;
    13.     GroundCheck();
    14.  
    15.     // If we got no ground collision, or NOT in a invalid slope, let ground detection off,
    16.     // BaseCharacterController Jump method, will handle the ground detection on / off.
    17.  
    18.     if (!isGrounded || !isValidSlope)
    19.         detectGround = false;
    20. }
    For the record, this 'fix' is needed because the way ECM handle slopes jump, It first disables ground detection during a jump, and once the character is falling (eg: its vertical velocity is negative), it re-enable ground detection, and approach which in 'most' cases works great, however in your case, you are moving your character really fast, and the Jump was not able to re-activate ground detection, because the character hit a steep slope, so its vertical velocity never was negative (eg: not falling), that's why you noted the red sphere on ECM character.

    Of course, this is an approach to handle it, another method, is to handle the jump different when on a steep slope, instead of apply a vertical impulse, apply an impulse perpendicular to the slope, that way you don't have to disable / enable ground detection, because the jump will slightly push the character off the slope.

    I really suggest the following post, which explain it really well, and talk about different approaches.

    Hope this helps you, however please be in touch if you need further assistance.

    Take care,
    Krull
     
    silentneedle likes this.
  35. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Thanks again Krull, it looks like it works without any side-effects now. :)

    I'll report back if I find any bug.

    p.s. That linked post was a nice read.
     
  36. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    You are more than welcome, I'm glad I was able to help.

    Best regards,
    Krull
     
  37. mookfasa

    mookfasa

    Joined:
    Dec 21, 2016
    Posts:
    18
    Just got this yesterday and I love. I plan on adding these myself for now but two things that I would love to see incorporated. Anti bunny hop, have the option to delay time between jump and the ability to crouch. Otherwise the is a great controller, perfect for doing what I want to do.

    Another question is the private void OnCollisionStay() script you posted incorporated to the newest version or would I need to add that in?

    Cheers
     
  38. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hi Mookfasa,

    First of all many thanks for your purchase and your kind comments, I’m glad you liked it!

    Now regarding your questions:
    The base controller already offers a property jumpToleranceTime, to delay the jump, plus you also can limit the character max movement speed (in CharacterMovement component) to effectively limit the character movement.

    That's actually a great addition, and surely will add it in following updates!

    It is not included in the current version (1.4) I will add it to the upcoming 1.5 update. Actually this fix is only needed if your character moves at really high speeds, however it is SAFE to add it, so feel free to add it until the 1.5 is released.

    Please be in touch if you need any help.

    Regards,
    Krull
     
  39. mookfasa

    mookfasa

    Joined:
    Dec 21, 2016
    Posts:
    18

    Seem like the jumpToleranceTime isnt really working. I am still able to spam the jump button over and over again. Correct me if I am wrong but it looks like the script is calculating how long I am holding the jump button down and not the last time it was pressed.
     
  40. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Let me clarify how the jumpToleranceTime property works, It prevents 'jump chaining'.

    To register a new jump, the player first must release the jump button, so if he keeps pressing the jump button, ECM will only process the first jump. To make a second jump, the player must release the button and press it again, and here is where jumpToleranceTime comes to play, it checks if the new jump press should be processed or not based on this jumpToleranceTime.

    In other words, as the docs says:
    Its somewhat difficult to put in words, but try the following example:

    Set jumpToleranceTime to 1, Make a jump, and while still in air, release the jump button and immediately press and hold the jump button again, as soon as the player touch the ground, it will will jump again, because the jump tolerance time is high.

    Now set jumpToleranceTime to 0.05 and repeat the test. Make a jump, and while still in air, release the jump button and immediately press and hold the jump button again, now the player won't jump.

    Worth not that a jumpToleranceTime == 0, will disable jump completely.

    Hope this helps you,
    Krull
     
  41. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,178
    I've got a strange bug cropping up.. And only in Build, works fine in the editor?? I'm using a simple mesh collider on my wooden stairs which are an L shaped stair platform stair sort of structure. Has worked fine until now, but now the lower part of the stairs seems to make the player slide as if the collider is pushing it properly but the easy character controller is not seeing it. I even cranked slope allowance up to 80 and it didn't fix it. Strangely the upper part of the stairs still works fine, which is a true 45 degree angle. The lower half is a little steeper something like 50. But the player plays the fall animation like it can't see it at all, though doesn't slide through it, slides down it...??

    It's a single mesh.

    add: I uploaded this mesh. the normals are correct, etc... I don't get it...
     

    Attached Files:

    Last edited: Sep 10, 2017
  42. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hello Malkere,

    I was able to track down the bug, to fix it, please add the following line to the CharacterMovement component:

    replace following code (at line 66):

    Code (csharp):
    1. private float _slopeVerticalLimit = 0.71f;
    with the following one:

    Code (csharp):
    1. [HideInInspector, SerializeField]
    2. private float _slopeVerticalLimit = 0.71f;
    The reason of this bug, is because it is a calculated field, however this value was only calculated in the 'OnValidate' method, which is only called in Editor, that's why it worked in editor, while in release it was set to its default value 45 degrees.

    I will add the fix to the 1.5 update, which I expect to submit to store this next week.

    Regards,
    Krull
     
  43. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,178
    Awesome response Krull. Thank you. Will plug it in when I get home.

    edit: That looks like it fixed it. Thanks again =]
     
    Last edited: Sep 11, 2017
  44. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Excellent!, glad I was able to help you. Please, do not hesitate to contact me if need further assistance.

    Regards,
    Krull
     
    malkere likes this.
  45. PartyBoat

    PartyBoat

    Joined:
    Oct 21, 2012
    Posts:
    94
    Hey Krull, I just purchased Easy Character Movement and I wanted to say how impressed I have been with the asset so far. I'd been working on my own character controller based movement system for so long that I simply got fed up. I've had only bad experiences in the past with other character controllers on the marketplace so I was hesitant to buy anything again.

    Luckily so far it has been working great and the added ability to interact with the physics system due to the character being a ridigbody has been a nice plus. I wish I had gone with this from the start instead of wasting time with my own implementation.

    I suppose if there is one area the system needs improvement it would be in the ability to step over small objects. I think adding the ability to step up stairs is a waste of time personally, as a good level designer would always put a ramp collider on top of a staircase to make movement perfectly smooth. However, the ability to easily step over small obstacles on the ground like small rocks, curbs, items, and other things that a player assumes they could walk over would be nice functionality to have. Currently it is all too easy for the player to accidentally get stuck on these types of things which is never good for gameplay feel.

    Anyways, great job on the asset and I hope to see it continue to improve!
     
  46. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hello PartyBoat!

    Thank you very much for your kind words about ECM, I am glad you liked it!

    Now regarding your suggestion about the small objects, yes I am aware this and is something I definitely will add to it, however at the moment the only way to overcome this situation is using root motion.

    I have been performing some test to add a overall solution, but I am not 100% satisfied with some aspects of it, however if you would like to try the current implementation, feel free to message me at support email, I'll be happy to share with you the code, the downside of this method, is it disable the 'slide on steep slopes' feature.

    Once again, thank you for your support, and please do not hesitate to contact me if need any
    assistance.

    Regards,
    Krull
     
  47. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,178
    I get stuck on simple colliders I can't figure out I thought I'd ask here. I just made a new object with only has a capsule collider, my ECM equipped player is a capsule, the new objects has a 0, 0 friction physics material on it, but if I touch it I get stuck to it until I jump away. Something to do with ECM collision detection? Seems a problem a lot of people outside of ECM run into anyway...
     
  48. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hello Malkere,

    Thats strange, I havent seen this behaviour on my tests or reported by other ECM users, does it happen in the demo scene? or with a newly created ECM Character? Also which unity version are you using? I appreciate if could share a little more info regarding this issue.

    By other hand, the Frictionless material should be on the ECM collider (as created by default) plus make sure your 'other' object if is a 'walkable' is in the ECM's ground layer mask.

    I look forward to your reply,
    Krull
     
  49. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,178
    I'm not at home right now, but it's actually objects and walls that I get stuck on, not the ground. I am using the first release of 2017, but it was happening before that. I'm also using a custom character with some added script for swimming and things, nothing heavy. I will check things when I get home.

    edit: works fine in a fresh project... there's really no easy way for me to check it in my project though I've altered the scripts too much =[ I'm using Unity 2017.1.0f3 .... will take a closer look at the scripts, run some checks... frictionless is on both objects

    edit2: lowering the sphere ground detection from 0.45 to 0.3 fixed it?? =]
     
    Last edited: Oct 16, 2017
  50. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    206
    Hello Malkere,

    That's great, i'm glad it worked out for you!

    Just for the record, another cause of the character getting stuck is a 'nested' collider without the frictionless physics material on it, so If your ECM character has another collider, please make sure it also has the frictionless physic material on it.

    Take care,
    Krull
     
unityunity