I’m making a 2D top-down game and I’d like to have an Arc from the player coming so in theory swords swings would do damage in a 45deg in a predefined range (weapon dependent, 1f, 2f so on). But no matter how I try to find anything I can’t make it work. I don’t want to rotate the player towards the mouse, I just want to have an Arc where the mouse position in the middle.
Either it becomes wonky and the degree from Euler is off, or when normalized it tries to draw a line (with Debug.DrawLine) in regards to Vector3.zero.
This is the latest of my tries:
var startPos = GetComponent<Renderer>().bounds.center;
var mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10));
Quaternion q = Quaternion.Euler(20, 0, 0);
Quaternion q2 = Quaternion.Euler(-20, 0, 0);
Debug.DrawLine(startPos, mousePos);
Debug.DrawLine(startPos, q * mousePos, Color.magenta);
Debug.DrawLine(startPos, q2 * mousePos, Color.green);
If at all possible I would like to have it visualized in Editor mode, but I’m getting to the point of thinking it’s either hard to do or impossible (to me)