Game Development Reference
In-Depth Information
}
}
else if(state == "attack")
{
if(prevState != state)
{
this.animation.CrossFade("shoot");
this.animation["shoot"].wrapMode =
WrapMode.Loop;
event = "update";
}
else if(event == "update")
{
position = target.position;
direction = position — transform.
position;
direction.y = 0;
// Rotate towards the target
transform.rotation =
Quaternion.Slerp(transform.
rotation,
Quaternion.LookRotation(direction),
rotationSpeed * Time.deltaTime);
transform.position.y = target.position.y +
heightOffset;
}
}
else if(state == "pursue")
{
if(prevState != state)
{
this.animation.CrossFade("run");
this.animation["run"].wrapMode =
WrapMode.Loop;
event = "update";
}
else if(event == "update")
{
position = target.position;
direction = position — transform.
position;
direction.y = 0;
// Rotate towards the target
transform.rotation =
Quaternion.Slerp(transform.rotation,
Quaternion.LookRotation(direction),
rotationSpeed * Time.deltaTime);
// Move the character
if(direction.magnitude > keepDistance)
Search Nedrilad ::




Custom Search