- Home /
AddForce to opposite direction
Hello
how can i addforce to the opposite direction after using this: rigidbody_.AddForce(direction.normalized * force * Time.deltaTime, ForceMode.Force);
I tried rigidbody_.AddForce(direction.normalized * -1 *force * Time.deltaTime, ForceMode.Force);
But it didn't work
Thanks.
P.S I tried also to do rigidbody_.AddForce(direction.normalized * -2 * force * Time.deltaTime, ForceMode.Force);
and it works. But I want to addforce with the same force.
Answer by Alond · Jan 26, 2020 at 03:33 PM
What you did should work, multiplying by -1... How do you define the direction? What's the rest of the code?
Answer by lgarczyn · Jan 26, 2020 at 08:51 PM
You should not use ForceMode.Force with a force multiplied by Time.deltaTime, ForceMode.Force already multiplied the input by Time.fixedDeltaTime, just like ForceMode.Acceleration.
You also need to make sure you are calling this on FixedUpdate.
Except for that, adding a - before direction or multiplying by -1 should work.
If you need to multiply by -2, maybe you're still calling the previous force as well? If you're calling both they'll cancel each other out.
Your answer
Follow this Question
Related Questions
Freeze Position + collision? 0 Answers
When Movement speed Change once it never change again 1 Answer
Rigidbody-based spaceship? 1 Answer
Jumping with rigid body3d 1 Answer
rolling ball movement on different axis 0 Answers