Game Development Reference
In-Depth Information
Update()
The Update() function is called at every frame, if MonoBehaviour is enabled.
Note
MonoBehaviour is the base class for every script derived from Unity. We can use
SetActive(true) to enable or SetActive(false) to disable the script. For more
details, visit the following link:
https://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.html
Update() is the most commonly used function to implement any kind of game behavior.
An example of the Update() function is as follows:
// JavaScript user:
// Moves the object forward 1 meter per second
function Update () {
transform.Translate(0, 0, Time.deltaTime*1);
}
//C# user:
// Moves the object forward 1 meter per second
void Update () {
transform.Translate(0f, 0f, Time.deltaTime*1f);
}
Search WWH ::




Custom Search