Missile ejection then ignite code needed

I built this for a hover tank prototype a while back. The way I built it was “kick” the missile out with an ejector (a single force-impulse) and start a timeline that animates when the engine ignites.

Once the engine ignites, I run the physics simulation for the missile in Tick(). I don’t turn off gravity; instead I have the missile controller apply some amount of force “upwards” to counteract the gravity. I ended up building a control system very much like what you’d get for a real homing missile :slight_smile: The basics are a simple PID controller that takes course and heading-to-target as input, and outputs control surface angles. The “I” part of the equation is what ends up compensating for gravity.

To look good, I also had the missile seek a “higher point” for the first half of the flight trajectory, rather than aim straight for the target; else there’s real danger of colliding with other things on the ground. This logic went into the “determine where the target is” code, which would add a Z value to the desired target position for the first half of the trajectory.

You don’t even need many tweakables. What you need are:

  • ejection impulse magnitude
  • duration until ignition
  • propulsion force
  • control surface area (turns into torque magnitude)
  • P, I and D tuning constants
  • amount of Z to add for first part of trajectory
  • what percentage of the trajectory uses the added-Z