Ive looked up many ways to try this but it never works. Im trying to make a platform prefab spawn at the mouse when its clicked. Again though, this is in 2D! If you know how to, please tell me but nothing will work for me. Heres my code:
using UnityEngine;
public class ObjectCreation : MonoBehaviour {
public Transform Prefab;
void Start()
{
}
void Update () {
if(Input.GetMouseButton(0))
{
Instantiate(Prefab, new Vector3(Input.mousePosition.x, Input,mousePosition.y, 0), Quaternion.identity);
}
}
}
EDIT:
Thanks a lot @Luo_Yang for the help. I had a different result but this question is now answered.