- Home /
How to position objects with mouse?
Hello everyone. I searched for a similar question but did not find one, sorry if this is a repeat.
I am working on a project to create a top down game where you can click on a GUI button to place objects (such as houses, benches, tables) into a scene. My problem is I cannot figure out how to move/rotate the object once it has been instantiated. I was thinking maybe using the left mouse button to move it and right mouse button to rotate it around the y-axis.
If you could help me with a script or just point me in the right direction I would be very thankful, and would like to say Thank You in advance.
Why not use a keyboard button to rotate? $$anonymous$$uch easier.
Answer by towerer · Jun 17, 2010 at 03:35 PM
Find the DragObject script from "Unify forums". Than add things like if (Input.GetKey (KeyCode.UpArrow)) MoveUp(); if (Input.GetKey (KeyCode.DownArrow)) MoveDown(); if (Input.GetKey (KeyCode.RightArrow))TurnRight(); or with mouse buttons
Answer by Tetrad · Jun 17, 2010 at 12:30 PM
I'd recommend doing something more obvious. Like you have the concept of a "selected" item (maybe it's highlighted somehow). And on that selected item you have 3D buttons you can click on to cause the object to rotate one way or another.
Your answer
![](https://koobas.hobune.stream/wayback/20220613062308im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Rotate 3rd person Character according to mouse position 0 Answers
2D Sprite rotate relative to mouse snapping incorrectly. 2 Answers
Rotate plane on a pivot to the mouse position (in 2D) 1 Answer
Problem with rotation of objects 0 Answers