- Home /
OnCollisionEnter not responding!?
Hi, I'm trying to make a fps game but the hit detection dont work so great! The bullets go to fast for the OnCollisionEnter to recognize it so it just goes through the object instead! Can anybody help me?
//Elis
Answer by Darkforce1980 · Feb 05, 2013 at 12:16 PM
I have the same problem... I chance it to use ray cast ... the problem is that the script only see if your hiting it...at that monet. if the bullet is too fast it may run thoght your target without any collider... you can slow the bullet down....make biggere target or long bullet .or ofcause use raycasting if you know how ... raycasting do not have the same problem
Answer by poday · Jan 27, 2013 at 10:02 AM
Simple Answer: Don't use bullets. 99% of the FPS games out there just do a raycast from the weapon. If the raycast hits a wall then apply a decal, if the raycast hits an enemy then apply damage.
If you feel like you absolutely need to model the physics of bullets then you'll need to really understand the relationship between fixedUpdate, the bullets' relative velocity, and the size of the colliders. In general you probably don't want a bullet's movement distance in a fixedUpdate time step to be greater then the size of the bullet's collider. More then likely you'll have to compromise on a few issues to try and get a balance between bullet speed, bullet collider size, and CPU usage (due to running fixedUpdate too often).
But I still want bullet travel time and gravity, can I do that with raycast?
Your answer
Follow this Question
Related Questions
Collision Detection 2 Answers
onCollisionEnter 1 Answer
How to detect if a collider is touching a gameobject (java) 1 Answer
I want to pass objects through each other AND detect the collision 1 Answer
When I kill one enemy, they all die? 0 Answers