Unity Tutorials Page

Download Unity Hub -> Unity Editor

– > Continue in the Unity Editor {for Objects} && a C# Code IDE like Visual Studio – >

__________________________________________________________________

+ Add an Object Controller Script to any Object as a Property +

  1. Create a new C# Script in the Unity Editor.
  2. Add the following code to the Update function.

__________________________________________________________________

+ Add Object pickup with Tag & the OnTriggerEnter Function/Method +

  1. Add an Object to the scene to pickup like a coin.
  2. In the ‘Properties Window’ -> Tag the Object with something like coin.
  3. Add Collider Properties to both the Character Object and the Pickup Object.
  4. Check the isTrigger property in the Collider section of the Properties Window.
  5. Add the following code to the Controller Script Class.
void OnTriggerEnter(Collider otherObject)
{
    if (otherObject.gameObject.tag == "coin")
    {
        Debug.Log("You've picked up a coin!");
        Destroy(otherObject.gameObject);
    }

}

__________________________________________________________________

+ Adding Object pickup counting UI +

image incoming

  1. Add a Canvas to the Scene
  2. Add a Text Element to the Canvas
  3. Display Score as Text with Code

image incoming