Help with some simple-ish math. =)

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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)

    <img src="http://puu.sh/2Mrap.png" border="0" />

    and here is my math:

    <img src="http://puu.sh/2Mri5.png" border="0" />

    I have basically no idea what I am doing on the second line but it almost works...

    Any advice? =)

  • 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 great

  • 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...

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ah. Thank you. That's exactly what I wanted. =)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)