[RELEASED] Easy Character Movement 2

Easy Character Movement 2

DESCRIPTION

Easy Character Movement 2 is a robust, feature-rich, highly customizable, general purpose (not game-genre tied) kinematic character controller.

ECM2 can be used for any kind of character (player or AI controlled) and for a wide range of games like, third person, first person, side-scroller, platformer, adventure, point and click, and more!

ECM2 thas been developed with extensibility in mind so you can rest assured it will serve you as a robust platform to build your game or add your unique game mechanics on top of it.

ECM2 includes over 40 examples, ranging from using the new input system custom actions, PlayerInput component, first person, third person, target lock, twin-sick movement, dash, slide, ladders, AI, Cinemachine, Bolt, and many more!

Extensive documentation, and fully commented readable source code included.

WHAT’S NEW?

The Character Movement component has been completely rewritten as a fully kinematic character controller and as a direct replacement for Unity’s Character Controller offering a similar workflow (Move function) but with many features and advantages over it.

A particularly important new feature is its new ground detection algorithm based on real surface normal, it supports all Unity’s primitive colliders (Box, Sphere, Capsule), Terrain Collider and Mesh Colliders (convex and non-convex).

First-Class transparent platforms support. The CharacterMovement component is able to transparently (without further steps needed by you) manage moving platforms, being dynamic rigidbodies, scripted, animated, etc.

Use Flat Base for Ground Checks. When enabled, it performs ground checks as if the character is using a shape with a flat base. This avoids the situation where characters slowly lower off the side of a ledge (as their capsule ‘balances’ on the edge).

Network friendly. Full control over its update and simulation timestep.

An many, many more new features!

INSTALLATION

ECM2 requires Unity’s New Input System and is recommended to install it before importing ECM2 into your project as this will ease the ECM2 import process.

ECM2 includes Cinemachine based examples, this are distributed as a zip file, so before unpack this, please make sure to install the Cinemachine package into your project.

ECM2 includes Bolt based examples, this are distributed as a zip file, so before unpack this, please make sure to install Bolt into your project.

VERSION 1.1.0

* W A R N I N G !

Starting with v1.1.0, ECM2 is now a fully kinematic character controller and as a such it present significative changes.

PLEASE BACKUP BEFORE UPDATE!

How to update ?

  • Its recomended to completeley remove the ECM2 folder from your unity project before import new package from store.

  • Once removed, import the package from asset store as regular.

  • Please refer to changes document for a detailed list of removed / deprecated files and data structures and its new counterparts.

FAQ
Do I have to use new input system?

No, while ECM2 uses Unity New Input system by default, you can completely ignore it an replace it with any other input system you prefer. ECM2 It include several examples of how to make use of old input system.

Can I use URP/HDRP with ECM2?

Yes, ECM2 doesn’t do any rendering, it’ll work with any render pipeline. The demos are made using the Standard Render Pipeline (built-in), as it’s still the only stable one, and the most common denominator, but you can use any RP you prefer.

FEATURES

  • Kinematic character controller.
  • Work the Unity’s way, simply call its Move method, just like Unity’ Character Controller.
  • Robust ground detection based on real surface normal.
  • Slope Limit Override lets you define walkable areas per-face or even per-object.
  • Configurable walkable area (perchOffset) lets you define the character’s ‘feet’ radius.
  • Capsule-based with Flat Base for Ground Checks option. This avoids the situation where characters slowly lower off the side of a ledge.
  • Ground constraint, prevent the character’s being launched off ramps.
  • Configurable Plane Constraint so movement along the locked axis is not possible.
  • Auto-stepping preserving character’s momentum (e.g. its stride).
  • User-defined gravity and up vector for mario galaxy like effects.
  • Physics interactions.
  • Character vs Character interactions.
  • First-class, transparent (without further steps needed by you) platforms support, be it animated, scripted, or physics based.
  • Collision and Grounding events.
  • Network friendly. Full control over the update and simulation timestep.
  • Flexible and customizable behavior through callbacks.
  • Fully configurable friction based movement including water buoyancy!
  • Uses Unity New Input System as its default input (but not limited to).
  • Different movement modes and states, like walking, falling, unlimited variable height jump, crouching, sprinting, flying, swimming, etc.
  • First person, Third person, Agent “base” characters.
  • Full control over how a character is affected (or not) by external forces, platform velocity, platform movement and / or rotation, push other rigidbodies and or characters.
  • Character actions events.
  • Extensive and configurable collision filtering.
  • Different template scenes (First person, Third person, Side scroller, Top down) for faster startup.
  • 40+ examples including custom input actions, cinemachine integration, first person, third person, character events, bouncers, fly, swim, dash, slide, ladders, and much more!
  • Developed with extensibility in mind, can be used as it is, extend one of its “base” characters or simply take control of them using controllers such as other scripts or visual scripting (e.g. Bolt).
  • Physics Volumes, to easily handle water, falling zones, etc. with configurable properties.
  • Root motion support.
  • Simple to use but complete API.
  • Easy integration into existing projects.
  • Fully commented C# source code. Clear, readable and easy to extend.
  • Garbage-Collector friendly, no GC allocations.

And much more!

ASSET STORE PAGE
Easy Character Movement 2

DOCS AND SUPPORT
User Manual
CharacterMovement User Manual
API Reference
Email

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

6 Likes

I’m a big fan of the first version, glad to see this asset evolving!

I think I asked the same question in the old thread, but I want to know (as I haven’t upgraded yet), how does the new version treats character to character collisions and pushing forces. In the old version the capsule checks when moving were necessary, so if a character was moving into other character, I’d reset the movement speed vector of the character so one character won’t push another. This makes the character to stop, and when you’re controlling that character, it doesn’t feel good when your input is being nullified. Is there a built–in algorythm that prevents pushing and just makes the moving character to slide over another character, does the mentioned Collide and Slide algorithm have something to do with it?

1 Like

Hi @my_little_kafka ,

Thank you!

In short yes, one of the big advantage of ECM2 over ECM, as previously stated, is the implementation of the Collide and Slide Algorithm, this is a form of continuous detection and response, basically it means that whenever our character collides with other collider (other character, rigidbody, a wall, ground, etc), instead of stopping our movement, we compute a sliding vector to let the character gracefully traverse the world solving future collision before it happens!

Actually the ECM2 implementation let you decide how to react to each of this contacts, the CharacterMovement is the responsible to perform all the geometric and collision related task, and in the end to physically move the character to its new computed position, while it let the Character to decide how the character should be moved (walking, running, falling, flying, etc), and how should react to contacts through the use of delegates, so in your custom controller (if needed) you can completely modify it as much as needed.

For example, when a collision between us (our character) and another character is detected, the CharacterMovement will call the Character’s OnApplyPushForce delegate, so you can use this function to take full control over how to solve this collision.

Actually ECM2 is somewhat an hybrid between a fully kinematic and a dynamic controller, where all the collision of Character vs others (e.g. character walks into a wall) is resolved by us, while the others collisions vs Character (Character is hit by a moving platform) is managed by PhysX (but can be omitted too if desired).

In the attached image, you can find the Character (replaces BaseCharacterController) properties you can use to decide how it should react to physical interactions, but as commented is not limited to, as all can be extended / replaced in your custom Character if desired or needed.

7116328--849403--Captura de pantalla (183).png

Mass
This character’s mass. Will set the Rigidbody’s mass.

Impart External Velocity
If true, impart the velocity caused by external forces during internal physics update.

Impart Platform Velocity
If true, impart the platform’s velocity when jumping or falling off it.

Impart Platform Movement
Whether the character moves with the moving platform it is standing on.

Impart Platform Rotation
Whether the character receives the changes in rotation of the platform it is standing on.

Apply Push Force
Should apply a push force to rigidbodies when walking into them?

Push Force Affect Characters
Should apply push force to characters when walking into them ?

Apply Standing Downward Force
Should apply a downward force to rigidbodies we stand on ?

Push Force Scale
Force applied to rigidbodies when walking into them (due to mass and relative velocity) is
scaled by this amount.

Standing Downward Force Scale
Force applied to rigidbodies we stand on (due to mass and gravity) is scaled by this amount.

All those properties can be toggled at run-time as needed.

Regards,
Krull

3 Likes

I was just checking up on the old thread to see if this released yet. Going to be upgrading as soon as possible. So many new examples, Character Events, Custom Gravity, I honestly can’t wait to try this out!

I’ve been working on a sorta Hack and Slash type game using the first one. It worked by using a mix of Root Motion and traditional movement for different animations. I used my own event system to switch between these 2 modes. Does that type of quick changing still work here?

Hi @Shiro_Rin

Sounds great! one my preferred game genre to be honest :slight_smile:

Absolutely, in ECM2 you can toggle root motion as desired, and it’s easier than ECM as in ECM2 all you have to do is set its useRootMotion property to enable or disable.

actually it includes an example showing how to toggle root motion while walking taking advantage of its new movements modes and its OnMovementModeChanged event, for example:

protected override void OnMovementModeChanged(MovementMode prevMovementMode, int prevCustomMode)
{
    // Call base method implementation

    base.OnMovementModeChanged(prevMovementMode, prevCustomMode);

    // Toggle root motion, allow when walking, otherwise, disable it

    useRootMotion = IsWalking();
}

Actually ECM2 is not just a better motor (analog to unity character controller) but also a high level layer on top of what ECM offers.

Having said that, please keep in mind that while it shares a lot with ECM, its basically a new product so unfortunately there is not a direct port between ECM BaseCharacterController to ECM2 Character classes.

Let me know if you need any further help.

Regards,
Krull

1 Like

I’m already loving it so far! Something I am having a bit of trouble with though.

I use a custom camera. I’ve noticed that without using the camera that comes with it, I get errors and my character won’t rotate properly. Is there a way around this without editing code?

I wanna add that editing out HandleCameraInput() from the update fixes my issue, just gonna add a bool to use camera input or not.

I did a couple more edits to fix the Cursor Lock as well. I made it its own script and reference it instead so I don’t have to reference the Original Camera Script at all.

Nice, happy to hear it!

Are you using the ThirdPersonCharacter? If so, worth note this has been developed to make use of its included ThirdPersonCameraController, however as all with ECM it can be extended as needed.

In you case since you are using a external camera with its own controller (I assume), you probably should use a Character, and simply assign your Camera to its camera property so it moves relative to it (e.g. Its Rotation Mode), after all the ThirdPersonCharacter is just extending a Character to control the ThirdPersonCameraController.

Let me know if you need any further help

-Krull

1 Like

Ahhh, that makes a bit more sense. I was basing everything off of the MyCharacter Script provided in the examples, so I followed and inherited from ThirdPersonController. I didn’t even think to just use Character instead. Thanks for the help!

1 Like

Yes, the Character is a full-feature highly customizable class, and the base for all your game avatars (player or AI controlled), however ECM2 already includes some Character derived classes, customized for different game-genres, like First Person, Third Person, Top Down (e.g. NavMeshAgent), etc. You can use any of these “base” characters as your parent class (e.g. Creating a derived Character class) or to be used by your Controller, but in the end all of those are just extending the “master” Character Class.

Take for example, the ThirdPersonCharacter, if you review the code, basically all it’s doing is extending a Character class and adding input related code to handle the ThirdPersonCamera or another third person example you can take a look is the Cinemachine based one.

I share personal tips about using Cinemachine for configure Character Controllers (With ECM2)

CM example(CMThirdPersonCharacter.cs) manages InputAction through Script.
(Initialization, binding etc…)

but Cinemachine can setting InputAction without Script
The way is simple.
Just add “Cinemachine Input Provider” and binding InputAction, setting related option to use.
It will be helpful if you refer to the reference document for detailed setup instructions and related information.

There is no correct answer to the method.
This is just a tip for users who configure character controllers using Cinemachine .

For the purpose of “ECM2 example,”
I think the content of CMThirdPersonCharacter.cs will be more appropriate.

2 Likes

There is parameters named “JumpLeg” in the “UnityCharacterController”
(ex ThiredPersonCharacter Example animator…)
It is used in Airborne Blend Tree

However, there is no script that uses that parameters
Of course, it has no effect on Blend tree’s behavior.

Hi @seoyeon222222

Thank you for sharing your tips, and sure will help me and others!

Hi :slight_smile: Just a question: Will I be able to use this controller for animal character? I’m thinking about rotation on uneven grounds like mountains. What do you think?

First off love the ECM2 having used ECM1 for a while now. Trying to learn the new input system I was wondering if there was a way to toggle sprint instead of having to hold it down?

Hi @asored ,

Well ECM and ECM2 are designed for vertical oriented characters (e.g. Humanoids) where it can be rotated as needed, e.g. Like Mario galaxy, but the bottom part of the capsule will always represent the character’s feet and the area designated to perform the ground detection.

So you can approximate your animal volume with the capsule an let it handle the locomotion, and use a more detailed collider hierarchy like hit boxes to say something. For example:

7127852--851549--dog_capsule.jpg

Here the yellow capsule will be your Character’s capsule and is the responsible to control all your movement, however in case you use additional collliders, make sure those do not collides with character’s capsule collider.

You can use the Character IgnoreCollision(Collider otherCollider, bool ignore = true) method to ignore additional colliders.

Regards,
Krull

1 Like

Hey @mookfasa ,

Happy to know you like ECM2!

About your question, absolutely, in your custom controller simply override the OnSprint InputAction Handler method and replace its implementation as follows:

// Overrides OnSprint InputAction Handler to handle toggle sprint

protected override void OnSprint(InputAction.CallbackContext context)
{
    if (context.started)
    {
        if (!IsSprinting())
            Sprint();
        else
            StopSprinting();
    }
}

By other hand, I recommend this article to get familiar with unity’s new input system, is really great!

Regards,
Krull

Thanks Krull. I’ve bought your asset and I try my first steps :slight_smile: But I can’t get to work jumping behavior with Root Motion animations. “Use Root Motion” is checked. Also my model has the Root Motion Controller as component. But when I jump, my character first jumps up on the y axis with physics and after that the root motion animation runs. I could prevent this behavior by setting the Jump Impulse to 0…then the Root Motion animations works, but only on each third or fourth jump…for many jumps nothing happens, because the “OnGround” parameter is set immediately to true.

Do I made something wrong? :slight_smile:

Not really hehe, its expected behavior since in other to make root motion jumps work, you will need to set your character’s movement mode to Flying.

Quoted from user manual:

[quote]
Does it work with vertical root motion?
[/quote][quote]

[/quote][quote]
Yes, but your character needs to be in Flying movement mode.

Remember when I commented that a movement mode should not be confused with a logical state? Well this is a good case to make it clear.

Consider, you might need to create a special ability where a character leaps a specific height into the air, then lands with a powerful attack. Here the character’s logical state should be Attacking (or whatever better fits your game), while its movement mode (in order to allow vertical root motion movement) must be Flying.
[/quote]

The reason behind this is because by default (walking / falling movement modes) ECM2 will discard any vertical velocity so it ignores your given root motion vertical velocity while in flying movement mode it uses the full velocity (lateral and vertical).

Having said that, the jump is always physics based, you can disable it overriding the CanJump method and make it return false and implement your own root-based jump, just play your root-motion based jump animation.

Let me know if have any further questions

Regards,
Krull

Hi, so I just bought ECM2 and imported into my project. I realise that the 2D version is actually 2.5D, but my character is a 2D sprite, so I want to rotation to be instant. The manual says “Rotation Rate: If set to zero (0) will perform instant
turns. This is particularly useful for 2D / 2.5D games to perform side to side lock rotation.”

I set Rotation Rate to zero, but rotation is not instantaneous, it still rotates about the Y axis, meaning the sprite gets skinny, disappears, reappears, and gets fatter in the opposite direction, if you know what I mean. Help please :slight_smile:

Edit: Hmmm the problem was me, not being observant :slight_smile: There was a MyCharacter component already in Side Scroller Controller, so when I added my own MyCharacter directly to my sprite, it messed things up. So now, there’s no slow 3D rotation of my sprite about Y, but the sprite does not flip direction when I move run the other way. Maybe this is something I have to implement myself. I’ll get started - please let me know if this is the case.

Edit2: So I have a workaround by setting OrientToMovement and RotationRate to 1000000, but this is not ideal :wink:

Hello @Predulus

Thank you for purchasing ECM2!

About your issues:

Yes this is a “bug” since this feature was removed at last minute, but still managed to get in the manual. So Ill fix it in first update!

Having said that, actually its pretty easy to get the lock feature added, in your custom controller, e.g. using the MyCharacter from the SideScroller template scene, override the UpdateRotation mode to perform the movement direction lock as follows:

/// <summary>
/// Extends UpdateRotation method to perform instant side to side lock rotation.
/// </summary>

protected override void UpdateRotation()
{
    Vector3 movementDirection = GetMovementDirection();

    if (movementDirection.sqrMagnitude > 0)
        transform.rotation = Quaternion.LookRotation(movementDirection, GetUpVector());
}

The above code will replace the Character’s rotation mode (ignores rotation rate) to perform an instant rotation towards movement direction vector.

Regards,
Krull

1 Like