DemoProductions / shmup

3 stars 2 forks source link

Player shooting #10

Closed flip40 closed 8 years ago

flip40 commented 8 years ago

Adds player shooting #4

PewPewPew (minus the sound effects)

Bullet direction is based on the way the player is facing (sort of), you can test it by rotating the player, the bullets will fire in the new direction. To be a bit more specific on the "sort of" I mentioned, the bullets sprite is actually sideways, which means the bullets have been rotated 90 degrees left when spawned to appear to face the correct direction, then (due to being turned) actually then move to the right. You can see this in the code, so this should clear up why it is rotated and then moving to the right.

Actually I decided having the bullet rotate and move to the right is silly and instead split the bullet into the parent (with most of the bullet components) and a child (with the sprite, and likely hitbox when added so it can form fit itself to the sprite). The child was rotated by 90 in the prefab so that the sprite faces the correct direction. Code now just sets the bullet (parent) to the same rotation as the player, and moves up (forward is into the screen).