I feel this is very basic, but I just can’t figure it out.
In this video:
The script looks like this
using UnityEngine;
using System.Collections;
public class UsingInstantiate : MonoBehaviour
{
public Rigidbody rocketPrefab;
void Update()
{
if(Input.GetButtonDown("Fire1"))
{
Instantiate(rocketPrefab);
}
}
}
The “rocketPrefab” is initialized as a Rigidbody, but the prefab is a GameObject, maybe with a Rigidbody attached, isn’t it?
Why do this code not initialize “rocketPrefab” as a GameObject?
I am trying to do this:
using UnityEngine;
using System.Collections;
public class Spawn : MonoBehaviour {
public GameObject prefab;
void Start () {
GameObject test = Instantiate (prefab) as GameObject;
test.tag = "TagName";
}
// Update is called once per frame
void Update () {
}
}
The prefab is Instantiated, but I can’t set the tag name?
As mentioned, would it be nice to understand this. I feel I lack some basic understanding.
Thanks