• 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!

Legacy GM Help Enemy Not Shoot If There's a Wall

D

dawson2223

Guest
Hey,

Is there a code that will only let the enemy do something to the player if there isn't any solids in between the enemy and player?

I'm trying to make it so the enemy can only shoot at me if there is no wall that separates us... Can't find the code for it.

Thanks a lot!
 
N

Newt

Guest
Use 'Collision_line' to check if there is an obj_Wall in the way, something like this ircc:

In enemy step event:

if !collision_line(x,y,player.x,player.y, object wall, false,false)
{
//shoot
}
 
D

dawson2223

Guest
I was looking at collision line but wasn't sure if that was the right thing to use. Thanks!!!


Use 'Collision_line' to check if there is an obj_Wall in the way, something like this ircc:

In enemy step event:

if !collision_line(x,y,player.x,player.y, object wall, false,false)
{
//shoot
}
 
Top