Hi. Thanks for reading. Once I’m aware you can’t get acknowledged on Discord while a few people are having a great chat, I’m left to ask here.
So my silhouette enemy needs to be raised up, pause for a few seconds, then rotate back down. Debug.Log shows me that SetBool("show", false)
is called, but when I check in Animator, the first animation plays once more, then moves to the hiding part. (so hide goes to show, then show again, then show reverse). I see the parameter does go to false, but it continues to play show.
I know I’m doing it an awkward way. I only have two animations. One hiding and one raising. I’m using Animator speed of -1 to trick you. If I can’t find the reason why the raising animation plays twice… I would only think I’d have to have 4 animations (hide, going up, going down, stay up). I just thought I’d be lazy and not animate more.
These are very simple box models. Do you think it’s best having more animations, or to do more through code?
PauseTarget is being called by an Event
public class silhouetteScript : MonoBehaviour
{
Animator anim;
public float pauseTime = 10f;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
paused = false;
}
// Update is called once per frame
void Update()
{
//Debug.Log(animationTime);
if (Input.GetKeyDown(KeyCode.G))
{
anim.SetBool("show", true);
}
}
IEnumerator PauseTarget()
{
Debug.Log("Pause triggered");
anim.speed = 0f;
yield return new WaitForSeconds(pauseTime);
Debug.Log("Go back down!");
anim.SetBool("show", false);
anim.speed = 1f;
}
}