Jump to content
  • Advertisement
Sign in to follow this  
newbie_game_dev

Dragable HUD to Gameobject instance

This topic is 731 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!