As the title says, I want to have a script that will make a enemy randomly move to a point within a area and then move to the next random point in the area and so on. However I don't really have an idea on how to do this.
I did try to create a script to see if i could do it but it doesn't work the way i want it sadly but it's what i expected. This is the code:
void Roaming()
{
if (!inRange)
{
v3 = Random.insideUnitSphere * 5;
v3.y = 0.0f;
transform.position = Vector3.MoveTowards(transform.position, v3, moveSpeed * Time.deltaTime);
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(v3 - transform.position), moveSpeed * Time.deltaTime);
}
}
I can tell someone is going to point out most likely a big thing wrong with the script but can anyone help me with my script or help me create an entire new script to do what I want it to do.
↧