Godot Version
Godot 4.2
Question
I’m making a top down 2d arpg. I’m trying to make a melee swing ability. I have the swing animation and hitbox stuff set up. When you press the button, the swing should happen in the direction of the mouse. The problem was that if I just start it at the player’s position, the sword will be inside the player at it’s origin. So I’d need to make it appear at some distance just outside the player.
After thinking about it, the solution here is probably just to make a pivot point node on the player scene to spawn it at. But I figure it might be still useful to know how to do the original question:
Given a vector, how do you place an object at a certain distance along that vector? Just multiplying by the distance you want would presumably give the wrong answer. I figure I’d need to use a^2+b^2 = c^2, but I want the 2 sides I don’t know.
What is the proper math here and does godot have a simple way to calculate this or do I just need to add in the formulas?