Uh oh. Here's a problem that's currently got me stumped:
This game is best described as a top-down 2D spaceship game, and the ships move via waypoints. AlignToVector works perfectly in this setting, except for in one rare scenario. If the waypoint is set exactly (pixel-perfect) in a straight line behind the ship (see crude ASCII-illustration)...
/_\
w
OR
w |>
...then the ship, instead of turning left or right, turns backwards into the Z axis to get to the waypoint. As the entire game occurs on the xy plane, this is a very serious problem, and I have found that after this occurs, no amount of waypointing will correct the ship and bring it back onto the plane. Curiously enough, this occurs even though I'm using AlignToVector with the vector_z# variable set to zero.
I've tried correcting this with if statements, but they can only reasonably work if the ship is facing either directly up, down, left, or right, and - though I have yet to produce it - I am positive that the effect could occur when the ship is facing any angle in between as well. The if statements don't work for other reasons as well that I don't want to explain in this post, as they don't seem relevant right now.
Basically, I'm wondering: is there any relatively simple solution that will keep my ships in the xy plane at all times and still allow me to use AlignToVector to bring my ships to waypoints. I could of course hard-code a function bringing ships to waypoints with angles and TurnEntity or something like that, but AlignToVector is much simpler and probably more efficient, and I'd really like to stick with it if I can.
Any ideas?
This game is best described as a top-down 2D spaceship game, and the ships move via waypoints. AlignToVector works perfectly in this setting, except for in one rare scenario. If the waypoint is set exactly (pixel-perfect) in a straight line behind the ship (see crude ASCII-illustration)...
/_\
w
OR
w |>
...then the ship, instead of turning left or right, turns backwards into the Z axis to get to the waypoint. As the entire game occurs on the xy plane, this is a very serious problem, and I have found that after this occurs, no amount of waypointing will correct the ship and bring it back onto the plane. Curiously enough, this occurs even though I'm using AlignToVector with the vector_z# variable set to zero.
I've tried correcting this with if statements, but they can only reasonably work if the ship is facing either directly up, down, left, or right, and - though I have yet to produce it - I am positive that the effect could occur when the ship is facing any angle in between as well. The if statements don't work for other reasons as well that I don't want to explain in this post, as they don't seem relevant right now.
Basically, I'm wondering: is there any relatively simple solution that will keep my ships in the xy plane at all times and still allow me to use AlignToVector to bring my ships to waypoints. I could of course hard-code a function bringing ships to waypoints with angles and TurnEntity or something like that, but AlignToVector is much simpler and probably more efficient, and I'd really like to stick with it if I can.
Any ideas?