x


Smooth gun movement?

How can I make my gun point in the same direction as my camera, but smoothly? I found this piece of code that works partly, but I need the variables to be constantly being set to the camera rotation. (The gun is a part of the camera)

var tiltAroundZ = Input.GetAxis("Horizontal") * tiltAngleZ;
var tiltAroundX = Input.GetAxis("Vertical") * tiltAngleX;
var target = Quaternion.Euler (tiltAroundX, 0, tiltAroundZ);
transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth);
more ▼

asked Mar 28 '12 at 06:08 PM

iguana72 gravatar image

iguana72
2 3 5 6

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

0 answers: sort oldest
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:

x461
x211
x43

asked: Mar 28 '12 at 06:08 PM

Seen: 487 times

Last Updated: Mar 28 '12 at 06:08 PM