Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class rotate : MonoBehaviour {
- public float rotSpeed = 2;
- public float rotRange = 90;
- public float currentRot;
- void Update ()
- {
- //Input for rotation
- float rotDir = Input.GetAxis("Horizontal") *rotSpeed;
- currentRot = currentRot +rotDir;
- // Limitation with clamp
- currentRot = Mathf.Clamp(currentRot, -rotRange, rotRange);
- //rotate dat thing
- if(currentRot < rotRange && currentRot > -rotRange)
- transform.Rotate(transform.forward, +rotDir);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement