• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

(fixed)zombie with colliosion line doesnt work

S

stepup2000

Guest
//step step
var view_distance = 800;
var tx = x+lengthdir_x(view_distance,direction);
var ty = y+lengthdir_y(view_distance,direction);
if (collision_line(x,y,tx,ty,obj_player,true,false)) {
if (collision_line(x,y,obj_player.x,obj_player.y,obj_wall,true,false)) = noone {
state = 2
}
}
else {
state = 1
instance_destroy(obj_interest_point)
instance_create_depth(obj_player.x, obj_player.y, 1, obj_interest_point)
}

// begin step

if state = 2 {

image_angle = point_direction(x,y,obj_player.x, obj_player.y);
mp_potential_step(obj_player.x, obj_player.y, 1, false)
}
}
if state = 1 {
speed = 0
}

i want the enemy to follow the player when he is looking directly at the player and there is no wall in between them. but for some reason it doesnt work. state = 2 is chasing the player
 
Last edited by a moderator:
S

stepup2000

Guest
What is obj_man in this scenario?
Oh I’m sorry I changed that to try something obj man was the player. But I changed the code it’s correct now. I still don’t understand why it doesn’t work tho
 

Relic

Member
After you see the player, the zombie performs one more check to see if there is also a wall. In the wall check code, you check all the way to tx, ty. What if the wall is behind the player?
 
S

stepup2000

Guest
After you see the player, the zombie performs one more check to see if there is also a wall. In the wall check code, you check all the way to tx, ty. What if the wall is behind the player?
Oh 💩💩💩💩 you are right. it works now! i also changed one of the "else" actions because it was in the wrong place . thank you for your help!
 
Last edited by a moderator:
Top