[RELEASED] Easy Character Movement 2

image


box collider is off.

From the video you sent me, it seems like the system is having trouble detecting the ground. It’s possible that the box collider is interfering with the ‘ground detection system.’ To address this, make sure the character is set to ignore the box collider.

To help isolate the issue, I suggest trying a regular ECM2 character (e.g., the demo character) to see if the problem occurs.

On a separate note, is your ‘ground’ (the checkboard plane) a moving platform?

Hi Krull,

Could you elaborate a bit more on an example of where you would call the Simulate manually? I assumed it was crucial for it to be where it was. My version of ECM2 doesn’t have the enableAutoSimulation settings but could look into updating if this is a good work around.

Hi @Asarge

By default, a Character is automatically simulated by implementing a ‘LateFixedUpdate’ using a coroutine. This ensures that the character is simulated (moved, rotated, etc.) after the internal physics engine has been updated.

However, in certain cases, such as networking, this automatic simulation may not be desirable. For this reason, ‘auto simulation’ can be disabled, allowing us to manually simulate the Character. Since the Character is fully kinematic, it will not move until its Simulate method is called.

In ECM2 versions prior to v1.4.0, this feature was called ‘enableLateFixedUpdate.’ However, in newer versions, it has been renamed to ‘enableAutoSimulation’ to more clearly reflect its purpose.

To use this feature, simply call it from a script, for example, in the Start method:

void Start()
{
    myCharacter.enableLateFixedUpdate = false;
}

And to call its Simulate method, from an Update, LateUpdate, etc.:

void Update()
{
    myCharacter.Simulate(Time.deltaTime);
}

This is exactly what the ‘LateFixedUpdate’ does, but in sync with Unity fixed step.

Please note that if you disable auto simulation and simulate your character in Update or LateUpdate, you must also disable Rigidbody interpolation. Since interpolation is no longer needed in this scenario, leaving it enabled can cause issues.

Another important consideration when simulating in Update or LateFixedUpdate is to implement a semi-fixed timestep. This helps reduce the character’s susceptibility to frame rate fluctuations.

The other option I mentioned is to use Unity’s Script Execution Order to define whether a Character is updated before or after a specific script. This solution is also worth exploring. However, please note that I am not familiar with the Obi package.

Hello! I am having problem with setting the maxFlyingSpeed. When the flying friction is set to 1 then the flying speed is not going above 20m/s

The formula is influenced by both acceleration and deceleration, as well as friction. It’s likely that your current settings limit the terminal velocity of objects due to the friction and acceleration values. This is similar to real-life scenarios where a vehicle’s terminal velocity is limited by friction, air resistance, and other factors.

You can review the formula in the CalcVelocity method. It’s also possible to completely replace the default formula with one that suits your game by overriding the CalcVelocity method in a class derived from Character.