diff --git a/Assets/Scripts/RotateTowardsMouse.cs b/Assets/Scripts/RotateTowardsMouse.cs
index 78fdfad..22c0447 100644
--- a/Assets/Scripts/RotateTowardsMouse.cs
+++ b/Assets/Scripts/RotateTowardsMouse.cs
@@ -2,14 +2,45 @@
using System.Collections.Generic;
using UnityEngine;
-public class RotateTowardsMouse : MonoBehaviour {
- //Circa qualcosa così
+public class RotateTowardsMouse : MonoBehaviour
+{
+ ///
+ /// Velocità a cui far ruotare il braccio.
+ ///
+ public int speed = 1;
- void Update() {
+ ///
+ /// Per testing.
+ /// Determina se bisogna utilizzare
+ /// Quaternion.Slerp() o Quaternion.LookDirection().
+ ///
+ public bool useSlerp = false;
+
+ void Update()
+ {
//Trova la direzione tra il transform e il braccio
- Vector2 screenPosition = Camera.main.WorldToScreenPoint(transform.position);
- Vector2 direction = (Vector2)Input.mousePosition - screenPosition;
- //Cambia la rotazione dell'oggetto
- transform.rotation = Quaternion.identity;
+ Vector2 screenPosition =
+ Camera.main.WorldToScreenPoint(transform.position);
+
+ Vector2 direction =
+ (Input.mousePosition - screenPosition) as Vector2;
+
+ Vector3 lookDirection =
+ new Vector3(direction.x, direction.y);
+
+ /*
+ * In alternativa provare direttamente con
+ * lookDirection = Input.mousePosition;
+ */
+ if (useSlerp)
+ {
+ Quaternion.Slerp (
+ transform.rotation, // Rotazione iniziale
+ Quaternion.LookRotation (lookDirection), // Rotazione finale
+ speed * Time.deltaTime); // Velocità dell'interpolazione
+ }
+
+ else // Questo dovrebbe bastare
+ Quaternion.LookRotation (lookDirection);
}
}