# Need help with shooting mechanic in orbit game.

Get help using Construct 2

### » Fri Apr 19, 2013 6:18 pm

I am currently working on a game which an object orbits the player, and allows the player to shoot the object in a straight line from what angle the object is from the player.

So say if the object is 90 degrees (from the top) of the player, the object will shoot off to the right of the player, if the object is 225 degrees (again from the top) the orb will shoot off down left of the player and so on.

The problem is that I have no idea where to start programming for the shooting mechanic, I already have a build where the object orbits the player, so that part is done, it's just the shooting part that I am stuck on.

Thanks in advance.

B
3
Posts: 5
Reputation: 414

### » Fri Apr 19, 2013 6:31 pm

You can get the angle with expression: angle(player.x, player.y, orbiter.x, orbiter.y). You could spawn a new bullet object at the orbiter object, and set it's angle towards angle(player.x, player.y, orbiter.x, orbiter.y)
B
24
S
9
G
7
Posts: 756
Reputation: 7,322

### » Fri Apr 19, 2013 6:32 pm

It have many possible solutions, one of the simplest is:

conditional:
System > Compare two variables > angle(obj.X,obj.Y,player.X,player.Y) = 90;

Actions:
obj Spawn shot.sprite;

And so on.
B
109
S
24
G
18
Posts: 1,385
Reputation: 22,903

### » Fri May 03, 2013 7:14 pm

Thanks for the replies, I tried doing these and I completely forgot to ask for help for the major part of the mechanic, it is whenever the player presses a button it will shoot off from that angle, sorry.

So when any key is pressed, the orbiting object will shoot off from what angle it is from the player, so say if it is 90 degrees, it will shoot off right from the player and if it is 180 degrees it will shoot down from the player, etc.

Again sorry, but thanks for your input, if you know how I can do this it would be greatly appreciated.

Again thanks in advance.

B
3
Posts: 5
Reputation: 414

Return to How do I....?

### Who is online

Users browsing this forum: Google [Bot], moisesremoto3, SimulacrumPro, tarek2 and 4 guests