Propel player at angle based on bullet firing

Get help using Construct 2

Post » Mon Jul 18, 2016 3:51 pm

I've got a circular character with a cannon attached. The player can "roll" this character back and forth, changing the orientation of the cannon.

When the cannon is overlapping the ground and the player shoots, I simulate a "jump" command on the platform behavior, making it seem like the player is being propelled upward by the cannon blast. The only problem with this is that it's always a straight up jump, regardless of what angle the cannon is pointing in.

What would be the best way to make this jump angled based on the cannon position? I assume I'd need to manipulate some combination of vector x/y, but I don't know how to calculate that in real time based on the angle of the player (who has the cannon pinned to it).

Image
B
14
S
2
Posts: 73
Reputation: 794

Post » Mon Jul 18, 2016 5:24 pm

Jump will only go up. You'll need to either apply a bullet behavior at angle, or physics impulse depending on how you have your physics set up.

To get the angle from your cannon to your character, use the expression angle(cannon.x,cannon.y,character.x,character.y).
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Mon Jul 18, 2016 7:01 pm

Should it, a question, not propell away from the turret ?

Jumping towards the turret:
https://www.dropbox.com/s/9ho9dfs9q5djv ... .capx?dl=0

Ofcourse you have to keep the player from jumping when hit, means non default keys, i did not do all that in this example.

Still think it is jumping away from the turret. But thats kinda the same example.

Fine ?
B
33
S
18
G
28
Posts: 2,474
Reputation: 20,912


Return to How do I....?

Who is online

Users browsing this forum: dahu, ketramtu18, Syazanie Amirin and 8 guests