I am making a robot battling game where I want the enemy to randomly move and then sometimes travel towards the enemy. Code that I want the movement to be in.
else if (avoid == false)
{
transform.LookAt(target);
transform.Translate(Vector3.forward * Time.deltaTime * movementSpeed);
currentLerpTime = 0;
}
This code just makes the AI move towards the player but I also want it occasionally to move in a random direction and then change direction occasionally. How would I do this?
To make it move in a random direction, the variable you need to edit is the vector.
The problem here though is while it moves it will continue to keep looking at the target (i am assuming this is getting called each frame). In terms of generating three random numbers, you can do this by yourself with just C# or go read this
https://docs.unity3d.com/ScriptReference/Random.html
That link should really help you out.
Hope this helps.