Help with some simple-ish math. =)

Get help using Construct 2

» Sat May 04, 2013 5:26 am

So my game has heavily gravity effected bullets, and what I do for the enemies to make them compensate for their aim is place a position between the player and them, and then put it into the air by some amount of their total distance, so if all the gravities and whatnot are balanced, the bullets should arc towards the player no matter what the distance.

BUT I don't fully understand the math I am doing and I have run into a bug that only happens when the player goes on the right side of the enemies.

Desired effect on the left (somewhat)

and here is my math:

I have basically no idea what I am doing on the second line but it almost works...
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

» Sat May 04, 2013 5:40 am

@Sushin
If I really understand what you do, I guess Y expression should be using these:

Distance Player/FootSoldier : abs(Player.X - FootSoldier.X)
Y origin: FootSoldier.Y
Ratioxy: a constant which you can use to adjust the height (4 maybe)
so, I guess you can try:

-abs(Player.X - FootSoldier.X)/Ratioxy + FootSoldier.Y

Not sure It will work though

EDIT: If FootSoldier and the player aren't at the same Y, the formula should not work really greatAphrodite2013-05-04 05:51:45
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150

» Sat May 04, 2013 5:55 am

Thanks. I took out the "- FootSoldier.Y" part and it works well, although the problem now is that when the player is next to the foot soldier, the crosshair is as high as it can get, but what it really should be doing is getting lower when the player gets closer.
So it works but I need the effect to be reversed...
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

» Sat May 04, 2013 6:24 am

@Sushin

Right after I realized my mistake, in C2, the Y axis is reversed compared to the One I am using in mathematics ^^"':

-abs(Player.X - FootSoldier.X)/Ratioxy + FootSoldier.Y

this should work better
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150

» Sat May 04, 2013 6:38 am

Ah. Thank you. That's exactly what I wanted. =)
B
10
S
3
G
3
Posts: 234
Reputation: 3,467