Page 1 of 1

Cannot freeze Player during conversation

Posted: Mon May 29, 2023 6:19 pm
by Luseya
Hello!

To freeze my Player during conversation, I tried following the steps in this video: https://www.youtube.com/watch?v=ZxppOvE ... elCrushers

When I add the script that controls my character movement, it doesn't give me the option to disable it (please see screenshot attached).

I'm new to scripting so I'm not sure if it's something I need to modify in the script.

Thank you so much!

Re: Cannot freeze Player during conversation

Posted: Mon May 29, 2023 9:37 pm
by Tony Li
Hi,

Short answer: Assign the player GameObject that has your script on it, not the script file in your Project folder. Then you'll be able to select the character movement component's enabled property.

Long answer:
In C#, script files define classes. A class defines a set of data and the operations that can be done on the data. For example, the Unity "MonoBehaviour" class defines some data such as "enabled" and "transform".

The C# language has a feature called inheritance that lets you create new classes that extend the behavior defined in other classes. The original class is called the base class, and the class that extends it is the derived class.

Your character movement class is a derived class of the MonoBehaviour base class. Unity lets you add an instance of any class derived from MonoBehaviour to a GameObject. This instance is called a component.

Make sure to assign components, not script files, to UnityEvents in the inspector. This way Unity knows which instance of the class (e.g., on which GameObject) to work with.

Re: Cannot freeze Player during conversation

Posted: Wed May 31, 2023 10:17 pm
by Luseya
Thank you for your reply!

I totally didn't realize you could just drag components on the Player into that box.

I also realized that my husband had written the code in a way where it couldn't be deactivated, so I will have to work with him on that.

Thank you so much! Your explanation was very clear and helped with my understanding of how all this works. I appreciate it :)

Re: Cannot freeze Player during conversation

Posted: Wed May 31, 2023 10:33 pm
by Tony Li
Glad to help!