Hello,
I want my enemies to be able to find covers. As a starter in 3dgs i did this.
I put dummy entities in cover positions in my level and set there enable scan on and made the enemy to scan for the covers using scan_entity.
for the trial the enemy successfully scanned the dummy entity on the cover position and i confirmed it by displaying result variable from scan_entity on screen. but when i try to point the enmy to you pointer returned by scan_entity the engine gives the empty pointer error. Also if i try to make the enemy turn to found object it doesn't turn. here is my code.
var detected;
font swc_font = <font.pcx>, , 24, 23; // sword combat font
panel found_entity // displays the result of scan_entity
{
pos_x = 0;
pos_y = 0;
digits = 120, 575, 4, swc_font, 1, detected;
flags = refresh, visible;
}
action dummy //set the enable_scan on for dummy objects at cover.
{
my.enable_scan=on;
}
action enemy_fight // attached to the enemy
{
enemy = me; // I'm the enemy
while(player == null){wait(1);}
while (1)
{
if (vec_dist (my.x, player.x) < 800) // the player approaches the enemy
{
temp.pan=360;
temp.tilt=360;
temp.z=1000;
scan_entity(my.x,temp);
detected=result; //show the result on screen
//you.skill1=50; //if uncommented gives empty pointer error.
//doesn't work
vec_set(temp, you.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
}
wait (1);
}
}
though it shows the result by scan_entity (i displayed on the screen using digits) that means that it successfully scans the entity but why it gives empty pointer error and why it doesn't turn to cover i don't know?
A few questions as a new starter.
Is my aproach for the cover is good or is there any better way?
which one is better suited for this task scan_entity, trace or c_scan? Does it slows down the game or is there any alternative?
Thank You!