Answer the question
In order to leave comments, you need to log in
How to spawn an object on click (2D)?
I did this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Coin_spawn : MonoBehaviour
{
private GameObject Coin;
private Touch touch;
private Vector2 touchPos;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
touchPos = Camera.main.ScreenToWorldPoint(touch.position);
Instantiate(Coin, touchPos, Quaternion.identity);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question