Q:
How do you get one actor to follow another?
A:
Here's a modified action from the A5 demo
project.
entity* robot_boss;
action robot_master
{
robot_boss = my;
// put the rest of your code here
// ........
}
action robot_slave
{
var slave_target;
var slave_speed;
while (robot_boss == null) {wait (1);}
while (1)
{
my.tilt = 0;
slave_target.x = robot_boss.x - 50 * cos (robot_boss.pan);
// stay 50 quants
slave_target.y = robot_boss.y - 50 * sin (robot_boss.pan);
// behind robot_boss
slave_target.z = robot_boss.z;
slave_speed.x = 7 * time;
slave_speed.y = 0;
vec_set (temp, my.x);
temp.z -= 1000;
trace_mode = ignore_me + ignore_sprites + ignore_models
+ use_box;
slave_speed.z = -trace (my.x, temp);
vec_set (temp.x, slave_target.x);
vec_sub (temp.x, my.x);
vec_to_angle (my.pan, temp);
if (abs(slave_target.x - my.x) + abs(slave_target.y
- my.y) > 30)
{
ent_move (slave_speed,
nullvector);
ent_cycle("walk",
my.skill10); // play walk frames animation
my.skill10 += 5
* time;
my.skill10 %= 100;
}
wait (1);
}
}

Q: I'm trying to write my own weapons. How can I attach particles to the trace
instruction? I don't want the script written for me just an idea.
A: Trace sets "target" to the coordinates
of the hit point. Place
the line below after your trace instruction.
effect(your_particle_function, number_of_particles, target, initial_particle_speed);
Example:
effect(hit_sparks, 10, target, vector(1, 1, 2));
Q:
I have a model of a tree. I want to be able to walk
right up to the trunk, but the bounding box won't allow me to do that
because of the leaves.
A:
Follow these simple steps:
- Add the tree model to your level and make it passable;
- Place a cylinder (a primitive) with 6-16 faces at the same position with the trunk and make it invisible.


Q:
How can I close a gate (as a trap) behind the player
if he's walking through a laser beam?
A:
Place an entity close to the laser beam and attach it the action named
"door_trigger". Create a wmb entity for the door and attach
it the action named "door_trap".
entity* door_t;
action door_trigger
{
my.invisible = on;
my.passable = on;
while (player == null) {wait (1);}
while (door_t == null) {wait (1);}
while (vec_dist(player.x, my.x) > 100) {wait (1);}
while (door_t.z > 0) // final z = 0, play with this value
{
door_t.z -= 3 * time; // 3 = speed
wait (1);
}
door_t.z = 0; // the door moves from 100 to 0 quants in this example
}
action door_trap
{
door_t = my;
my.z = 100; // initial z, play with this value
}

Q:
I need some simple level changing code for a project that includes 9
levels. A simple box and a figure that shows the level number will do
the job.
A: Click here to download the project.
Q:
I'm making a game and I was wondering
know can I insert a movie (avi) file. At a certain point
the movie would be triggered.
A:
Place any entity in your level and attach it the "movie_trigger" action;
come close to it to start the movie.
action movie_trigger
{
my.passable = on;
while (player == null) {wait (1);}
while (vec_dist(player.x, my.x) > 100) {wait (1);}
media_play("my_movie.avi", null, 50);
}
Q:
How would I go about reading the names of planets from a text
file into an array, set random
x,
y and
z coords
for each planet, save these to a new file, and then load them as the player
approaches?
A: Click here to
download a project that reads five planet names from a text file named
planets.txt, generates a random position for each planet and then writes
the names and
the coords in the processed.txt file. You will have to "ent_create" small,
low poly entities at the positions given by processed.txt. Use those entities
to check the distance between them and the player in a loop and create the
corresponding planets
when the
player
has
come close
enough to them.
Q:
I tried the project from Aum37's faq (moveps2.zip) and I'd
like to ask you to make a small change to it: when I turn and want
to go in that direction I'd like to push "W" for forward,
whatever direction that is.
A:
Click here to download the modified project.
Use "A" and "D" to rotate the player, "W" to move forward and "S" to move
backwards.
Q: How
can we make big levels with terrains but don't lose performance ?
A: Use several (smaller) terrain
entities, and then use fog and decent camera.clip_far values. Take
a look at the picture below: all the blue terrains will be rendered
(this happens even if a single vertex is inside the camera.clip_far
range), while the violet terrains won't be rendered. Don't forget
to glue your terrains together nicely; I left that black space between
them on purpose, because I wanted you to see them as separate pieces.