Hello Guys, Im making a Top down shooter and Im wondering how I can make a Survivor (GameObject) Follow my player but not get to close, so if(distance.Vector3 < 5) for e.g.
PLEASE HELP!!
Hello Guys, Im making a Top down shooter and Im wondering how I can make a Survivor (GameObject) Follow my player but not get to close, so if(distance.Vector3 < 5) for e.g.
PLEASE HELP!!
This should help
http://www.youtube.com/user/TornadoTwins#p/c/11F87EB39F84E292/8/u8t3fdKhDxg
Hope it helps!
The correct way of vector3 distance is
if(Vector3.Distance( selfObject, otherObject.transform) < distanceVariable);
tho following is much more complicated. Yet not complicated.
Get the AI to look at the player and move Transform.Foward in that direction.
More exact for your case you do something like this.-
var enemyObject: Transform;
function Update(){
if(Vector3.Distance(transform.position, enemyObject) > 10)
{
transform.LookAt(enemyObject.transform);
var dir = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")));
if (dir != Vector3.zero)
{
transform.forward = Vector3.Normalize(dir);
}
}
}
I hope I helped you at all.
Is this JavaScript?
– baseballlord9