Hi, im having some troubles I have a swimming style game where the player moves forward, up and down, i’m applying forces to a rigidbody in order to move the player more naturally the aceleration is working fine, the thing is when i want to move up or down the player moves but the velocity of the rigidbody remains, i mean it keeps moving vertically, but i want it to only move a little bit more when the user releases the key, not to keep moving vertically at a constant speed.
Here’s the code im applying to the movement, everything is succesfully called from FixedUpdate() and input from Update()
void FixedUpdate ()
{
if (isPlayer)
{
if (up && !down)
Subir();
if (down && !up)
Bajar();
}
}
public void Subir()
{
rigidbody.AddForce(Vector3.up * VerticalVelocity,ForceMode.Force);
}
public void Bajar()
{
rigidbody.AddForce(Vector3.down * VerticalVelocity,ForceMode.Force);
}
i’m changing the up and down variables from the Input on the update. i think is not necessary to show it, the problem is if there’s some way to slowly decelerate the Y velocity of the rigidboy to Zero when the user releases the key.
I’ve already tried with different ForceMode, Impulse,Acceleration,Force, etc… without any result.