icecapboy Posted June 20, 2006 Report Share Posted June 20, 2006 Hey gang, I have a question. How can you make an enemy shoot when it's facing the character you're playing and not shoot when it's not facing the character the player is controlling. BTW, I'm using the TGF, so I need the events of how to do this. Thanks! Link to comment Share on other sites More sharing options...
Serephim Posted June 21, 2006 Report Share Posted June 21, 2006 Im not too good at explaining stuff, but... this is for him shooting at you when your on the left. ---X Position of player < X position of Enemy ---> ---Direction Of Enemy is facing (<-- *this way) -*enemy shoots at player* Do the same for the right. ---X Position of player > X position of Enemy ---> ---Direction Of Enemy is facing (--> *this way) -*enemy shoots at player* To make it more realistic, you need to set a distance that he starts shooting at you. For instance, if you want them to see you almost instantly (player on the left), Do this: ---X Position of player < X position of Enemy - 500 ---> ---Direction Of Enemy is facing (<-- *this way) -*enemy shoots at player* This makes it so he only shoots at you when hes facing you, and your player is within 500 pixels to the left of the enemy. Lower it to make his vision worse, highten it to make his vision better. But make sure you put a restriction on there, otherwise hes going to shoot at you whenever hes turned to you, even if your nowhere near him. You also need to make an event that sets you in a certian Y range, otherwise you can be under him and he will still "see" you. So alter the above events like this (when your on the left): ---X Position of player < X position of Enemy - 500 ---> ---Y position of Player > Y position of Enemy +50 ---Y position of player < Y position of Enemy -50 ---Direction Of Enemy is facing (<-- *this way) -*enemy shoots at player* And when your on the Right : ---X Position of player > X position of Enemy +500 ---> ---Y position of Player > Y position of Enemy +50 ---Y position of player < Y position of Enemy -50 ---Direction Of Enemy is facing (<-- *this way) -*enemy shoots at player* Now, he can only see you if your pretty much on the same plane as him. You may want to highten it a bit for when you jump. (+50 pixels isnt very much.) That gives him a full range of view. This method can allow the enemy to detect you without having to give them all Active Objects for their view field. Just do the same thing for when your on the right. Alter the pixel range to fit your needs. Link to comment Share on other sites More sharing options...
Recommended Posts