Homing Missile v0.46 :
works on Lightwave 7.x

(C) Alexandre Labedade 2006
Last update : 11 / 05 / 2006

Comments , suggestions and bugs reports: earthwormjim@free.fr

Download Script + Demo scene: homingmissile.zip

Happy massive destruction :)

Changes since version 0.45 :
- Removed limitations and alerts...

Changes since version 0.4 :
- Now the parent and the target are kept from the LW parameters, set the parent and the target in the motion panel directly.
- Some optimizations everywhere.
- Bug fix ...

Changes since version 0.35 :
- Modified a bit the target detection, now the missile go straight to the target more easily
- More accurate motion baking (thanks to Fujio)
- Bug fix ...

Changes since version 0.3 :
- Real time preview re-activated.
- Bug fix ...

Test an earlier shockwave demo of this algorythm...


Target : Use the Lightwave native Target in the motion panel of the missile

Parent : Simply parent the missile to any object in the scene. The missile will follow this parent until the 'Startframe' is reached, then the missile is launched.
THE MISSILE MUST HAVE A PARENT, else the script doesn't works.

Speed : Speed of missile in meters / seconds

Turning : Turning Factor from 10 to 100
10 means low turning, so the missile will travel more around the target to touch it
100 means high turning, the missile will go to the target more quickly and will have more 'reactivity' if the target change suddendly it's direction.

Emergency turning : will replace the default turning value when a wall is detected.

Sharp turning near target: will use the Emergency turning value when the missile is near the target, this fix the 'orbit' problem in most cases.

Missile radius: the radius of the bounding sphere of the missile to detect collision with walls and of course, the target.
NB : the X scaling of the target object is used as target radius.... so it's better to use a scaled null parented to your real object, as target for the script

Wall detection interval: the frame interval for wall detection, 0 means the wall are detected at each frame, 50 means walls are detected every 50 frames, etc....

Wall detection: Activate / desactivate the wall detection.
Wall objects must be called : Wall_
Clones are supported, so you can have as many walls as you want.
Walls are detecteds as "spheres to avoid", the X scaling of the object is use to determine the radius of this sphere.
I recommend to use nulls + item shape custom object plugin to view them correctly (like in the test scene)

Forward Launch : the missile will go forward it's starting direction during a short time (specified in seconds) before seeking the target.

Start Frame : specify the launch frame of the missile.

Bake motion : when activated, a key frame will be created every 5 frames for the X,Y and Z channels of the missile. The rotation is controlled by the 'Align to path' LW feature.

Clear Motion : remove all keyframes from X,Y and Z channels from the "startframe" to the end


1) Create 3 objects : a missile launcher, the missile, and a target object
NB : The missile object must be oriented on Z+ axis and parented to the launcher
The target must be specified using the standard Target selector in the motion panel.

2) Assign the missile script to the missile object in its motion options panel (shortcut [m]) : Add Modifier / LScriptRT / load script

3) Be sur to be on frame 0, then open the missile script parameters, set the parameters as you like

4) Check the 'bake motion' option, and clic on 'Clear motion'

5) Clic on 'OK'

6) Clic on the 'Play' button and wait... press the 'Pause' button before the timeline slider loop to frame 0

7) that's All !
I've automated the process :
If the missile explode (on the target or on a wall), the baking is automatically disabled,
from frame 0 to startframe the missile will follow its parent position and rotation, so the script MUST stay activated
from startframe to impact, the missile rotation will swicth to "align to path" automatically, and follow it's baked path to the target.


If the missile doesn't explode, you'll need to desactivate manually the bake option....

TIPS : to have a faster refresh rate, disable the display of "motion path" in the "display options" panel (shortcut d)

Technical limitations :

- The missile object cannot be cloned, you must create another missile and assign the script again....
- To bake correctly the motion, the baking must always be done from frame 0, and motions must be cleared before baking.