How to use OnCollisionEnter when use AStar

I hope enemy collide player and enemy can play attack animation
here is very simple test project: https://github.com/roroco/How.To.Detect.Collision.When.Use.AStar
here is my screencast: https://youtu.be/5PyWpi7eJSw
when enemy(cube) collide Player(capsule), OnCollisionEnter cannot be triggered, I hope detect collision, how should i do?

From the Unity documentation

Notes: Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached.

I find the solution, I cannot set rigidbody in AIPath object, but I can add empty object to its child, and put rigidbody for this child, and freeze child rigidbody position and rotation(make sure child relative position and rotation is constant), and now I can use OnCollisionEnter

2 Likes