- Home /
How could I tell a OnCollisionEnter method running on collider instead of running on a gameObject which is collided by others?
void OnCollisionEnter()
{
// I need to know whether this method running on a gameObject which collider other
// instead of being collided by other.
}
Comment
@tanoshimi Yes,a stationary gameObject is collided by other gameOjbect, but the velocity in the "OnCollisionEnter" method has already been changed by the physics engine, so still can not tell which one.
Answer by Ali-hatem · Sep 02, 2014 at 12:22 PM
void OnCollisionEnter() used to detect other gameobjects:
void OnCollisionEnter(Collision other) { if(other.gamobject.tag == "Enemy") {
do sum thing } }
//note "Enemy" is the tag for other game object taged in unity mor info see unity tags.
Thanks for your solution! I'm using it already,but I wanna some Physics based way to solved this...As I dont think this solution is enough elegance^_^