- Home /
Question by
pntruong17 · Mar 14, 2021 at 02:04 PM ·
2ddrag-and-drop
unity 2d drag & drop
Hi Every one I Instantiated one gameobject named "Food" and I want to drag it on other gameobjects named such as "Chicken". after the mouse is UP the Food will be destroyed. Thank you for your help.
Comment
Answer by TPorteau · Mar 14, 2021 at 02:21 PM
Hi, there is a component called "Event trigger", it allows to call functions of a script if an event has been triggered. And there are the Drag, Drop, Begin Drag and End Drag events which can be useful in your case.
To create a drag effect make sure you call a function in your Drag event that does :
transform.position = Input.mousePosition.
I hope it will help you.
capture-decran-2021-03-14-151503.png
(17.6 kB)