How do I make enemies kite?

0 favourites
From the Asset Store
Pixel Enemies for SHMUP consists of 38 enemy ship sprites to be used in your game.
  • I have a skeleton with a bow which I want to slowly move away from the player to maintain a safe distance. I thought there was a condition that checks how close to 2 sprites an enemy is but I couldn't find it.

    Basically here is what I need

    When the player is within 50pxl of the skeleton it should move to a safer firing range (maybe 60 pxls away).

  • To calculate distance there is an exprestion for that,

    distance(Player.X,Player.Y,Enemy.X,Enemy.Y)
    

    Or alternatively, you can use Line of Sight behaviour.

  • Awesome thank you. Should I use line of sight? Combat is usually pretty close.

  • It depends, LOS would give you more control n all.

    All the best for your project.

  • It depends, LOS would give you more control n all.

    All the best for your project.

    Okay thx. Seems simpler to do with the compare value so I will do that.

  • Eh still haven't figured out how to make them move away. Should I be using custom movement for this?

  • Doest matter. Figured it out with custom movement.

  • distance(Skeleton.X,Skeleton.Y, PlayerBox.X, PlayerBox.Y) is less or equal to 60

    set custom angle of motion to distance(Skeleton.X,Skeleton.Y, PlayerBox.X, PlayerBox.Y) - 180

    accelarate custom 150

    isnt working. Why is that?

  • The distance seems too short, try to play with different value, or you can make a text object and set the text value to "

    distance(Player.X,Player.Y,Enemy.X,Enemy.Y)
    

    " to check the real-time distance b/w two objects

    if you need to just move the enemy to further by pixels you don't need custom movement,

    + System: distance(Player.X,Player.Y,Enemy.X,Enemy.Y) ≤ 400

    -> Enemy: Move forward 1000 pixels

    Hope it helps.

  • So what behaviour am i moving it with?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Without seeing your events I cant be sure, but you could have conflicting movement demands as the enemy moves in and out of range.

    I like to use boolean instance variables that control what state the enemy is in. You can set them with your events.

    eg.

    If Enemy distance to player is less than 50 - set instance variable "Kite" to true

    If Enemy is Kite - (insert your custom kiting movement here and attacks here)

    - sub event - if Enemy distance to player is greater than (whatever you want) set Kite to False

  • So what behaviour am i moving it with?

    This is what I was referring to, but again, it all depends, custom behaviour will give you more controls.

  • Okay thanks. Originally I was going to use 8 direction but came to the conclusion I wouldnt be able to move at 20° for example

  • Without seeing your events I cant be sure, but you could have conflicting movement demands as the enemy moves in and out of range.

    I like to use boolean instance variables that control what state the enemy is in. You can set them with your events.

    eg.

    If Enemy distance to player is less than 50 - set instance variable "Kite" to true

    If Enemy is Kite - (insert your custom kiting movement here and attacks here)

    - sub event - if Enemy distance to player is greater than (whatever you want) set Kite to False

    Yeah I thought about that. I decided I would have them move until they were 60 pixels away.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)