Files
RatStabber/Assets/Sword.cs
ProtoSharkk 22bb25e95e Added sword that always points at the mouse cursor
help me i hate quaternions and trig so much
2024-10-20 00:11:58 -07:00

24 lines
480 B
C#

using UnityEngine;
public class Sword : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.rotation = Quaternion.Euler(
new Vector3 (0, 0, Mathf.Atan2(
Screen.height/2 - Input.mousePosition.y,
Screen.width/2 - Input.mousePosition.x
) * Mathf.Rad2Deg + 135)
);
}
void Swing() {
}
}