I have two objects - each of which have rigid bodies and are kinematic (I don’t want Unity’s physics applied to them). I want to react to when they are overlapping. But I read this in the manual:
“Collider.OnCollisionEnter
…
Note that collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached.”
I can’t use triggers for either because I have other objects which use trigger colliders. So can I either:
Get some event triggered when two kinematic colliders are touching?
–or–
Perform a manual test to see if two colliders are touching? I haven’t been able to find anything on this in the docs, but I can’t imagine there not being tests between two colliders if it’s already supported internally for the events to fire.
I know other rigidbodies can interact with kinematic objects so would it be possible to switch off the IsKinematic on one or both while they are interacting with one another in code but I guess that would defeat the purpose of not wanting either object to be affected by physics.
Maybe someone else could tell you what, if any, two Kinematic objects send when they “collide”
I’m wondering why this is a problem. In your OnTriggerStay method, you can specify that you only want to fire a block of code if the “collision” is from a specific object through a few different methods.
An example in C#:
public OnTriggerStay(Collider other){
if( x.other.name == "Foo")
//Do stuff with GameObjects that are named "Foo"
if( x.other.gameObject.compareTag("Bar")
//Do other stuff with GameObjects that are tagged as "Bar"
}