1
Support / Re: How to play animationf after a WaitForSeconds
« on: November 06, 2012, 10:22:11 pm »
Previously Unikron has said:
Now I'm having this kind of problem, but I don't know how to avoid that problem without use a trigger. In this case I'm using raycast and I don't know why with an object works well but with other doesn't. I'm doing this:
and into another script with the code for the animations, I have:
Quote
calling anim.Play(...) repeatedly will make it get stuck at the first frame (i.e. the clip keeps getting restarted) - can you please confirm that this isn't happening. If you call Prune from Update() it will happen.
Now I'm having this kind of problem, but I don't know how to avoid that problem without use a trigger. In this case I'm using raycast and I don't know why with an object works well but with other doesn't. I'm doing this:
Code: [Select]
if(Physics.Raycast(origin,direction, out hitInfo,1.2f))
{
if(hitInfo.collider.gameObject.name == "pole" && Animator.Instance.currentAction == "hoistFlag")
{
StopInFrontObjectClicked();
Animator.Instance.HoistFlag();
}
if(hitInfo.collider.gameObject.name == "pump" && Animator.Instance.currentAction == "drinkingWater")
{
Debug.Log("ray hit the bump.");
StopInFrontObjectClicked();
Animator.Instance.DrinkFromWell();
}
}
and into another script with the code for the animations, I have:
Code: [Select]
public void HoistFlag()
{
State = CharacterState.HoistingFlag;
if(MoveDirection == Direction.Left)
anim.Play("hoist_flag_left");
else if(MoveDirection == Direction.Right)
anim.Play("hoist_flag_right");
anim.animationCompleteDelegate = ActionToIdleCompleteDelegate;
}//HoistFlag()
public void DrinkFromWell()
{
State = CharacterState.Drinking;
Debug.Log(State.ToString());
anim.Play("drink_water_from_well");
anim.animationCompleteDelegate = ActionToIdleCompleteDelegate;
}//DrinkFromWell()