[How do i] Math for Artillery

0 favourites
  • 14 posts
From the Asset Store
25 high-quality tanks / artillery. This asset is perfect for a top-down game.
  • Hello,

    im not that good at math, and construct 2.

    And now i want to simulate an artillery.

    First, i need to simulate the angle the barrel is at.

    Second, i need the correct gravity and acceleration.

    If i have those two factors it should work out.

    I have something like enemy.X - (enemy.x/2) (repeat the same for y)

    in the head for the angle of the barrel.

    but since not every shot is landing correct, this isnt working out.

    How should i handle these two factors so i could simulate an artillery?

  • Anyone know?

    really frustrating ...

  • You're not very clear. Do you want a formula for hitting a specific target? Or do you just want your artillery to shoot properly?

  • i want it to hit a specific target,

    better said, to hit a specific X,Y Point.

    and the problem is setting the barrel of the Artillery unit in the right angle to do this.

  • I recommend to read this page about trajectories:

    http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html

    It can be little hard to understand at first, but this page really helped me to do trajectory calculations for 3d space.

  • Sry but im not that good at vector, i cant even make tests how far the projectile would fly, i tried:

    if Projectile.Y = Barrel.Y , then set global variable Distance to Projectile.Y - Barrel.Y

    But that wont work, i dunno why...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So when the y-coordinate of the projectile is the same as the y-coordinate of the barrel set the global variable to 0(if they are both the same deducting them will always be 0)?

    I don't think this is what you are trying to do. But this is what you are doing.

    Now the question is what are you trying to do?

  • oh sry i meant Proctile.X - Barrel.X

    i tried to figure out how far away the bullet would fly so i could calculate the ca. Angle of the barrel if the enemy would be that far away.

    this was my second option.

    But of course i stould would love to calculate the Angle ingame without having it pre-defined.

  • good link, but i dont understand a thing in that CapX, i only want the end destination, i dont care about how it flies, just where it lands.

  • To know where something lands, you will have to know how it flies.

  • sound logic, but when i dont understand how it flies, i cant understand how to find out where it lands.

  • Sounds logic. So it seems you should learn to understand how it flies.

    On the first page there is a link to a page that explains about trajectories and a link to a capx that calculates trajectories.

    These will be very helpfull to learn what you need to learn.

    You could also choose to create a custom movement, so you can make the trajectory simpler and the landing spot easier to calculate.

  • good idea with the custom movement, im going to look at it when i finally get the 140 beta update, its not on steam yet...

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