How do I calculate angle, speed, gravity of a bullet to a position [.capx]?

0 favourites
  • 5 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • Hello,

    I have an object (enemy) wich change position ... and evey X seconds it spawn an object to another position (player).

    i want to create a sort of IA that calculate the angle, gravity and speed of that spawned bulet to colloide another fixed object

    Here is what i have done but i can fix it

    easyupload.io/q6ndla

    Help will be much appreciated ... thanks

  • Don't know if that helps. It calculates only the distance for the same height (y.coordinate are the same) of player and enemy.

  • Don't know if that helps. It calculates only the distance for the same height (y.coordinate are the same) of player and enemy.

    Thanks a lot for your reply

    but you misunderstand me probably because of my bad english

    the blue object (player) never change position

    the yellow object (ennemy) is changig position and spawning an arrow (bullet with gravity and speed)

    i want to manipulate those (gravity,speed) in order that the arrow colloide everytime with the player (blue object) even if the ennemy (yellow) change position.

  • You can do it with three variables vx, vy, and t. t is the number of seconds you want it to take to hit the player and vx,vy are the horizontal and vertical velocities we will calculate from t. anyway the arrow launch will look like this:

    create arrow at (enemy.x, enemy.y)

    t = 1

    vx = (player.X-enemy.X)/t

    vy = (player.y-enemy.y)/t-arrow.Bullet.Gravity*t/2

    arrow: bullet: set speed distance(0,0,xv,vy)

    arrow: bullet: set angle of motion to angle(0,0,xv,vy)

    dropbox.com/s/68mhi9hrwsjf7fl/bullet_proj_calc.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can do it with three variables vx, vy, and t. t is the number of seconds you want it to take to hit the player and vx,vy are the horizontal and vertical velocities we will calculate from t. anyway the arrow launch will look like this:

    create arrow at (enemy.x, enemy.y)

    t = 1

    vx = (player.X-enemy.X)/t

    vy = (player.y-enemy.y)/t-arrow.Bullet.Gravity*t/2

    arrow: bullet: set speed distance(0,0,xv,vy)

    arrow: bullet: set angle of motion to angle(0,0,xv,vy)

    https://www.dropbox.com/s/68mhi9hrwsjf7fl/bullet_proj_calc.capx?dl=1

    great ... thanks

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