So im making a zombie game and i need them to roam around convincingly before spotting player.
I tried using this random turning method, but it just too random, it doesn’t look convincing and quickly they all kinda start bumping in to walls.
So does anyone have ideas for a better method?
Or should i introduce intermediate directions like forward+left or even randomize the time turns should be taken?
Or try some waypoint system?
void Update ()
{
turnTimer = turnTimer - Time.deltaTime;
Vector3 curLocation = gameObject.transform.position;
int randTurn = Random.Range (1, 4);
if (turnTimer < 0) {
if (randTurn == 1){
direction = Vector3.forward;
}
if (randTurn == 2){
direction = Vector3.back;
}
if (randTurn == 3){
direction = Vector3.left;
}
if (randTurn == 4){
direction = Vector3.right;
}
turnTimer = startTurnTimer;
}
//Debug.Log ("random vec" + randomTargetPos);
Vector3 randomTargetPos = curLocation + direction;
agent.SetDestination(randomTargetPos);