How do I move bullets

Get help using Construct 2

Post » Mon Jul 03, 2017 3:21 am

Quick question

I have a player object that moves and rotates (space ship behavior). When the object is moving and then rotates and fires while moving how do i get the bullets movement to match the player objects movement?

In the example picture below

The player is moving to the right as shown by the red arrow

The player has rotated to the left to fire. When it fires its bullet it follows the green line

How do i get the bullet to fire along the blue line (gaining the same directional movement(red arrow) as the player)

Image
B
23
S
11
G
4
Posts: 69
Reputation: 3,439

Post » Mon Jul 03, 2017 8:17 am

Well, if you set the bullets and the spaceship facing the same direction on their original sprites, i think you can then set the projectile angle to the player's angle every time you create one. If you are already doing that and the behavior is still weird like you are describing maybe you should upload part of your code, or even better a capx. so we can take a better look on what's going on.

Now, for the bullet to gain the same directional movement as the player. You could try and add some X and Y variables inside the bullet object and set them to zero, and then change them to specific values depending on the keys the player is pressing. And while they are on the screen you change their X and Y position values every tick. So for instance, the player is pressing to the right, the X would be 5 and the Y 0 so every tick the bullets fired would move to the right.... This might work weird depends how the ship moves, but I suggest you to start from there and improve it later.

Hope it helps o/
B
17
S
7
Posts: 280
Reputation: 2,522

Post » Mon Jul 03, 2017 5:17 pm

Set this up quick

Move with w,s,a,d and shoot with space.

https://www.dropbox.com/s/qooa7a5ix3yhr ... .capx?dl=0
B
23
S
11
G
4
Posts: 69
Reputation: 3,439

Post » Mon Jul 03, 2017 9:29 pm

found this but unfortunately the capx is broken

viewtopic.php?f=147&t=149751&p=949434&hilit=trigonometry+bullet#p949434
B
23
S
11
G
4
Posts: 69
Reputation: 3,439


Return to How do I....?

Who is online

Users browsing this forum: beohs, ignaciosimo, nickar and 36 guests