Added sword that always points at the mouse cursor
help me i hate quaternions and trig so much
This commit is contained in:
23
Assets/Sword.cs
Normal file
23
Assets/Sword.cs
Normal 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() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
- [x] Health
|
- [x] Health
|
||||||
- [x] Enemy takes health when touches
|
- [x] Enemy takes health when touches
|
||||||
- [ ] Enemy health bar
|
- [ ] Enemy health bar
|
||||||
- [ ] Sword that points to mouse cursor
|
- [x] Sword that points to mouse cursor
|
||||||
- [ ] Sword swings when click
|
- [ ] Sword swings when click
|
||||||
- [ ] Sword damages enemies in swing area
|
- [ ] Sword damages enemies in swing area
|
||||||
- [ ] Wave spawns enemies
|
- [ ] Wave spawns enemies
|
||||||
|
|||||||
Reference in New Issue
Block a user