L1 - Scripting

Script

Scripting in Unity is a powerful method to implement complex behaviour in your experience. In the following, we will introduce a first set of useful techniques to add new functionalities. Here is an overview.

Scripted Movement

Scripted Instantiation

https://docs.unity3d.com/Manual/InstantiatingPrefabs.html

Repeating Invokes

https://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.html

Scripted Random

https://docs.unity3d.com/ScriptReference/Random.Range.html

Scripted Set Material

https://docs.unity3d.com/ScriptReference/Renderer-material.html

Trigger and Destroy

https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html https://docs.unity3d.com/ScriptReference/Object.Destroy.html

Tags

https://docs.unity3d.com/Manual/Tags.html

On Collisions and Triggers

Collisions and triggers are two native mechanics in Unity to handle interactions between objects in Unity. Both events require specific components such as colliders and rigidbodies to activate correctly. Please refer to the manual for an overview of combinations: https://docs.unity3d.com/Manual/CollidersOverview.html.

Checklist

Here is a list of important classes in Unity.

Are you familiar with those terms?

  • Vector3 and Rotate
  • Transform
  • GameObject
  • Rigidbody
  • GetComponent
  • Instantiate
  • InvokeRepeating

And here are important functions in the MonoBehavior

  • Start
  • Update
  • OnTriggerEnter
  • OnCollisionEnter
  • Destroy
Previous
Next