I am making a space shooter game and I have come to the point where I need the enemies to follow flight paths. I started my game in Swift and used a follow action on bezier paths. How would you guys suggest to handle this?
This tutorial may help you: https://coronalabs.com/blog/2014/09/09/tutorial-working-with-curved-paths/
Rob
Hi.
Well, first off: tutorial and example
How complex are your paths? Are they long? Were you building them in code or through some editor?
With nearly linear or circular paths you can probably make some simple assumptions, but if they’re pretty general and mix-and-match quadratic and cubic, you might need to build lookup tables of lengths so the enemies aren’t erratically changing speed.
(I’ve got code for this sort of thing, but it’s sort of begging for a friendlier interface on top.)
Will your enemies face in a fixed direction? Or will they track the path and / or the player?
If they track the path you’ll need to be able to figure out the curve’s tangent.
I was building them with paintCode, a piece of software that let me draw a bezier curve and would spit out code to throw in my program. I want my enemy ships to fly somewhere, stop momentarily, maybe face the player’s ship and fire a few bullets, then continue. They would travel in a combination of straight and curved paths. What would you suggest for that?
I have been looking at this tutorial since before you suggested it, but I’m having trouble putting it in terms of being able to set the path with code and not touch.
This tutorial may help you: https://coronalabs.com/blog/2014/09/09/tutorial-working-with-curved-paths/
Rob
Hi.
Well, first off: tutorial and example
How complex are your paths? Are they long? Were you building them in code or through some editor?
With nearly linear or circular paths you can probably make some simple assumptions, but if they’re pretty general and mix-and-match quadratic and cubic, you might need to build lookup tables of lengths so the enemies aren’t erratically changing speed.
(I’ve got code for this sort of thing, but it’s sort of begging for a friendlier interface on top.)
Will your enemies face in a fixed direction? Or will they track the path and / or the player?
If they track the path you’ll need to be able to figure out the curve’s tangent.
I was building them with paintCode, a piece of software that let me draw a bezier curve and would spit out code to throw in my program. I want my enemy ships to fly somewhere, stop momentarily, maybe face the player’s ship and fire a few bullets, then continue. They would travel in a combination of straight and curved paths. What would you suggest for that?
I have been looking at this tutorial since before you suggested it, but I’m having trouble putting it in terms of being able to set the path with code and not touch.