Scripts
. Navigate into the newly created folder and create a new C# script. As for the name, I go withUseGameCreatorComponents
. Open the script, and delete void Start()
and void Update()
, we won't use them. You also need to the following using
statements: Start()
, Update()
, LateUpdate()
with no content in it. Even if you don't use them, Unity processes them and generates overhead. In a game with thousands of objects and empty methods, this can cost performance!Game Creator -> Characters -> Player
. Now, open the script with your chosen IDE. The script should look like the following: <yourVariable>.GetComponent<ComponentType>()
inside a method. The second one is to already specify the type you want to have for the public variable. Let's take a look: GetComponent<Type>()
in the Unity Editor, it will generate ~0.5 KB of garbage collection, because of the safety checks that get executed. This doesn't occur in the build version. IsControllable
. player.IsControllable()
is a method with a return value of type bool. This returns the current value of the IsControllable checkbox. You can set the value of IsControllable if you access the characterLocomotion
field of the PlayerCharacter. There are also the fields for canRun
, canJump
,runSpeed
, faceDirection
and many more. health
and the stat level
from the Stats examples and set it to something new. For this, you need the methods GetAttrValue()
, SetAttrValue()
, GetStat()
and SetStatBase()
. There are also many more methods to use. Actions
component, but if you are curious enough, you can even get the title of the current executing action. For this tutorial, I'll only cover the topic on how to execute an action. Actions
component. Then you simply do <variable>.Execute();
.<variable>.Execute()
is also applicable on buttons , where a OnClick
event executes certain things, and the Call Methods
action. You reference the actions object and select Execute()
.