Collision Detection In Unity3D

前端 未结 1 1743
青春惊慌失措
青春惊慌失措 2021-01-27 09:26

I am working on 3D fighting game.I have two character with their animation.I have applied character controller and character controller script which i have customized. I have tw

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-27 09:48

    Alright. I assume that you get neither the OnCollisionEnter nor the OnTriggerEnter call.

    Ensure, that the scripts with these methods are on the actual GameObject, that has the collider-component.

    OnCollisionEnter-Reference:

    "Note that collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached."

    To sum up: OnCollisionEnter is only called if you actually use the physics system for moving the objects around due to forces, collisions etc.

    If you want to just register a hit without it causing movement via the physics-system, you can use the OnTriggerEnter. In this case, the rigidbody must be on the moving object, and at least one of the involved colliders must be set to isTrigger.

    Also ensure that the layers are set to collide in projectSettings->Physics.

    Hope this helps you.

    0 讨论(0)
提交回复
热议问题