Post by Invector on Jul 10, 2018 12:47:10 GMT
Hey guys!
In the last update, we did a fix for the idle root motion but affected the Jump in place.
To fix it's really simple just open your vThirdPersonMotor and replace the ControlSpeed method to this:
In the last update, we did a fix for the idle root motion but affected the Jump in place.
To fix it's really simple just open your vThirdPersonMotor and replace the ControlSpeed method to this:
public virtual void ControlSpeed(float velocity)
{
if (Time.deltaTime == 0) return;
// use RootMotion and extra speed values to move the character
if (useRootMotion && !actions && !customAction)
{
if (input.magnitude > 0.1f)
{
this.velocity = velocity;
var deltaPosition = new Vector3(animator.deltaPosition.x, transform.position.y, animator.deltaPosition.z);
Vector3 v = (deltaPosition * (velocity > 0 ? velocity : 1f)) / Time.deltaTime;
v.y = _rigidbody.velocity.y;
_rigidbody.velocity = Vector3.Lerp(_rigidbody.velocity, v, 20f * Time.deltaTime);
}
else
{
if(!isJumping && !isSliding)
_rigidbody.velocity = Vector3.zero;
transform.rotation = animator.rootRotation;
transform.position = animator.rootPosition;
}
}
// use only RootMotion
else if (actions || customAction || lockMovement || forceRootMotion)
{
this.velocity = velocity;
Vector3 v = Vector3.zero;
v.y = _rigidbody.velocity.y;
_rigidbody.velocity = v;
transform.position = animator.rootPosition;
if (forceRootMotion)
transform.rotation = animator.rootRotation;
}
//use only Rigibody Force to move the character (ideal for 'inplace' animations and better behaviour in general)
else
{
if(input.magnitude > 0.1f || isJumping || isSliding)
{
if (isStrafing)
StrafeVelocity(velocity);
else
FreeVelocity(velocity);
}
else
{
transform.rotation = animator.rootRotation;
transform.position = animator.rootPosition;
_rigidbody.velocity = Vector3.zero;
}
}
}