Ok, not sure if my earlier post went through, but I am trying to have target follow my mouse position. I have
void Start () {
MousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
GameObject targetObject=(GameObject) Instantiate(target, new Vector3(MousePosition.x, MousePosition.y, 1), Quaternion.identity) ;
Debug.Log(targetObject);
}
void FixedUpdate () {
MousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//targetObject.transform.position = MousePosition;
Debug.Log(targetObject);
}
However, if I started with
public GameObject targetObject;
in the beginning, then targetObject is constantly Null for the debug.
If I do not include that, then it says targetObject is not in the current context.
I checked the library and I believe I Instantiated it right and targetObject should be a GameObject and not Null/not in context.
What am I missing?
Thanks!
Edit: Ok maybe my earlier post did went through and you can ignore this one…