I have some simple chase behaviour setup on my npcs that have a “follow” component.
If the npc can see the player and is within attack distance it will then move towards the player. The npc will return to it's original position if the player goes out of sight or our of range of the npc.
My problem is the npc will wobble at it's destination, either after reaching the player's position or returning back to it's home position.
I am a beginner and I feel I'm just missing out a simple step. Can you guys please take a look at my code and advise me:
if(!visionBlocked && (playerPos.dist(npcPosition) < 300))
{
direction = playerPos - npcPosition;
}
else
{
direction = homePos - npcPosition;
}
direction.normalize();
direction *= npc->getComponent<CFollow>().speed;
npcPosition += direction;