SetBusy not resetting

Exactly what it says in the topic. After I spin the character, the ClearBusy function does not seem to run even though I have it set up as in the video. Any help would be appreciated.

Doesn’t look like you’re calling the clearbusy method. Where are you supposed to be calling it?

It’s a callback from the Action.

Do you call it in the SpinAction? Can you show the SpinAction?

Please don’t paste screenshots. Check here on how to format your code in the posts

Yep. Here’s the code for the spin action. As far as I can tell it looks the same as the code in the video

public class SpinAction : BaseAction
{
    public delegate void SpinCompleteDelegate();

    private float totalSpinAmount;

    private SpinCompleteDelegate onSpinComplete;

    private void Update()
    {
        if (!isActive)
        {
            return;
        }

        float spinAddAmount = 360f * Time.deltaTime;
        transform.eulerAngles += new Vector3(0, spinAddAmount, 0);

        totalSpinAmount += spinAddAmount;

        if(totalSpinAmount >= 360f)
        {
            isActive = false;
        }
    }
    public void Spin(Action onActionComplete)
    {
        //speen

        this.onActionComplete = onActionComplete;
        isActive = true;
        totalSpinAmount = 0f;
    }

}

It’s not.

image

You are not calling onActionComplete() so the ClearBusy you passed in is never called

1 Like

I swear this keeps happening. I miss a single line. I swear I’m not an idiot. Thanks for the help.

You’re not an idiot. If I had a dollar for every time I left out a critical line, I could quit my day job and buy a nice mansion. This particular concept, the callback, can be tricky. It’s easy to forget to invoke the callback when we’re done with whatever thing we’re doing. After a while, remembering the callback will be second nature.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms