Hello guys,
I think some of you have the problem that their character sometimes stuck, if they get to close on a ctm point and then the next ctm point.
But if you set the distance check too high, you bot runs bad if he wants solve a corner or something like that.
So I decided to use vectors.
I calc a vector between PlayerPoint and EndPoint.
Code:
vecX = playerX - endX
vecY = playerY - endY
vecZ = playerZ - endZ
Then I calc the lenght of this vector:
Code:
length = Sqrt(vecX^2 + vecY^2 + vecZ^2)
With this length I can build the unit vector:
Code:
unitX = vecX / length
unitY = vecY / length
unitZ = vecZ / length
And then add your yard number whatever you want (for example 15):
Code:
increasedX = playerX + (vecX + 15*unitX)
increasedY = playerY + (vecX + 15*unitX)
increasedZ = playerZ + (vecX + 15*unitX)
So your character would walk to another point, but your ctm point is included in this straight line.
I would calc this a few times if your character runs. And you could check if your
character has reached the EndPoint (which is not the ctm point!)
So if you want stop there you must Push a StopState (Click to Move)
I hope I could help some of you. Sorry for my bad english.