- Home /
NavMeshAgent "disables" Colliders
Hi, i hope i can explain my problem good enough:
I've got a Player who doesnt use a NavMeshAgent for walking (uses new input system) and an object, which moves randomly on a NavMesh using a NavMeshAgent. so far so good. Now i wanted to implement a simple damage function; If the Player collides with the Object, his health should change. So i used the OnTriggerEnter and OnTriggerExit function. Both Object and Player have a rigidbody and a (capsule-)collider. The Collider of the Object is set to "IsTrigger".
The Problem: I tried to debug the collision, but it dosn't collide unless i turn off the NavMeshAgent (i deactivated the Agent through the Inspector). Then the Collision works fine and my DebugLogs and changeHealth method is properly called. I tried to set the Rigidbody's bool "Is Kinematic" both true and false as well.
How can i achieve both: collision detecting and movement through the NavMeshAgent?
Answer by N-8-D-e-v · Dec 05, 2020 at 12:59 AM
if it isn't already, make the collider bigger than the navmesh agent
np :) I'll convert this to an answer so you can mark it as correct @Fluffy_me .
Answer by The-Aidency · Dec 05, 2020 at 06:06 AM
The simplest option would be to create a general "damage applier" script that does only that, make a child of the NavMeshAgent with a collider, and set the script onto the child. For extensibility, allow for referencing that damage applier from your main Enemy script. Hope that helped!
Its a rather simple application, so i dont even have a major enemy script. All i have is the Script to define the movement on the nav$$anonymous$$esh. The Damage is handled in the Player Script, via OnTriggerEnter and Exit funcions.
Anyway, i did generate a child to the GameObject with the Nav$$anonymous$$eshAgent and added a collider as well as a rigidbody. Sadly the same problem accures. The OnTriggerEnter and Exit funcion are only called if the Nav$$anonymous$$eshAgent of the Parent GameObject is disabled.
Your answer
Follow this Question
Related Questions
Patrol script yielding varying results? 0 Answers
NavMesh problem it does not respond corectly 0 Answers
Can't click gameobject when over another trigger? 1 Answer
Child object's collider (on a different layer) is interfering with parent Physics... 0 Answers
Can it be detect several colliders in the same gameObject? 0 Answers