Untitled
unknown
plain_text
3 years ago
744 B
7
Indexable
using System.Collections; using System.Collections.Generic; using UnityEngine; public class rotate : MonoBehaviour { public Transform Turret; public float TowerSpeed; public float TowerAngle; void Start() { TowerAngle = 0; Turret.localRotation = Quaternion.AngleAxis(TowerAngle, Vector3.up); } // Update is called once per frame void Update() { rotatetower(); } void rotatetower() { TowerAngle += Input.GetAxis("Mouse X") * TowerSpeed * Time.deltaTime; TowerAngle = Mathf.Clamp(TowerAngle, -90, 90); Turret.localRotation = Quaternion.AngleAxis(TowerAngle, Vector3.up); } }
Editor is loading...