- Home /
Distance Between NavMeshAgent and RaycastHit,Distance between NavMeshAgent and RayCastHit
Hello. I'm trying to make turn based combat system similiar to Fallout 2. oject is in isometric camera and i'm using NavMesh to move character. I need to calculate the distance between my agent and place where ray from camera hits my navmesh to put the action point cost for movement to the screen. When i use Vector3.Distance it returns always the same value when ray hit the terrain. I found the solution with Vector3.cross method but the result was usless becouse returned value had no sense. Thank's for help in advance!
Hey there,
perhaps post your current code for this calculation so that we might see where your your problem is.
Answer by KaspianR · May 17, 2018 at 11:46 AM
So Vector3.Distance(agent.transform.position, hit.point)
doesn't work? I can't see why that would always return the same value... Could you perhaps provide the script you've written so that I can take a look?
Perfect! Thank You $$anonymous$$aspianR, my mistake was that i used hit.transform.position. $$anonymous$$uch obliged for pointing newbie for right direction.
Glad I could help, good luck with the rest of the game!
Your answer
Follow this Question
Related Questions
How do I get one object to move to (the closet) another object? 2 Answers
2D Game Checkpoint & Respawning 2 Answers
Varying behaviour of transform.position.localPosition.x in StateMachineBehaviour OnStateUpdate 1 Answer
Animate from instantiated GameObject 0 Answers
Does it help performance to first check if some transform attribute has changed before setting it? 1 Answer