Angles and impulses.

0 favourites
  • 3 posts
  • I'd like to start by saying that I've learned so much the past few months from this forum! I hope to know enough soon to start contributing/giving back to this fine community! But that's a long ways away me thinks, as there is still much for me to learn.

    Like angles.

    Disclaimer: I never took maths in high-school, or beyond. I've only just started to come to grips with the most basic calculations. Coding in python and working with Construct 2 is really a fine way to learn how to do math at a later age. So please consider this in your answer: I'm a dumbass.

    The question:

    For the sake of explaining what I'm trying to do, please imagine the adept's "pull" skill from the "Mass Effect" series. Then imagine a 2D side-scroller.

    A projectile is launched at an angle, from the player towards the enemy/object. Upon collision, the enemy/object is then propelled towards the direction the projectile just came from.

    I used to solve it like this:

    When (push) collides with (object) Apply impulse (value) towards angle (player.x, player.y).

    Simple enough eh? Its a rather limited approach though:

    I'd like to be able to control the arc of the projectile (any clever thoughts on that will also be much appreciated) so then the player's position is no longer the origin of the projectile.

    How would you solve this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In construct you have many choices.

    you could use the projectile's angle - projectile.angle

    or if the projectile is a bullet - projectile.bullet.AngleOfMotion

    you could use the angle between object and projectile - angle(object.x,object.y,projectile.x,projectile.y)

    And there are more options depending on behaviours used.

    Also you could mess around with sin and cos, but I have never needed those myself.

  • To control the arc I would choose to use custom behaviour.

    You could set it so that on every step the y-speed decreases.

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