From AUM 43
Q: If I would kick a box, how would I program it so that it moves in the opposite direction without losing its original pan and tilt angles?
A: Use the code below. Run into the box to move it.
function move_boxes()
{
vec_rotate (vector(2 * (my.x - player.x) * time, 0, 0), player.pan);
vec_add (my.x, vector(2 * (my.x - player.x) * time, 2 * (my.y - player.y) * time, 0));
}
action my_box
{
while (player == null) {wait (1);}
my.enable_impact = on;
my.enable_entity = on;
my.event = move_boxes;
}
[EDIT]...and AUM58
Q: I need to have a box that can be pushed by the player. Can you help?
A: Use this example.
action pushable_box
{
while (player == null) {wait (1);}
var my_angle;
while (1)
{
// play with 50 - it depends on the size of the box
if (vec_dist (player.x, my.x) < 50)
{
vec_set(temp.x, player.x);
vec_sub(temp.x, my.x);
vec_to_angle(my_angle.pan, temp.x);
temp.x = -10 * cos(my_angle.pan - my.pan) * time;
temp.y = -10 * sin(my_angle.pan - my.pan) * time;
temp.z = -1 * time;
c_move (my, temp.x, nullvector, ignore_you | ignore_passable | glide);
}
wait (1);
}
}
[ENDEDIT]
Last edited by Nems; 11/09/07 20:28.