I’ve made a script to control tanks, and their movement is performed by transform.Translate.
The problem is that sometimes the enemy’s bullets bounce off me.
The bullets of the enemy have a script that detects the collision and the bullet destroys itself.
Sometimes the operation is correct, the bullet hits me and destroys itself. But sometimes the ball bounces off me and not destroy itself.
Also, I am using a plane as the stage floor. And sometimes the bullet has such behavior when it hits the ground, which is static.
are you using collider + rigidbody on your bullet ?
your tank , i believe has a collider on it ? if things bounce is because they catch up between us collider and if some of the element get rigid body on it you may get this behavior as the physics will respond to that.
if you want have your bullet get destroy on contact with your tank you may be better to just check on your collider is trigger , this way you won’t get any bounce / collision response other than a simple detection hit.
My bullet have a sphere collider + rigidbody attached. The rigidbody of the sphere have Collision Detection: Continuous Dynamic.
My tank also have a collider + rigidbody too. Maybe here is the problem? Im using a rigidbody in the tank to have earth gravity and center of mass. Maybe I have to remove this rigidbody? In this case I will need to emulate the gravity inside the script,
Im using OnCollisionEnter instead of OnTriggerEnter, becouse I like to have the contact point of the impact, to instantiate an explosion right there.