Question by
sieulang · May 17, 2018 at 01:12 AM ·
gameobjectscenemousepositioninstancefalling
Help me! Create a game object falling from the top scene at click mouse point! T________T
I want create a game object falling from the top scene at click mouse point! Help me please! My script only create GO from click mouse, i'm new babie so my understand about code so bad :p! // using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ClickDrop : MonoBehaviour { [SerializeField] private GameObject drop; public int button;
private void Start()
{
}
private void FixedUpdate()
{
_Button1();
}
void _Button1()
{
if (SillyHyena.instance.isAlive)
{
//attack target
if (Input.GetKeyDown(KeyCode.Mouse0))
{
if (Input.GetMouseButtonDown(0))
{
Vector3 a = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10));
Instantiate(drop, a, Quaternion.identity);
}
}
}
}
}
Comment