- Home /
Can the update function calculate collisions?
I have an arrow hitting the target with an OnCollisionEnter function, which doesn't always stop the arrows or they stop in mid air behind the target or at a weird angle. To stop the arrow I used a Destroy(collision.rigidbody); method. I think the problem is the arrow is moving too fast. Is it possible to run a collision in the Update function so it's checking for the collision more often?
Thanks for any help!
Answer by TowerOfBricks · Jan 08, 2010 at 06:17 AM
You can increase the rate at which the Fixed Updates occur, it would not be very good though since it takes CPU power and it won't always stop it from happening (if you still want to do it you can change the Fixed Update rate in the Project Settings-->Time). A better option would be to use a script which checks if it should have hit something the last frame (using raycasting), there is such a script at the wiki and you can find it here: http://www.unifycommunity.com/wiki/index.php?title=DontGoThroughThings
Why are you destroying the rigidbody of the object? That would only cause it to stop instantly, shouldn't you destroy the gameObject instead?
I'm guessing he destroys the Rigidbody only, because he wants the arrow mesh to remain stuck into the object and visible, like real arrows do!
Answer by QuapPac · Mar 25, 2014 at 02:29 AM
This might be a dumb answer, but did you remember to change the rigidbody collision detection from Discrete to Continuous?
Your answer
Follow this Question
Related Questions
OnTriggerEnter2D not triggering 2 Answers
ControllerColliderHit, two objects, takes wrong one 1 Answer
Check if object left a specific collider. 1 Answer
detect power of a hit for VR boxing 0 Answers
raycast hit point is wrong 2 Answers