- Home /
Bullet getting repelled when coming closer to it's spawn point.
In my project, a bullet spawns then moves toward its target and getting bounced after hitting a wall. After getting bounced back, when it comes closer to its spawn point, it starts to slow down then goes in opposite direction like there is some opposing force present in its spawn point. Any idea why this is happening?
Bullet has rigidbody component and I am using AddForce to move the bullet.
do you have other rigidbodies around ? A screenshot will help
No. I don't have any other rigidbodies there. Just walls having block colliders.
I think my bullet has physics material because of which it is bouncing back. But as I have used
rb.AddForce(transform.forward * thrust * Time.deltaTime);
to move the bullet. and after getting bounced back it does not change its face. So a force is still being applied toward the direction of its face i.e. towards the wall.
Any idea how to turn its face toward the direction of its motion?
putting rb.AddForce(transform.forward thrust Time.deltaTime);
in Start function is helping but for that I have to keep thrust at 500000 to get a decent bullet speed. And I also want to know if there is any better way to do this.
Answer by osybear · Jan 08, 2018 at 05:01 PM
You are continuously adding force in one direction so it will continue in that direction after the bounce. Instead in Start or Awake function add a force using ForceMode.Impulse once so that it continues in the desired path after bounce.
yes, that's how I resolved it by adding force in Start function. Thanks.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Improve Script Performance Physics 2 Answers
How to drive Rigidbody.AddForce acceleration correctly from Update 1 Answer