basically, since i think i need to clarify just a bit... is there a way that i can make a script that does what their script does (i'll add in the script as code) but as an FSM?
//Code denotes a minimum and maximum distance from player in which to follow
//Code denotes a distance from player in which to face them
// Figure out how to isolate the axis responsible for vertical movement
// and include an option to lock it to prevent vertical movement
//Follow Variables
var target : Transform; //the enemy's target (drag player(s) to this field.)
var moveSpeed = 3; //move speed
var rotationSpeed = 3; //speed of turning
//Range Variables
var lookDist : float = 6; //How close to player before looking in Player direction
var minProximity : float = 1; //minimum range for movement.
var maxProximity : float = 4; //maximum range for movement.
var myTransform : Transform; //current transform data of this enemy... try to set this as private and not adjustable from the inspector.
function Awake()
{
myTransform = transform; //cache transform data for easy access/preformance
}
function Start()
{
target = GameObject.FindWithTag("Player").transform; //target the player
}
function Update ()
{
var dist = Vector3.Distance(target.transform.position, transform.position);
if (dist < lookDist)
{
//rotate to look at the player
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
if (dist > minProximity && dist < maxProximity)
{
//move towards the player
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
}
}
since both berg zerg and the Tornado Twins cover this kind of script in their tutorials (though i have added to it) i don't think it's really prudent to say it's mine and be tight lipped... especially if keeping the code to myself won't help resolve this.
though, if someone has an FSM or template they can share that does the same thing, i'll be very grateful