Projectile/Arc Trajectory

  • Can anyone help me with these two things that I need for my game? They are almost the same thing, projectile/arc trajectory, but I don't know how to implement it.

    1. An enemy AI which randomly jumps between 3 positions (left, middle, right) before executing an attack.

    2. Enemy attack which throws an object to the Player position.

    Thanks in advance!

  • the easiest way would probably be to give the thrown object bullet behavior with a strong gravity, then work out the bullet speed required for each location.

    is the enemy above the player? or on the same level? and how much can the player move around?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It’s a boss area.

    The boss randomly jumps between 3 positions (left, middle and right). Those 3 positions are fixed.

    But the throw attack is set to the Player’s last position when the attack triggers.

  • Hi!

    The important thing while calculating trajectory is that you need to figure out which parts of the equation you want to set as constants. This is my example using the "time of flight" and "gravity" as constants. You might want to play around the the trajectory equation if you want to for example change the angle of trajectory or Vx component to be the primary constant.

    dropbox.com/s/vg0shir90yxwtcz/Trajectory.c3p

    Useful link for the equations:

    omnicalculator.com/physics/trajectory-projectile-motion

  • Thanks guys esp. Von Perkele! I used what you sent me and tweaked it to suit my needs. I understand everything except the Vy formula. Is it okay if you explain it to me or point me to the formula of where you got it? Thank you very much!

    Edit: Tagged the wrong guys so I deleted my replies. Still new here and I have no idea how to tag people with spaces in their names Haha.

  • You get the Vy from this equation:

    y = h + Vy * t - g * t² / 2

    If you know "t" (time of flight), then y = 0 when the projectile has flown "t" time. Or in other words, the projectile hits ground (y = 0) after time (t) has passed. So you can insert y as 0 and your chosen t to the function.

    From this formula you eventually get:

    Vy = gt/2 - h/t.

    If your projectiles are thrown "up" or towards the top of the layout you need to take the opposite of this function since in Construct that is negative speed (y is decreasing while traveling to that direction), so we use:

    Vy = -(gt/2 - h/t).

    I actually improved my example. In this version you can also choose to manipulate Vx since I realized that might usually be more useful that using t as a constant. Remember you could also calculate the time of flight or Vx based on the distance between the player and enemy or any other factor you want, which will give you more tools to tweak the trajectory just the way you want it.

    Improved example:

    dropbox.com/s/lrnqt7iy21t82t6/Trajectory_Improved.c3p

  • This is a huge help for me. Thank you so much!

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