//Initial Spawn Position
public float x;
public float y;
public float z;
//Target Position
public float movetoX;// x coord
public float movetoY;// y coord
public float movetoZ;// z coord
public float movetoH;// z coord
//Delta Position
public float deltaX;// x coord
public float deltaY;// y coord
public float deltaZ;// z coord
public float deltaH;// z coord
void Start()
{
//place NPCs via ZoneSpawns packet positions
this.transform.position = new Vector3(x, y, z);
}
void Update ()
{
//update deltas from clientupdate packet
if(updateDeltas == true)
{
deltaF = new Vector3 (deltaX,deltaY,deltaZ);
updateDeltas = false;
}
if (deltaF.magnitude != 0)
{
//idle gameobject recieving a target position
if(clientUpdate == true)
{
//initial movement
targetPosition = new Vector3 (movetoX,movetoY,movetoZ);
}
//if waiting on update from server for final target position, move along the delta positions
if(clientUpdate == false)
{
//continuing to move in between updates
targetPosition += new Vector3 (deltaX,0f,deltaZ);
}
//move now
this.transform.position = Vector3.MoveTowards(this.gameObject.transform.position, targetPosition, step * Time.deltaTime);
}
//idle npc after reaching a target destination.
else
{
if (deltaX == 0 && deltaY == 0 && deltaZ == 0 && movetoX != 0 && movetoY != 0 && movetoZ != 0)
{
this.transform.position = new Vector3(movetoX, movetoY, movetoZ);
}
else
{
//FOR Y ADJUSTMENTS IF UNDER OR BENEATH WORLD WHEN NOT MOVING AND NO POSITION UPDATES FROM SERVER
}
}