I’m trying to make a game with my own physics and I want my character accelerate at a certain rate but stop once it reaches a set speed.
At first I thought I could test to see if it is at my maximum speed and then ignore the player input but that creates choppy movement.
Any suggestion?
BTW I’m using JS.
Keep accelerating but put this code after the acceleration code:
rigidBody.velocity = Vector3.ClampMagnitude(rigidBody.velocity, maxSpeed);
aditya
3
With this you can maintain a constant speed for your character
float speed = 0.5f;
Rigidbody char;
void FixedUpdate(){
char.MovePosition(char.position + (char.gameobject.transform.forward + (speed * Time.fixedDeltatime)));
}
This is an untested code so please don’t just copy and paste