x


2D arm rotation using mouse

Hello, I'm trying to rotate the arm (plane) object in z axis using the x and y positions of the mouse. I did the same thing in c++ language a while a go, but I feel like there is an easier way in unity.

I tried this code in my arm object, but it rotates it in x and y axis. opposite of what I want.

var position = Input.mousePosition;
newposition = Vector3(position.x,position.y,-camera.main.transform.position.z);
var lastposition = camera.main.ScreenToWorldPoint(newposition);
transform.LookAt(lastposition);

Has anyone did something similar?

Thanks

more ▼

asked Dec 12 '10 at 06:24 AM

akurdas gravatar image

akurdas
1 1 1 1

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2166
x1036
x984

asked: Dec 12 '10 at 06:24 AM

Seen: 1027 times

Last Updated: Dec 12 '10 at 06:24 AM