I have a player with a Platform behavior and a cannon that rotates towards the mouse and is pinned to the player.
I want to make the rotating cannon shoot towards the mouse, and I want to adjust the speed of the projectiles it shoots so that they're faster by as much as the player was moving in any direction when they were fired.
So to be able to adjust for the player's motion, I'm not using the Bullet behavior, I'm using VX and VY instance variables, in hopes of adding player.Platform.VectorX and VectorY to the VX and VY of the bullet, instead of using angle and speed.
But I haven't gotten to the addition of the player's motion yet, because I don't even have it shooting towards the mouse correctly.
Here's how I have it now:
- System - Every tick - Cannon - Set angle towards Mouse.X, Mouse.Y
- Mouse - On Left button clicked - Spawn projectile on layer cannon.LayerNumber(image point 1)
- Projectile - On Created -
=Set VX to cos(angle(cannon.X,cannon.Y,mouse.X,mouse.Y)*pi/180)*Self.Speed
=Set VY to sin(angle(cannon.X,cannon.Y,mouse.X,mouse.Y)*pi/180)*Self.Speed
- System - Every tick - projectile - Set position to x:Self.X+Self.VX*dt y:Self.Y+Self.VY*dt
I thought that should make it shoot the projectiles towards the mouse, but it doesn't. They go straight to the right instead.