Move a character a set distance on NavMesh
Hello all,
I am trying to move a character a set distance per turn. For this I currently use the following script:
pathDifference = pathCurrentPosition - pathStartPosition; //CurrentPosition = Mouse Position
pathDirection = pathDifference.normalized;
pathDistance = Mathf.Min(selectedUnitMovementRange, pathDifference.magnitude);
pathEndPosition = pathStartPosition + pathDirection * pathDistance;
This also works very well so far. The problem is that only the start and mouse position is included in the calculation. If the character should walk around a wall, he can walk much further than he should.
I have already tried to adding the difference of the individual points via a loop. Unfortunately without success.
Does anyone maybe have an idea how I could solve this problem?
Your answer
Follow this Question
Related Questions
How do I find a point along a line with a forced x and z values 0 Answers
prob to define a condition to get out of a search position loop for obstacle avoidance 0 Answers
How to play animation depending on distance ?? (Video) 0 Answers
Having some problem with AI finding a vector3... 0 Answers
Distance is always zero 0 Answers