- Home /
Detecting a colission with an instantiated object.
Hi im making a FPS game, but i have only one problem left, i have dynamic enemies that shoots instantiated bullets, the problem is i cant get my character collider detects the collision with the bullet, and then rest an ammount of life to the HP, this is the script attached to my characters collider:
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if(hit.gameObject.tag == "bullet"){
transform.parent.SendMessage("EnemyHit", 5, SendMessageOptions.RequireReceiver);
}
}
Thanks for your help!
Answer by DanFrias · Mar 13, 2013 at 05:23 AM
The problem may be due to the speed of the bullets. To deal with bullets (or other fast moving objects) you typically want to set the Rigidbody.collisionDetectionMode setting to "Continuous" or "ContinuousDynamic" to deal with this. The following page explains this:
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-collisionDetectionMode.html
Your answer
Follow this Question
Related Questions
Bullet Damage on different Limbs 1 Answer
Pickup Bullets 1 Answer
How can I destroy an enemy with two shots 1 Answer
Scoring system based on time remaining and targets hit 4 Answers
collider doesnt react to script 0 Answers