- animated aliens that are programmed to behave like living beings
- all based on one movie clip playing back randomly and reactively (show dude clip)
- randomness within a limited set of actions creates crowd behaviour
- fundamentally, the alien code works much like the text animation code
- each alien has a start point
- each alien follows a (moving) destination--the mouse pointer
- each alien has a speed (it just varies depending on distance from destination)
- each alien is created by
makeDude(), which assigns random size, speed, movement tolerance levels (like spawnTitle() created letters).
- aliens aren't created all at once. timing is dynamic--the more beings there are on screen, the less likely a new one will spawn.
dudeFollow() moves aliens towards the mouse pointer if necessary; otherwise, instigates idle actions
- zones dictate speed and animation loop: runDist, jogDist, walkDist, idleDist (creates dispersion)
- here we set the dude's animation loop and speed for each zone:
if (dist <= dude.idleDist) {
// ...assign random idle behaviour
} else {
if (dist > dude.runDist) {
dude.gotoAndStop("running");
var distancePerSecond = dude.runSpeed;
} else if (dist > dude.jogDist) {
dude.gotoAndStop("jogging");
distancePerSecond = dude.jogSpeed;
} else {
dude.gotoAndStop("walking");
distancePerSecond = dude.walkSpeed;
}
var moveAmount = distancePerSecond * numSeconds;
- if a dude is in the idle zone, then do idle behaviours: sit, jump, kneel, idle (look around)
var randomDudeAction = myRandom(0, 100);
if (randomDudeAction < 20 && !dude.busy) {
// Only jump at the mouse if the dude's really close to it...
var mouseYdist = dude._y - _root._ymouse;
if (dist < 15 && (mouseYdist > 25 && mouseYdist < 50)) {
dude.gotoAndStop("jumping");
dude.busy = true;
} else {
dude.gotoAndStop("idle");
dude.busy = true;
}
} else if (randomDudeAction < 30 && !dude.busy) {
dude.gotoAndStop("kneeling");
dude.busy = true;
} else if (randomDudeAction < 50 && !dude.busy) {
dude.gotoAndStop("idle");
dude.busy = true;
} else {
if (!dude.busy) {
dude.gotoAndStop("sitting");
dude.busy = true;
}
}
- use
dude.busy to prevent dude from starting something new while he's busy doing something else.
- stutter steps between jog and walk
- inspiration: conker's character animation (7.2mb)
- context-sensitive idle actions: juggling, watching butterflies, shaking water off
- smooth transitions between running/walking/jumping/etc
- conker looks at you when camera points to his face.