- Home /
Moving NavMeshAgent inside a Collider
I'm making a Click-To-Move RPG, and I have a Spawner
GameObject that needs to detect whether the Player is standing inside it or not. I used the SphereCollider
and RigidBody
components to detect if the Player is inside or not, but when I click the ground that's covered by that Sphere Collider the Player won't move there. I tried setting isKinematic
to true
and false
, doesn't seem to fix to problem.
How do I enable clicking over that Collider so that the Player is able to move there?
Answer by unity_UaKEscun_Mpx-g · Jan 27, 2021 at 10:10 AM
Found the solution to my problem:
I handled movement using Raycasts, so I put the Spawner
Collider on a layer called "IgnoreRaycast". Works like a charm.
Answer by DanielRPixelMan · Jan 26, 2021 at 08:47 PM
Hi , how do you handle your movement ? Try using Raycasts , this is the case if an game is 2D. This will work if an object has any kind of an collider on it , you can filter it with layermask .
void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); } }
Your answer
Follow this Question
Related Questions
Higher speed of Navmesh agent makes him go off the optimal path 0 Answers
Enemies using navmesh are bumping each other through solid objects 1 Answer
My collisions doesn't detect the collider's tag 0 Answers
How NavMesh Cost can slow down NavMeshAgent's speed? 0 Answers
How do I get agents to avoid each other? 0 Answers