Hi, I'm trying to get my plane to accelerate; i have used rigidbody.addRelativeForce, but that accelerates the rigidbody straight to the speed in the variable. I want the acceleration to be slow and smooth. I've found that you can't do rigidbody.velocity.magnitude = rigidbody.velocity.magnitude + 10; because it's read only. How do I slove this problem?
`Rigidbody.AddRelativeForce` won't accelerate the object straight to any particular speed; it will just keep making it go faster and faster. The bigger the force you specify, the quicker the acceleration. If you want the acceleration to be slower, pass in a smaller value.
You can also modify the velocity directly. `Rigidbody.velocity` is not read-only, it's the `magnitude` property that is. This should work:
rigidbody.velocity = rigidbody.velocity + rigidbody.velocity.normalized * 10;
However, that will increase the velocity by 10 units each frame, which is probably not what you want. You can use this instead to increase the velocity by 10 units per second:
rigidbody.velocity = rigidbody.velocity + rigidbody.velocity.normalized * 10 * Time.deltaTime;
You should also make sure to only run this code if the velocity is not Vector3.zero, because it will produce errors otherwise (you can't normalize something that doesn't have a direction).
Make sure that you add force in FixedUpdate
Increase the mass of your rigid body
Increase the drag of the rigid body
If you link the force to the GetAxis input it'll ramp up at the same sensitivity you give the controls, this is not really ideal as it appears in the set up screen of a stand alone player. Alternatively you can make your own force ramping function to get it smoother.