- Home /
The trigger enter detect fast moving object more accurate
I'm working on a bow and arrow shooting scene ! when I shoot to hit a wall , I want to arrow stick in the wall , the problem is when the speed of arrow is low it works fine ! but when its fast ! its pass through the wall and sticks inside the wall , which means that the trigger detector is slow on that ! how can I make it more accurate too detect it faster ?that arrow stop out side the wall . any idea ?
Try storing the arrow's previous transform x,y,z at the end of each FixedUpdate. Then when a collision is detected cast a ray from the previous position to the new position (not including the arrow) and see where on the target it collides and set your arrow position accordingly.
^That's the way to do it. Unity's physics system can only do so much, in the end you have to use such workarounds to get reliable collision with high-speed colliders.
Answer by mrpmorris · Jul 26, 2016 at 12:12 PM
Try storing the arrow's previous transform x,y,z at the end of each FixedUpdate. Then when a collision is detected cast a ray from the previous position to the new position (not including the arrow) and see where on the target it collides and set your arrow position accordingly.
Answer by Brian-FJ · Jul 27, 2016 at 07:44 AM
You could try changing the rigidbody's collisionDetectionMode to ContinuousDynamic. (https://docs.unity3d.com/ScriptReference/Rigidbody-collisionDetectionMode.html) It can have an effect on performance but it's worth looking into.
Your answer
Follow this Question
Related Questions
Collisions - bounce of walls but not from characters (while still reacting with them) 0 Answers
OnTriggerEnter is not working! I have tried absolutely everything I can think of. 1 Answer
Rigidbody Trigger Collider vs. Static Collider no OnTriggerEnter message 1 Answer
RigidBody - GameObject moves but mesh stays! 1 Answer
Rigidbody Version of RotateAround 2 Answers