Aetheria/Assets/MouseRotate.cs
Reinier Vens 47e500e1ce Playability
Fixed loadout generator tutorial edge cases
Recreated missing items
Created field shader & test scene
2022-08-08 22:43:55 +01:00

42 lines
1,013 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using Unity.Mathematics;
using static Unity.Mathematics.math;
public class MouseRotate : MonoBehaviour
{
public float Speed;
public ClickRaycaster Click;
private bool _rotating = false;
private Vector3 _euler;
void Start()
{
Click.OnClickMiss += data =>
{
_rotating = true;
//Debug.Log("Started Rotating");
};
_euler = transform.localEulerAngles;
}
// Update is called once per frame
void Update()
{
if (_rotating && !Mouse.current.leftButton.isPressed)
{
_rotating = false;
//Debug.Log("Stopped Rotating");
}
if (_rotating)
{
var mouse = Mouse.current.delta.ReadValue();
_euler.x -= mouse.y*Speed;
_euler.y += mouse.x*Speed;
transform.rotation = Quaternion.Euler(_euler);
}
}
}