How can I have a cannon shoot a ball (with physics behavior) so that the ball's trajectory goes through the point where the user clicks?This is what I tried to do to get the cannon at the right angle, but the cannon doesn't rotate at all (0 degrees):I got the formula from Wikipedia.The ball gets shot with an impulse of 0.6 at Cannon.Angle. I convert this to velocity using the formula that I found here.

I calculated the velocity that the ball starts moving at and realised that the formula assumes that the cannon is at (0, 0). So I subtracted the cannon's coordinates from the mouse's coordinates.Note: I blurred out parts that are unrelated to the problem.

Now, when the mouse is anywhere to the left of the cannon, it points almost straight up (270.00009316509215 degrees). When the mouse is anywhere to the right of the cannon, it points almost straight down (89.99999794984215 degrees).

Also, the formula assumes that (0, 0) is in the bottom-left corner instead of the top-left. I'm not sure how to correct this.