- Home /
How to Instantiate prefab when dragging an object through a specific area?
I have an inventory panel and I want to know how to instantiate a prefab every time I drag an object out of it. When the object crosses the border of the panel, it turns into a prefab and turns back to the object when it crosses back in.
Answer by tormentoarmagedoom · Aug 15, 2018 at 02:26 PM
Good day.
You are asking fora lot of things in only one question. I suggest you to look for tutorials and manuals of this things:
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseDrag.html
https://docs.unity3d.com/ScriptReference/Object.Instantiate.html()
https://docs.unity3d.com/ScriptReference/Input-mousePosition.html
https://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html
https://docs.unity3d.com/ScriptReference/Input.GetKey.html
You only need to detect the mouse position, know when is over the map
Then know what world position is the position of the mouse
Then detect when the player click with the mouse
Then instantiate there the real prefab object
Bye.
Your answer
Follow this Question
Related Questions
How to obtain this prefab name in this circunstances 1 Answer
Link GUIText to a prefab? 2 Answers
Tower defense target update 0 Answers
Prefabs spawn with wrong values 0 Answers
Prefabs & Instances 1 Answer