Advertisement Jump to content
Sign in to follow this  

Dragable HUD to Gameobject instance

This topic is 830 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!