How do I make bullets follow mouse accurately?

Get help using Construct 2

Post » Mon Jul 27, 2015 6:37 pm

Hello everyone, I'm currently working on a spaceship shooting game, and I've stumbled on a problem.

The ship shoots lasers toward the mouse.
When I shoot while being stopped, the lasers go on the right direction (as shown on the image below):
Image

However, if I'm moving and I shoot, the lasers will stay behind like shown below.
Image

I know that's what would normally happen, but it doesn't work very well for a game, since the player can't aim correctly to enemies. How can I fix it?

You can download the capx if you wish.
http://www.mediafire.com/download/q5a3p ... usher.capx
B
15
S
5
G
7
Posts: 84
Reputation: 4,054

Post » Mon Jul 27, 2015 6:56 pm

I know it's pretty much physically impossible but you will need to add momentum to your laser. Einstein probably turned in his own grave as I said that. xD
B
74
S
31
G
26
Posts: 994
Reputation: 20,198

Post » Mon Jul 27, 2015 7:21 pm

Haha (Einstein doesn't understand gamedesign xP)
I tried to add accelaration but the bullets end up being too fast.
Have you tried the capx?
B
15
S
5
G
7
Posts: 84
Reputation: 4,054

Post » Mon Jul 27, 2015 7:28 pm

Just tried it, however, you probably cut too much content, I can only find the 4 movements events, no "laser firing" at all...
B
74
S
31
G
26
Posts: 994
Reputation: 20,198

Post » Mon Jul 27, 2015 7:56 pm

Oops, you're right, it was an old save, re-uploaded it:

http://www.mediafire.com/download/q5a3p ... usher.capx
B
15
S
5
G
7
Posts: 84
Reputation: 4,054

Post » Mon Jul 27, 2015 8:35 pm

Add a Car movement or 8 direction behavior to your bullets, remove any acceleration and inputs. Upon the creation of your bullets, set its new behavior VectorX and VectorY to your ship's Car.VectorX and VectorY. It should give your bullets the ship's velocity.

edit: After a bit of testing, it seems the Custom Movement behavior would be a better idea, since this behavior ignores solids (the ship being one).

Here's the modified capx : https://dl.dropboxusercontent.com/u/700 ... usher.capx
B
74
S
31
G
26
Posts: 994
Reputation: 20,198


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 42 guests