- Home /
Question by
BDX777 · Dec 21, 2013 at 03:35 AM ·
rotationgungun scriptsway
Gun Rotation Sway
Hi, I'm trying to have my weapon rotate with the mouse movements but then rotate back upright. And I want to limit it's rotation.
using UnityEngine;
using System.Collections;
public class GunSway : MonoBehaviour {
// Update is called once per frame
void Update ()
{
if(Input.GetAxis("Mouse X")<0)
print("Mouse Moved Left");
if(Input.GetAxis("Mouse X")>0)
print("Mouse Moved Right");
if(Input.GetAxis("Mouse Y")<0)
print("Mouse Moved Down");
if(Input.GetAxis("Mouse Y")>0)
print("Mouse Moved Up");
if(Input.GetAxis("Mouse X")<0)
transform.Rotate(0,1,0);
if(Input.GetAxis("Mouse X")>0)
transform.Rotate(0,-1,0);;
}
}
Comment
Your answer
Follow this Question
Related Questions
Sprite facing object to mouse 0 Answers
Camera Control/ Rotation C# 0 Answers
Creating limits on how far something can rotate. 1 Answer
How do i make my weapon sway? 2 Answers