Dragable HUD to Gameobject instance

Started by
-1 comments, last by newbie_game_dev 7 years, 6 months ago

Im trying to copy some game do about how they make a HUD and then when u press some icon it will be a game object where you can drag N drop it. For example the game C0C where when u click the house it will eventually be a game object and you can place it anywhere else..

I have this code


void OnMouseDown(){

    print("icon script getting mouse down");
    GameObject instance = Instantiate(bombInstance);
    Vector3 mousePosition = new Vector3(Input.mousePosition.x,Input.mousePosition.y,19);
    instance.transform.position = Camera.main.ScreenToWorldPoint(mousePosition);
}

problem here is I have to click twice. One for the HUD icon and the other for the instantiated object to drag to the scene. Can someone help me how to attain the Drag N Drop HUD icon where many games do?

This topic is closed to new replies.

Advertisement