Hey folks.
i have a math problem :D
Abstract:
A playership (physics) flys at a velocity. It can shot. Shots have the bullet behavior. The shots speed is e.g. 500 when the playership has 0 velocity. Lets say the playership flys at 45degrees with a velocity of 250 and shots. then i want the shot to fly with a velocity of 750 in this direction.
Lets say the playership turns 180 Degrees, but still drifts with a 250 velocity in the same direction as before. Then i want the shot to fly at the new direction the playership is facing with a velocity of 250.
How do i do that?
Here is what i got so far but there must be something wrong with my thinking as shots are going crazy fast as soon as the ship moves:
Set Bullet speed to
Self.shotspeed+((playership2.angle)*playership2.physics.velocityX + sin(playership2.angle)*playership2.physics.velocityY)
I also made a very professional grafic to clarify what i want to archive:
1st panel: ship flys at 45 degrees with 250px/s. Shots should have a velocity of 500pixel/s + shipspeed.
2nd panel: Ship flys in the same direction with same speed but faces the other direction. Shots should fly at a speed of 500px/s - shipspeed in at the ships angle
3rd panel: Ship has no velocity, shots should fly in the direction the ship is facing at 500px/s (normal shot speed)
4th panel: ship is drifting with 100px/s at 200degrees, ship is "looking" at an angle of 225 degrees. Shot speed should be 500 + the ships velocity at this angle.
Any help is highly apprechiated :) thank you in advance!
Kind regards
Joschi