Need help with shooting mechanic in orbit game.

Get help using Construct 2

Post » 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.

Posts: 5
Reputation: 414

Post » 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)
Posts: 756
Reputation: 7,192

Post » Fri Apr 19, 2013 6:32 pm

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

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

obj Spawn shot.sprite;

And so on.
Image Image Image Image Image Image
Posts: 1,166
Reputation: 18,090

Post » 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.

Posts: 5
Reputation: 414

Return to How do I....?

Who is online

Users browsing this forum: Chris118, gamecherry, makkancs and 31 guests