- Home /
Initial force in a rigidbody2d object?
How can I set an initial force for a rigidbody2d object? I want an object to fly in a parabollic path, but I don't know how to. I already have a y acceleration that comes from gravity, and that's the only acceleration I need. If I use AddForce, it also gives acceleration in the axis I'm aplying it.
function FixedUpdate(){ gameObject.rigidbody2D.AddForce(Vector2(10,0)); }
What can I do to make the object not move with acceleration in the X axis, and with the gravity acceleration in the Y axis (I mean, a parabolla)?
Answer by koray1396 · Mar 18, 2014 at 12:15 PM
If you do not want to apply force in x, you should be using Vector2(0,10). Also you are applying force in every fixed interval, so you should create an if statement and apply it once. Like this
void Update(){
if(Input.GetKeyDown(KeyCode.Space)){
// and force function here
}
}