- Home /
What is the best way to check is object intersecting?
I need to check multiple times in one frame is object intersecting with anything. Yes, I could use bounds but then I should generate cube colliders for every object to deal with meshes with holes.
OnCollisionStay could be used.
If your objects are irregular, you could use mesh colliders and then set them as convex to give a basic collision approximation
Documentation says OnCollisionStay is called once per frame. How do I make it work multiple times?
fire flag in OnCollisionEnter and reset it in OnCollisionExit. And use this flag as many times per frame as you need.
Why? Providing an explanation here will help others see what you are trying to do and hopefully offer an alternative approachOnCollisionStay is called once per frame. How do I make it work multiple times?
Answer by Hexer · Dec 19, 2014 at 06:08 PM
function OnCollisionStay()
{
Debug.Log("It intersect!");
if (collision.gameObject.tag == "ObjectTag1"){
Debug.Log("ObjectTag1");
}
}
Do you mean something like this?
No, he meant the working version with the appropriate parameters.
It does not work multiple time in one frame. I know how physics work and I can't use it. Please delete your answer.
Your answer
Follow this Question
Related Questions
How to check is object directly next to another object? 1 Answer
Drag and Drop Objects in Game Problem 2 Answers
Reset a collider during runtime to lose previous Physics.IgnoreCollision() calls 1 Answer
3D player and 2D floor. I have collider problem. 1 Answer
Compound Collider - Best Practices 1 Answer