Day #003

DAY #003

Instantiating a bunch of prefab text objects at random positions in the scene.

Main points covered

#3Dtext

#Instantiate

#Vector3

#Debug.Log

#Quaternion.Identity (rotation in space)

C# script (attached to anything)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Instantiate : MonoBehaviour {

public GameObject fallingtext;

// Update is called once per frame
void Update () {
if (Input.GetMouseButton(0)) {
Debug.Log (“mouse was pressed”);
Instantiate (fallingtext, new Vector3 (Random.Range(-7, 10), 10, Random.Range(-17, 7)), Quaternion.identity);
}

}
}

Leave a Reply

Your email address will not be published. Required fields are marked *