im currently making a simple 2D box falling game and im getting this error " UnassignedReferenceException: The variable box_Prefab of BoxScript has not been assigned. You probably need to assign the box_Prefab variable of the BoxScript script in the inspector. UnityEngine.Object.Instantiate[T] (T original) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:275) BoxScript.SpawnBox () (at Assets/BoxScript.cs:15) BoxScript.Start () (at Assets/BoxScript.cs:10) CODE: using System.Collections.Generic; using UnityEngine; public class BoxScript : MonoBehaviour { public GameObject box_Prefab; private void Start(){ SpawnBox(); } public void SpawnBox() { GameObject box_Obj = Instantiate(box_Prefab); Vector3 temp = transform.position; temp.z = 0f; box_Obj.transform.position = temp; } }
I dont get it i was watching a video of a dude and i did exactly the same as he did but it wont work for me its giving me that error
I did add it to my SpawnBox Script... something else i forgot to ask, the (temp.z = 0f doesnt show any color or marks it just a plane black text but on his video did