Using splines to control spaceship physics/AI?

Started by
0 comments, last by HateDread 10 months, 2 weeks ago

I've posted previously about spaceship control (https://www.gamedev.net/forums/topic/714454-using-physicsai-to-maneuver-a-spaceship-through-a-point-with-a-specific-velocity/)​ and since then have been looking at splines for spaceship control.

Basing my current attempt upon this answer here: https://gamedev.stackexchange.com/questions/162030/how-can-i-maneuver-an-ai-pirate-ship-for-a-sea-battle/162038#162038,​ I create a bezier curve with

  • T = estimated time (currently just dist/velocity)
  • V0 = velocity at the start
  • VT = velocity goal (i.e. velocity we want at end of the curve)
  • P0 = Ship pos
  • PA (control point) = P0 + (⅓T * V0)
  • P1 = Destination pos
  • PB (control point) = P1 - (⅓T * VT))

This seems to make some sense, and means that I can move the control points depending on velocity, giving me the ability to specify the final velocity I want, which was one of the hard parts.

I'm having a few issues though;

  1. The ship should “thrust" in a direction to maneuver, applying an acceleration along its forward axis. Ignoring the rotation time, when a spline gives us velocities and accelerations along it, should we either
    1. Calculate a deltaV based on velocityOnCurve - currVelocity and push in that dir? Or
    2. Take accelerationOnCurve at our current time and just blindly accelerate in that dir, trusting the spline
  2. If I want to constantly recalculate my spline to handle that we likely do not perfectly estimate T, other impacts/imperfections etc, does that not mean my ship should constantly look at the spline at 0.0? If so, it seems to break things - we accelerate, which pushes PA control point forwards, which makes us accelerate more, etc, and we never actually turn.
  3. I don't understand how to apply constraints to this solution - for example the ships have a max speed and a max acceleration. I don't think I can constraint a spline to these right?
    1. So at least if I can detect when the max velocity / max acceleration on the spline exceeds the limits, I can “slide” the target point further along the line defined by P1 → P1 + VT * infinity until the max velocity/acceleration of the spline satisfies my constraints, basically pushing the point that we get on that line into the future until the ship doesn't have to accelerate beyond its limits.
  4. I tried simplifying things by calculating a spline once with my estimated T value, and using that each frame to calculate pos/vel/accel. If I set my ship to the pos at currT along the spline, it works okay, but if I try to use the velocity or acceleration, it shoots off into infinity. How does one… actually use the velocity/accel? Are they in some kind of space and need to be converted back to real space or something? The numbers look insanely high (and that's with a pretty high estimated T value that isn't exactly requiring the object be moving that fast, so it is extra surprising to see).

Appreciate any insights to these questions! It's getting there, I'm just not used to splines and don't fully get how to apply the numbers I'm getting from them to a physical world / control.

Thanks!

Advertisement

This topic is closed to new replies.

Advertisement