Jump to content


Photo

Enemy Collisions


  • Please log in to reply
No replies to this topic

#1 nathantcash

nathantcash

    GMC Member

  • GMC Member
  • 77 posts
  • Version:GM8

Posted 25 April 2012 - 04:12 AM

I am having problems with my enemies overlapping . I tried having them move away on the collision event but since they're the same object they preform the same actions. Is there a way to make them move away in different directions on the collision event or would it be easier to prevent them from moving into each other in the first place. Here is my current AI:

if(instance_exists(Guy)){//If Guy exists
  if(point_distance(x,y,Guy.x,Guy.y) < 350){//If within  range
    if(x > Guy.x){
      hspeed = max(-3,hspeed - 0.25)
      sprite_index = Alien_Run_left
    }
    else{
      hspeed = min( 3,hspeed + 0.25)
      sprite_index = Alien_Run_right
    }
  }
  else{
    if(abs(hspeed) > 0.5){
      hspeed -= 0.5*sign(hspeed)
    }
    else{
      hspeed = 0
    }
    if(hspeed<0){
      sprite_index = Alien_Left
    }
    else{
      sprite_index = Alien_right
    }
  }
}

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users