using UnityEngine; using System.Collections; public class ConstantForce : MonoBehaviour { public Vector3 force; public Rigidbody body; public float maxSpeed = 1000; public bool localSpace = true; // Use this for initialization void Start () { } // Update is called once per frame void FixedUpdate () { if (body != null) { var vel = body.velocity.magnitude; if(vel < maxSpeed) { if(localSpace) { var f = transform.TransformDirection(force); body.AddForce(f); } else { body.AddForce(force); } } } } }