I'm not sure why I can't get c_trace to work. I downloaded the workshop that came along with AUM51 and it ran fine. I tried to adapt the code to my own script many different ways but none of them work. The idea is to make the player move when the space key is pressed, but by first activating c_trace to look for wall entities. When c_trace detects a wall entity, the player should move, but doesn't. The move_forward() function works fine and requires a single key to be pressed as well, but doesn't use c_trace. I've defined the wall entity, placed it in an action and attached the action to the wall entity in WED, just like in workshop 26. The wall entity that I speak of is really a hollowed out box, with which the player can pass through. The player is a sprite but I'm not sure where the c_trace origin is coming from. I would appreciate any help that you can give. If any part of my problem is unclear and needs refinement, please let me know. Thank you.
ENTITY* Walls_ent; //WALL ENTITY
function move_forward() //THIS FUNCTION WORKS FINE AND IS CALLED IN THE PLAYER_MOVE ACTION
{ var new_position = 256;
var old_position = 0;
while (old_position < new_position)
{c_move (my, vector(64, 0, 0), nullvector, GLIDE);
old_position += 64;
wait(1);
}
}
action Walls_act() //THIS ACTION IS ATTACHED TO ALL WALL ENTITIES IN LEVEL
{ Walls_ent = my;
}
function wall() //THIS FUNCTION DOESN'T WORK AND IS CALLED IN THE PLAYER_MOVE ACTION
{ while(1)
{ c_trace (player.x, Walls_ent.x, IGNORE_ME + USE_BOX); // trace from the weapon to the enemy
if (you == Walls_ent) // got the enemy?
{ c_move(player, vector(64,0,0), nullvector, GLIDE);
}
wait(1);
}
}
action player_move()
{ player = my;
while (1)
{camera_view.pan = player.pan;
camera_view.x = player.x;
camera_view.y = player.y;
if (key_w - key_d - key_s - key_a == 1) //only key_w is being pressed
{ while (key_w - key_d - key_s - key_a == 1) //while key_d is being held, wait a frame
{wait(1);}
move_forward();
}
if (key_space == 1) // only key_space is being pressed
{ while (key_space == 1) // while key_space is being held, wait a frame
{wait (1);}
wall();
}
wait (1);
}
}