- Home /
Standard RigidbodyFPSController incomplete feature
Hi guys, I've noticed that there is an incomplete feature in the code of the standard rigidbody fps controller that comes with Unity.
In the RigidbodyFirstPersonController.cs, located in the Characters section, there is a variable called slowDownRate that is never used anywhere in code. The comments say "rate at which the controller comes to a stop when there is no input".
I would like to implement this feature, but I'm not sure how to do it the right way. Initially I added this in FixedUpdate:
if ((Mathf.Abs(input.x) > float.Epsilon || Mathf.Abs(input.y) > float.Epsilon) && (advancedSettings.airControl || m_IsGrounded))
{
/*original controller code here*/
}
else
{
if (m_IsGrounded)
{
Vector3 newVel = m_RigidBody.velocity;
if (newVel.magnitude <= advancedSettings.slowDownRate)
{
m_RigidBody.velocity = Vector3.zero;
}
else
{
m_RigidBody.velocity -= newVel.normalized * advancedSettings.slowDownRate;
}
}
}
However, this approach is obviously flawed, because if another rigidbody gives a big impulse to the character, and there is no user input, this causes a rapid decrease in speed.
Does anyone have any ideas how to improve this?
Your answer
Follow this Question
Related Questions
Third Person Camera Movement control. 2 Answers
Problems creating first person controller 0 Answers
Problem with Colliders 1 Answer
Attaching Main Camera to a GameObject 1 Answer
How to change rigs spine rotation? 2 Answers