How do I make an action occur on the start of the NEXT step?

Right now, I have code that disables a character’s controls when talking to an NPC. However, the same button they use to start talking is the same as what they use to stop talking. Obviously, they can only start the conversation while their controls are enabled, but upon ending the conversation with the NPC the controls are re-enabled. The problem with this is that the character then registers that very same input from ending the conversation as true and starts the conversation again. Is there any way I can re-enable the player’s controls at the start of the NEXT step without a complicated workaround? Or, is there a better way to do something like this?

Hi, personally I would use a coroutine to add a cooldown to a conversation with an NPC. Seems to me that this would be a more desirable behaviour. To do this I would add a check to the start conversation code for the NPC and when ending the conversation fire off a coroutine that would reset a flag after a second or so. Add something like this to the NPC script:

    bool canConverse = true;

    public bool StartConversation()
    {
        if(canConverse)
        {
            canConverse = false;
            // actually start conversation code here
            return true; // we have started a conversation
        }
        return false; // we have not started a conversation
    }

    public void EndConversation()
    {
        StartCoroutine(ConversationCooldown());
    }

    private IEnumerator ConversationCooldown()
    {
        yield return new WaitForSeconds(1);
        canConverse = true;
    }

This allows another script to try and start a conversation, and to find out whether a conversation has actually started - so you can stop movement for example. Then the NPC will count for a second before allowing the player to start another / same conversation. I hope that helps =)