I am making a td game in minecraft. For that I made some projectiles and wanted to add the ability to fire left and right projectiles. For some reason this doesn't work and the projectiles fly in wrong directions, but sometimes its fine. He is how I calculate the movement:
let dx = (x + w / 2) - 100
let dy = (y + h / 2) - 100
let distance = Math.sqrt(dx * dx + dy * dy)
dx /= distance
dy /= distance```
For the normal projectiles this works fine, and for the left and right projectiles I just do `movementX:dx*-1,movementY:dy`, `movementX:dx,movementY:dy*-1`
If you have any idea why its not working, please tell me.
