- Home /
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);
Comment