Oh, I just remembered check out the bloodrush game we made for the idevgames contest, the red blood cells move out of your site then teleport behind you and keep doing that so it looks like there's lots when there's really only a few.
(it's not gory, though it should be :P. It's about fighting off viruses. Just find the red blood cell script.
Code:
var anim, location;
function construct(obj)
{
obj.model.on=true;
obj.model.name='bloodcell';
obj.model.lit=DIM3_MODEL_LIT_VERTEX;
obj.model.offset.x=Math.round(Math.random()*6000)-3000;
obj.model.offset.y=-Math.round(Math.random()*4000);
obj.size.x=100;
obj.size.z=100;
obj.size.y=100;
obj.size.weight=1000;
obj.setting.contact=false;
obj.setting.hitBox=true;
obj.setting.damage=true;
obj.turnSpeed.facingWalk=5;
obj.turnSpeed.motionWalk=5;
obj.forwardSpeed.walk=Math.round(Math.random()*40)+50;
obj.forwardSpeed.acceleration=1.0;
obj.forwardSpeed.deceleration=1.2;
}
function spawn(obj)
{
var nodeId,nodeName;
location=0;
anim='turn'+Math.round(Math.random()*2+1); //utility.random.getInteger(1,3);
obj.model.animation.start(anim);
// obj.model.animation.start('turn1');
obj.model.rotate.x=Math.random()*359;
obj.model.rotate.y=Math.random()*359;
obj.model.rotate.z=Math.random()*359;
obj.watch.start(30000);
obj.event.startTimer(50,0);
nodeId=map.node.nearest(obj.position.x,obj.position.z,obj.position.y,null,obj.angle.y,null,180,10000);
if (nodeId==-1) return;
nodeName=map.node.getName(nodeId);
// obj.forwardSpeed.walk=35;
obj.motionVector.walkToNode(nodeName,obj.setting.getParameter(location),0);
location++;
}
function bringBackToPlayer(obj)
{
var xpos, zpos, ypos, angle, node;
angle=utility.angle.sub(map.object.getAngle(map.object.findPlayer()).y,180);
xpos=map.object.getPosition(map.object.findPlayer()).x;//+Math.round(Math.sin(angle/180*3.1415)*2000);
zpos=map.object.getPosition(map.object.findPlayer()).z;//-Math.round(Math.cos(angle/180*3.1415)*2000);
ypos=map.object.getPosition(map.object.findPlayer()).y;
// obj.position.place(xpos,zpos,ypos,angle);
// idNode=map.node.nearest(obj.position.x,obj.position.z,obj.position.y,null,obj.angle.y,180,0,50000);
node=map.node.nearest(xpos,zpos,ypos,null,utility.angle.add(obj.angle.y,180),90,15000,30000);
// iface.console.write(map.node.getPosition(node).x);
if (node!=-1) {
obj.position.place(map.node.getPosition(node).x,map.node.getPosition(node).z,map.node.getPosition(node).y,obj.angle.y);
obj.motionVector.walkToNode(map.node.getName(node),obj.setting.getParameter(location-1),0);
}
// obj.event.sendMessage(DIM3_MESSAGE_TO_PLAYER,'Player',1);
}
function event(obj,mainEvent,subEvent,id,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
construct(obj);
return;
case DIM3_EVENT_SPAWN:
spawn(obj);
return;
case DIM3_EVENT_DAMAGE:
spawn.particle(obj.hitPosition.x,obj.hitPosition.z,obj.hitPosition.y,'JoeFoe Blood');
bringBackToPlayer(obj);
return;
case DIM3_EVENT_WATCH:
if (subEvent==DIM3_EVENT_WATCH_OBJECT_FAR && obj.watch.objectIsPlayer) bringBackToPlayer(obj);
return;
case DIM3_EVENT_PATH:
if (subEvent!=DIM3_EVENT_PATH_DONE) return;
obj.motionVector.walkToNode('join'+location,obj.setting.getParameter(location),0);
location++;
return;
case DIM3_EVENT_TIMER:
if (map.object.getDistance(map.object.findPlayer(),obj.position.x,obj.position.z,obj.position.y)>50000) bringBackToPlayer(obj);
return;
}
}