The one year game develpoment duel



Isometric Projectile Trajectory in Swift and SpriteKit

How do you launch a catapult, grenade, arrow, or any other projectile in an isometric world? I had to joy of figuring that out over these past two days, and I thought I would share. Before jumping in, let me point out that the code below is for my specific use case, and is not a full featured framework. So, you’ll still have to understand the concepts, but if you’re Googling for help this will hopefully get you on the right track.

To accomplish the above, here is what has to happen:

  • Load up your high school math brain.
  • Bookmark HyperPhysics Trajectories. This tool will be your math checker and teacher.
  • Figure out a meters to pixels conversion that works for your game. 50px / meter works for mine.
  • Supply a start point, end point, and launch angle. The example above is 60 degrees.
  • Note that my degreesToRadians and distanceTo functions below come from SKTUtils.
  • Call the function below, and run the returned SKAction on your projectile.
2 of you did not hold your tongue!
  1. A test message live.

    • A nested reply live

Speak Freely

Thank you

Your comment will be published once it has been approved.

Click here to see the pull request you generated.