Added sword that always points at the mouse cursor

help me i hate quaternions and trig so much
This commit is contained in:
2024-10-20 00:11:58 -07:00
parent 7aa325cccc
commit 22bb25e95e
2 changed files with 24 additions and 1 deletions

23
Assets/Sword.cs Normal file
View File

@@ -0,0 +1,23 @@
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() {
}
}

View File

@@ -33,7 +33,7 @@
- [x] Health
- [x] Enemy takes health when touches
- [ ] Enemy health bar
- [ ] Sword that points to mouse cursor
- [x] Sword that points to mouse cursor
- [ ] Sword swings when click
- [ ] Sword damages enemies in swing area
- [ ] Wave spawns enemies