Step event for enemy:
Well, im quite new to arrays, i still don't know how they exactly works
what this code does, is that it creates a collision line between enemy and player, if it detects an untranspasalbe object, the enemy can't see the player, else if it is a traspasable one, it saves (i think it does) the object x,y and image_xscale and then destroys it, finally if there are no objects left between enemy and player, enemy can see the player (if its inside of its vision range), if it sees the player it does magic stuff.
the problem is that i dont know how to recreate the destroyed objects, i already tried, but it gives an error
help?
Code:
if (collision_circle(x,y,320*vision_size,p,true,false)){//If player is inside the enemy vision
//Note: p stands for obj_player
var recover;
var i;
var detected = false
for(i = 0; detected = false; i += 1){
collision = collision_line(x,y,p.x,p.y,obj_solid,false,false); //Create a line between enemy and player
if collision != noone{ //If it detected a obj_solid
if collision.type = 1{ //If that solid was an untranspasable object, can't see the player
detected = true; //End for loop
seen = 0; //Haven't seen the player
}else{ //If the solid was a traspasable object, save x,y and image_xscale in a array
recover[0,i] = collision.x;
recover[1,i] = collision.y;
recover[2,i] = collision.image_xscale;
with collision{ //Destroy the object
instance_destroy();
}
if collision = noone{ //If no more solids detected, sees the player
detected = true;
seen = 1;
}//Else continue the loop until it detects an untranspasable object or
//Deletes all objects between player and enemy
}
}else{ //If there are no solid object between player and enemy
detected = true; //End for loop
seen = 1; //See the player
}
}
//Recreate destroyed blocks
//This is where its supposed to recreate the saved objects
}else{ //If out of range, can't see the player
seen = 0;
}
what this code does, is that it creates a collision line between enemy and player, if it detects an untranspasalbe object, the enemy can't see the player, else if it is a traspasable one, it saves (i think it does) the object x,y and image_xscale and then destroys it, finally if there are no objects left between enemy and player, enemy can see the player (if its inside of its vision range), if it sees the player it does magic stuff.
the problem is that i dont know how to recreate the destroyed objects, i already tried, but it gives an error
help?