- Home /
how to thrust a rigidbody exponentialy faster in a direction?
how can i thrust a rigidbody forward (z axis) by pressing the left mouse button with changing parameters, like maximum speed and exponential increasing speed time?
Answer by SOIL · Aug 02, 2010 at 08:00 AM
here is the correct working script: for my issue it works like it should. a bit more options could be made, but as a non scripter this is also enough for me. good enough for a small start in moving rigidbodies.
public class MoveForwardwithMouseClick : MonoBehaviour {
void FixedUpdate() {
if (Input.GetButton("Fire1")) {
rigidbody.AddForce(transform.forward * 2000f);
}
}
}
Answer by fireDude67 · Jul 31, 2010 at 10:22 PM
function FixedUpdate() {
if (Input.GetAxis("Fire1")) {
rigidbody.addForce(transform.forward * rigidbody.velocity * 2);
}
}
put the above script on the GameObject that has a rigidbody.
maybe i am to dump to create an Csharp script. but i get an parsing error.
C# requires more than the script above to function write. I replaced it with a javascript script
Your answer
![](https://koobas.hobune.stream/wayback/20220613070156im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Auto-moving RigidBody2D to a point, using thrusters (part of AI) 0 Answers
Composite body physics 2 Answers
collision problem 1 Answer