- Home /
Moving a object around with mouse, rotating it with arrow keys and placing it.
I've been trying to make a script that lets me attach an object to the mouse, while keeping the base of the object on the ground. So when you move the mouse around the object moves across the ground while never going any higher than the ground. While it it being moved around with the mouse I want to be able to rotate it with the arrow keys.
I've tried several things and have spent a lot of time trying. The best I can do is place the object at the players position.
Any help would be much appreciated.
Cheers!
Answer by Est · Feb 24, 2011 at 03:55 PM
i am just a beginner so i made mess with capital and name ..... but i think you can do something like this
create a object-boss give him all variable you have in a transform component traslate,x,y,z
rotate x,y,z
so make he create the object you want place on the ground storing his id (?) in this way
var newObject = Instantiate (myObject);
now you can set the variables of the object using
newObject.transform....
so you can update the "fake"information of the boss in the newObject and use the input.Getdown(keycode) and the mouse position to increase and decrease the "Fake"variables
at the end you can cut the link.
var newObject = null
if you want place the newObject where the mouse point, you must use a ray i dont know how use it , but in the help there are some useful example
Your answer
Follow this Question
Related Questions
Move object A towards object B 2 Answers
Dragging Objects with the mouse 1 Answer
Rotating object using mouse movement 1 Answer
Rotate a moving object 0 Answers
Rotate a thrown spear to Mouse Position (2d top down game) 0 Answers