# Calculate the angle to fire to hit enemy

Get help using Construct 2

### » Thu Jan 17, 2013 11:21 pm

@sqiddster The idea was to have a space ship that could move around freely. The player ship's turrets would shoot the enemy weapons if it got within a certain range. I was thinking of basing it on vector rather than speed, as the turrets didn't have movement (so to speak) even though they do move.

I've tried it with @Ashley / @Yanns code, but they all seemed to aim *dumb*.

If the ships were just moving I could base the speed, etc off of the ship... but as you said, it's the rotation that seems to mess things up.

This one got us beat?
B
95
S
19
G
8
Posts: 1,031
Reputation: 12,513

### » Thu Jan 17, 2013 11:36 pm

It's certainly possible, but I'm not able to work out the formulae. I'm sure some of the math geniuses here could do it but it will certainly be difficult!
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,739

### » Fri Jan 18, 2013 10:37 am

Thanks for your help @sqiddster! I'll keep having a go, and will post if I have any luck!
B
95
S
19
G
8
Posts: 1,031
Reputation: 12,513

### » Tue Jun 09, 2015 12:56 pm

sqiddster wrote:Science!

It works rather well, if I may say so
sqiddster2012-12-11 13:27:30

Hello I know it's been some time , but im working on something similiar to what you are describing and the dropbox link you provided seems to be dead (which is natural after so long). I was wondering if you can re-upload the above .capx (provided you still have it).

thanks you!
B
5
Posts: 3
Reputation: 233

### » Tue Jun 09, 2015 2:33 pm

I did get this working in the end, but don't think I have an example. I could probably delve into the old program and have a look, unless the other guy replies with his link.

My finished game is here https://www.scirra.com/arcade/strategy-games/korelos-34

Doesn't work for me, I still get a white screen, but apparently it works for others. Fly out a bit and get some enemies to fire at you and you should see that they're fairly accurate, although everything is moving so they pretty much do a 'rough guess' I think.
B
26
S
6
G
4
Posts: 456
Reputation: 5,858

Previous