Page 1 of 1

ENEMY'S TO HARD!

PostPosted: Tue Feb 24, 2009 11:10 pm
by refresh
I need help with how to get and enemy monster to walk around and attack actor on sight. any info would help. i've sat at my computer for almost an hour messin' around to find it but nothin'. PLZ HELP! :?







and THX.

Re: ENEMY'S TO HARD!

PostPosted: Tue Feb 24, 2009 11:59 pm
by skydereign
The way you will end up doing this will depend on what style game, if there is only left right, or left right up and down. Also, it depends on how your enemy is attacking. A way of controlling moving them randomly is by using a timer. I have a demo of it, and you could use a collision for the triggering of the action, though it can be pretty easy to overdo it... If you can give a description of the attack, it would be easier to explain.
This uses a timer, and with certain triggers you could make change it so the actor does something. These triggers will depend on what you want.
http://game-editor.com/forum/download/file.php?id=3503

Re: ENEMY'S TO HARD!

PostPosted: Thu Feb 26, 2009 5:03 am
by refresh
this game is a left to right only. so i guess a third person shooter. and if there is another way from timers (i never scripted them right) then that would be nice. heres a screen shot of my demo. :lol:

Re: ENEMY'S TO HARD!

PostPosted: Thu Feb 26, 2009 5:13 am
by skydereign
Okay, you could set up a distance check, it really depends on how mobile you want the enemies and how you are going to have them attack. Will the enemies shoot you too, or will they just rush attack you? As far as other methods, one way talked about in one of the demos is using paths, though I avoid those as they are not very editable. Moving back in forth would be really easy with timers, but I don't mean the gameEditor timers. I am talking about a variable that increments every frame. And depending on what it is, the enemy will move either left or right.
Enemy->DrawActor->Script Editor
Code: Select all
if (count>0)
{
  count++;
}
switch(count)
{
  case 1:
  //ChangeAnimation to left
  xvelocity=-5;
  break;
  case 100:
  //ChangeAnimation to right
  xvelocity=5;
  count=1;
  break;
  case 101:
  //Attack
  break;
}

Note that you need to initialize the enemy, on create actor, count equals one. If the enemy's horizontal distance is under a certain range, you can switch count to 101 to initialize the attack, and have that repeat.

Re: ENEMY'S TO HARD!

PostPosted: Thu Feb 26, 2009 10:58 pm
by refresh
i got it now! thx skyderegin! the enemys work now heres my latest screen shot!