简体   繁体   中英

Multiple collisions not working

I am experimenting collision detection using onTriggerEnter. On collision with other object(tower) direction changes and object moves. I have created one more similar object (tower) and placed both far from each other. Now for the first collision it is working fine, but at other collision it is not working, if I placed both closer to each other it works! .. I am unable to understand this phenomena, pl help Here is my code:

void OnTriggerEnter(Collider obj) {

collideCount++;
Debug.Log(collideCount);

Quaternion target = Quaternion.Euler(0, 90, 0);

tf.rotation = Quaternion.Slerp(tf.rotation, target, Time.deltaTime * speed);

tf.Translate(0,6,0);

}

I would recommend try record a collision count for each of the other collider methods such as OnTriggerStay and OnTriggerExit

This way you can identify if the engine is raising the event correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM