Answers for "how to set max speed to object in unity"

C#
0

how to set max speed to object in unity

public float maxSpeed = 200f;//Replace with your max speed   
void FixedUpdate()
{    
  if(rigidbody.velocity.magnitude > maxSpeed)
{    
  rigidbody.velocity = rigidbody.velocity.normalized * maxSpeed;
}
}
Posted by: Guest on June-27-2021

Code answers related to "how to set max speed to object in unity"

C# Answers by Framework

Browse Popular Code Answers by Language