I’m trying to understand what I’m doing wrong here.
When I try to use Instantiate (c#) I get an error with this code:
Using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Transform prefab;
Void CreateEntity(){
Instantiate(prefab, new Vector3(2.0F, 0, 0), Quaternion.identity) as Transform;
}
When I try to do this, unity kicks back a “error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement”
to make it work, I have to say Transform clone = Instantiate(prefab, new Vector3(2.0F, 0, 0), Quaternion.identity) as Transform;
This works, but I do get a warning about never using clone (well, duh, I didn’t want to have to use it anyway!!!)
Can anyone explain what I’m missing?