k0fe

Moving a RigidBody at a constant speed

Jun 23rd, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.18 KB | None | 0 0
  1. maxSpeed : float = 10.0;
  2. accel : float = 3.0;
  3.  
  4. function FixedUpdate () {
  5.     if(rigidbody.velocity.magnitude <= maxSpeed)
  6.         rigidbody.AddRelativeForce(Vector3.forward*accel);
  7. }
Advertisement
Add Comment
Please, Sign In to add comment