Movable Target

A Movable Target is a dummy object for movement; you can set it's mass, velocity, resistance, and so on; then the program will automatically animate it. For example, assume we want to create a tiger that walk around in scene; we can first create a movtar and set it's movement parameters, then the movtar will automatically 'walk' in scene; we just need set the tiger's position same as the movtar.
As movtar will collide with other objects in scene, it need have a specific shape. Awakening provides three shapes for movtar: box, sphere, and point. The point shape is much faster than other two, so use it as possible; especially for small and rapid objects (like bullet). In the script class of movtar, there are three functions for set it's shape: pointed(), setRadius(),
setBoundingBox(), below is the usage:

 Shape  Code  Explain 

 box

pointed(false); setBoundingBox(bbox)

box is independent of radius

 sphere

pointed(true); setRadius(number)

sphere is a point that radius>0

 point

pointed(true); setRadius(0)

just set pointed to true is not enough

A movtar do collide with ocean, terrain, surface, static mesh, mobile (movtars do not collide with eachother by default). In collision detection, a surface treat as a plane, a mesh treat as a box; and ignore all objects with 'no clip' style.
When collision happen, the program will call movtar's callback function -
OnCollide(); You can do something for collision in this function, like make a sound, make a spot, etc.

To create a movtar, use the createMovTar() function of the scene class; please remember use the deleteMovTar() function to delete unused movtars, because movtars is quite a few load on CPU.

Example :

-- create a movtar with sphere shape
local m=scene.createMovTar()
m.pointed(true)
m.setRadius(5)

-- play sound when collision happen
m.OnCollide = function(ptrace)
        local t=trace.new(ptrace)
        PlaySound('\\hit.wav')
end

-- delete the movtar
scene.deleteMovTar(m)