Help with trig and stuff please

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I'm fine with trig on paper, but I somehow have a mental block trying to apply it to my game, so maybe you guys can help

    What I need is best summed up in this diagram:

    <img src="http://img15.imageshack.us/img15/9639/helpnq.png">

    In other words, the X and Y of the spot 30 (for example) pixels above the plane, but 'up' is the direction of the plane's floor to roof rather than ground to plane

    So basically I need what to put in the X and Y fields of 'add force towards'.

    Hope you can help

  • AAaaaaand I seem to have figured it out (with the help of Hempuli on IRC) about ten seconds after I post.

    Well, may as well make sure this is the 'best way' to do it.

    In X I have: Sprite.X-cos(Sprite.Angle+90)*30

    In Y I have: Sprite.Y+sin(Sprite.Angle-90)*30

    And 100 in Force.

    Is this the best way?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That is correct, yes, but this formula is actually a little simpler:

    X = Sprite.X + cos(Sprite.Angle - 90) * 30

    Y = Sprite.Y + sin(Sprite.Angle - 90) * 30

    The only change for the Y coordinate is that "cos" is changed to "sin". Everything else stays the same.

  • Thanks.

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