In a libgdx project of mine, I have two units on a 2d field who want to fire at each other. They both know the x and y distance to each other by subtracting their enemies position from their own:
Vector2 path = pos.cpy().sub(target.getPos());
What's the simplest way of turning this Vector2 into a vector that'll allow the units to fire at each other, with the projectile being sent off with Projectile.maxSpeed
?
I was thinking of normalizing path
and multiplying both x
and y
with the desired bullet speed, but I fear I may be overthinking this and that applying trigonometry would be simpler.