Single Enemy Detect Player By Proximity

0 favourites
  • 3 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hi, Everyone.

    This has probably been explained several times before but, since I'm a bit of a noob and can't find the right technical term, I just gonna drop this here.

    I'm making a game prototype similar to Diablo and, right now, I have an circular object attached to the player object that, on overlapping with an enemy object, the enemy will start pursuit.

    My problem is, on detection, all the enemies on the scene start pursuit. I tried using "Pick Nearest" but I can't seem to make it work since I'm probably doing something wrong.

    What's the best way for the pursuit action affect only the enemy object overlapped by the circular object?

    Many thanks

    3rdclover

  • You are doing something wrong, probably picking wrong set of enemy instances.

    If you change your code to something like this:

    Enemy is overlapping DetectionSprite -> Enemy set speed to 100

    else -> Enemy set speed to 10

    then only enemies overlapping DetectionSprite will get speed increase.

    You can do the same without the sprite. For example:

    System: Every 1 seconds
    System: For each Enemy
        System: Compare two values: distance(Enemy.x, Enemy.y, Player.x, Player.y)<200 -> Enemy set speed to 100
        Else -> Enemy set speed to 10
    [/code:26nq1shi]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You are doing something wrong, probably picking wrong set of enemy instances.

    If you change your code to something like this:

    Enemy is overlapping DetectionSprite -> Enemy set speed to 100

    else -> Enemy set speed to 10

    then only enemies overlapping DetectionSprite will get speed increase.

    You can do the same without the sprite. For example:

    > System: Every 1 seconds
    System: For each Enemy
        System: Compare two values: distance(Enemy.x, Enemy.y, Player.x, Player.y)<200 -> Enemy set speed to 100
        Else -> Enemy set speed to 10
    [/code:8x3cngo0]
    

    Thanks a lot for the help!

    I just went with the second option and removed the detection sprites.

    Cheers

    --

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