Page 1 of 1

Dialogue System Events - Can I toggle a setting within a component?

Posted: Thu Aug 05, 2021 3:52 am
by foxfoxwaltz
Hello!
This might be a simple question/answer but within the Dialogue System Events under Conversation Start/End, can I toggle my "Can Move - True/False" under a Player Controller script component?

Initially I have the Player Controller.enabled off, and Player Animator.enabled off, and Player Rigidbody2D.sleep to stop the player from moving and animating while in a conversation. This turns off those entire components and stops my player from running and animating but he freezes mid run and stays on that frame.

Is there a simpler way to set my 'Can Move' from true to false under the Player Controller script (my player goes to zero velocity and his animation returns to a facing state instead of immediately stopping him mid run) within the Dialogue System Events?

Just somewhere I can put this in 'PlayerController.instance.canMove = false;'

Thanks again for any help! I am loving the whole Dialogue System overall!

Re: Dialogue System Events - Can I toggle a setting within a component?

Posted: Thu Aug 05, 2021 9:05 am
by Tony Li
Hi,

Yes, you can use Dialogue System Events, or add OnConversationStart/OnConversationEnd() methods to your PlayerController script. Make sure the player GameObject is being used as the conversation actor. See Character GameObject Assignments for details. Briefly: Assign the player GameObject to the Dialogue System Trigger's Conversation Actor field, or add a Dialogue Actor component to the Player GameObject and select the Player actor.

If you use Dialogue System Events, you may be able to select PlayerController.canMove from the UnityEvent's inspector. Otherwise you may need to use OnConversationStart/End() methods. You could add them to a new script on the player or add them to your PlayerController script. Example:

Code: Select all

void OnConversationStart(Transform actor)
{
    PlayerController.instance.canMove = false;
}
void OnConversationEnd(Transform actor)
{
    PlayerController.instance.canMove = true;
}

Re: Dialogue System Events - Can I toggle a setting within a component?

Posted: Fri Aug 06, 2021 1:19 am
by foxfoxwaltz
Thank you so much!
This was exactly what I needed and very easy to implement.
I appreciate your time and quick reply!

Re: Dialogue System Events - Can I toggle a setting within a component?

Posted: Fri Aug 06, 2021 7:35 am
by Tony Li
Happy to help!