Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class HorseMouseMovement : MonoBehaviour
- {
- public float mouseSensitivity = 100f;
- private float yRotation = 0f;
- private bool isActive = false;
- void Start()
- {
- // Locking the cursor to the middle of the screen and making it invisible
- Cursor.lockState = CursorLockMode.Locked;
- }
- void Update()
- {
- if (isActive && !InventorySystem.Instance.isOpen && !CraftingSystem.Instance.isOpen && !MenuManager.Instance.isMenuOpen && !DialogueSystem.Instance.dialogueUIActive && !QuestManager.Instance.isQuestMenuOpen && !StorageManager.Instance.storageUIOpen && !CampfireUIManager.Instance.isUIOpen)
- {
- // Get mouse input
- float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
- // Control rotation around y axis (Look left and right)
- yRotation += mouseX;
- // Apply rotation only around y axis
- transform.localRotation = Quaternion.Euler(0f, yRotation, 0f);
- }
- }
- public void Activate()
- {
- isActive = true;
- }
- public void Deactivate()
- {
- isActive = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement