Im creating a tank game, and I want the enemy tanks to see the players tank if its on the enemies X or Y axis.
I am using Collision_line to check the X and Y axis for the player. However the enemy tanks just get stuck when they spawn and dont move.
Can anybody help?
Walls are solid
Player's tank and enemy tank are not solid.
This code is placed in step event.
//Checks if the players tank is on the Y axis +200
var coldown; coldown = collision_line( obj_enemy_tank3.x+16,obj_enemy_tank3.y+16, x,y+200, obj_tank, 0, 1) ;
//Checks to see if there is a wall in the way, on the same Y axis
var waldown; waldown = collision_line( obj_enemy_tank3.x+16,obj_enemy_tank3.y+16, x,y+200, obj_BrickWall, 1, 1) ;
//Store the instance of the players tank. Not sure if this should be 1 or 0. Only 1 instance is ever created
player_inst = instance_find(obj_tank,1);
//If the collision line down, is the same as the players instance
if(coldown == player_inst)
{
//If the collision line down, returns noone(-4) then there is no wall, and continues.
if(waldown < 0)
{
//turn down and shoot
sprite_index = spr_enemy_1_down;
motion_set(270,2);
enemy_dir = 3; //For shooting direction
move_snap(16,16);
}
}
//This is repeated for the other directions.











