First of all, here’s my code:
if (wanderMovement)
{
Vector2 randCircleLoc = Random.insideUnitCircle * 20;
if (wanderTime < Random.Range(20,60))
{
inputMovement.x = randCircleLoc.x - transform.position.x;
inputMovement.z = randCircleLoc.y - transform.position.z;
inputRotation = inputMovement;
wanderTime += Time.deltaTime;
}
else
{
waitTime += Time.deltaTime;
if(waitTime < Random.Range(2,30))
{
inputMovement = Vector3.zero;
}
else
{
wanderTime = 0;
waitTime = 0;
}
}
}
I’m just trying to get my enemies to pick a random spot inside a 20 radius circle and move towards it (eventually getting them to pick a new spot once they arrive, for infinite wandering).
The problem is, when I start this up, they just do this weird twitching where they are trying to pick a bunch of different rotations and it looks like they are just spazzing out. On top of that, they will only head towards the center of the map, to what I think is 0,0,0.
I have no idea why they would be always be picking 0,0,0 as their travel to spot when it’s supposed to be random and I have no idea why they are twitching. I took out all of my AI code except that and they were still doing it, so it’s not an issue with the rest of my code.
Thanks for the help. Boy do I miss the simplicity of XNA after using Unity so much haha.