Path Following: Entities stop responding randomly
Posted: Wed Dec 24, 2014 9:23 pm
From my previous thread I managed to implement a path system using the demo and the enemy moves as I want it to now. However, I have this weird problem on my server where on random restarts, entities stop responding totally to any input or automated movement patterns.
I checked and my space is being updated as well as the time parameter for the paths. The player which is controlled by an EntityMover (setting targetPosition) will move very slightly forward/backward when I press a key but will only move so far, then no more. The very small movement is due to the fact that whenever the player presses the forward/backward key, based on their orientation the player's position will be updated by small increments like so:
What I cant figure out is why the player would only move once in either direction and no further. It seems based on observation every time something goes wayward with my monster's entities it affects all other entities in the space.
The monster which uses a path following system does not move at all even if my logs are telling me it is being updated. I am not sure how to isolate the problem...it seems totally random. Any ideas where I can start looking?
EDIT: I also noticed that I may not be handling my loops properly. My update method is basically run by a timer every 16 ticks. It starts when the server started. I tried restarting and once again the same problem shows up and it takes a very long time for my entity to even spawn. in the client. This has never happened before and I did not change my code at all before the restart.
I checked and my space is being updated as well as the time parameter for the paths. The player which is controlled by an EntityMover (setting targetPosition) will move very slightly forward/backward when I press a key but will only move so far, then no more. The very small movement is due to the fact that whenever the player presses the forward/backward key, based on their orientation the player's position will be updated by small increments like so:
Code: Select all
if (!unityClient.isMoving)
{
unityClient.isMoving = true;
Vector3 oldpos = unityClient.compactCollider.Position;
Vector3 forward = unityClient.extendedCollider.OrientationMatrix.Forward;
Vector3 newpos;
float rate = 0;
if (!unityClient.canRun)
{
rate = unityClient.cacheCharStatsInfo.walk_speed * 0.01f;
}
else
{
rate = unityClient.cacheCharStatsInfo.run_speed * 0.01f;
}
if (dir > 0)
{
newpos = new Vector3(oldpos.X - (forward.X * rate), oldpos.Y, oldpos.Z - (forward.Z * rate));
}
else
{
newpos = new Vector3(oldpos.X + (forward.X * rate), oldpos.Y, oldpos.Z + (forward.Z * rate));
}
if (newpos != oldpos)
{
unityClient.charCompactMover.TargetPosition =
unityClient.charExtendedMover.TargetPosition =
unityClient.charGrabMover.TargetPosition = newpos;
unityClient.currentMapPos[1] = newpos.X;
unityClient.currentMapPos[2] = newpos.Y;
unityClient.currentMapPos[3] = newpos.Z;
}
else
{
unityClient.isMoving = false;
return;
}
unityClient.isMoving = false;
return;
}
else return;
The monster which uses a path following system does not move at all even if my logs are telling me it is being updated. I am not sure how to isolate the problem...it seems totally random. Any ideas where I can start looking?
EDIT: I also noticed that I may not be handling my loops properly. My update method is basically run by a timer every 16 ticks. It starts when the server started. I tried restarting and once again the same problem shows up and it takes a very long time for my entity to even spawn. in the client. This has never happened before and I did not change my code at all before the restart.