- Home /
Maintaining the set of contact points.
I'm trying to maintain the set of contact points that a rigidbody has with any objects in the game (in order to exert some custom forces on them in FixedUpdate), however I cannot understand the relationship between OnCollisionEnter and OnCollisionExit events. My rigidbody has multiple colliders and debugging the Collisions I get to enter and exit events, I don't see a one-to-one correspondence (i.e. there is not an Exit for every Enter, neither for every ContactPoint nor for every thisCollider).
The documentation seems extremely terse and gives no precise information about what events will be sent for any sequence of collision events.
Is there better documentation beyond the statement that the contact points are "The contact points generated by the physics engine"?
Ultimately I need, in FixedUpdate to be able to consider all the current contact points between my rigidbody and other rigidbodies and static colliders in the game (I'll actually try to push heavy calculation to the enter and exit events of course).
Note that I do not want to use OnCollisionStay as that doesn't get sent with sleeping rigidbodies, and I don't want to be doing all the calculation every frame, only when contact points change.
Answer by cjmarsh · May 19, 2011 at 05:59 AM
If you were to only use a sum of spherical triggers for the collision calculation, you could use polar geometry to indicate a vector for every contact point. If you let x = < sin a, cos b, c > where a,b are degrees or radians and c is a number representing magnitude ( distance from the origin of the vector ), the collision sphere is represented by the norm of x. As a result, you could simply assign an xn for the number of spheres you need and compare their corresponding vectors for your points of collision. Hope this helps, Chris.
Sorry, I don't see how this is related to my question. $$anonymous$$y problem is to maintain, given enter and exit events, the list of current contact points. Unity has the list - you can even see it in the profiler.
Your answer
Follow this Question
Related Questions
Unity3d Arkanoid platform collision problem 1 Answer
Object Reference Not Set 2 Answers
Weird Collision Detection with a Cube and OnCollisionEnter 2 Answers
Problem in Collider 2 Answers