Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
hyperPad

hyperPad Forum

  1. Home
  2. Help and Support
  3. Enemy chase player? (RESOLVED)

Enemy chase player? (RESOLVED)

Scheduled Pinned Locked Moved Help and Support
4 Posts 3 Posters 942 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • dumbTacticsD Offline
    dumbTacticsD Offline
    dumbTactics
    wrote on last edited by dumbTactics
    #1

    UPDATE: Organized & Updated post, in case community members pose the same question, they will see resolution quoted below:


    @RobinsonX said in Code for emery chasing you:

    @SavageBuilderKid You can have a timer in the enemy that would constantly trigger the following:

    • Get the position of enemy and player
    • If enemy's x position < player's x position:
    • Move right. (You can use set velocity, apply force, move by, etc. depends on what you are doing.)
    • Otherwise, move left.

    This is a very simple method to emulate an enemy chasing the player. Let me know if you need more!


    ORIGINAL POST:

    I am trying to conduct a study of enemy AI behavior. In my case:

    • Player is running away from enemy
    • Enemy is chasing the player <— this is where I’m stuck

    I created a simple scene that mimicks the donkey kong gif below:
    A9525CFE-CFC8-4272-B51B-6B9D4C1B80A7.gif

    except, in my game scene, donkey kong chases mario throughout the different floor levels. No other elements.

    I read this excellent Enemy A.I. tutorial from hyperPad:
    https://hyperpad.zendesk.com/hc/en-us/articles/360029968391-How-to-Create-Artificial-Intelligence-for-an-Enemy-Slime

    It teaches how to have the enemy, attack a player within “x” proximity.

    It also explains

    • tag system
    • get position behavior

    These logic systems, provides the enemy with player coordinate awareness. Wonderful! but how do I get the enemy to chase the player?

    That question, is where I’m stumped, any nudge in the right direction will help me tons. Thank you

    TutorialDoctorT 1 Reply Last reply
    0
    • dumbTacticsD dumbTactics

      UPDATE: Organized & Updated post, in case community members pose the same question, they will see resolution quoted below:


      @RobinsonX said in Code for emery chasing you:

      @SavageBuilderKid You can have a timer in the enemy that would constantly trigger the following:

      • Get the position of enemy and player
      • If enemy's x position < player's x position:
      • Move right. (You can use set velocity, apply force, move by, etc. depends on what you are doing.)
      • Otherwise, move left.

      This is a very simple method to emulate an enemy chasing the player. Let me know if you need more!


      ORIGINAL POST:

      I am trying to conduct a study of enemy AI behavior. In my case:

      • Player is running away from enemy
      • Enemy is chasing the player <— this is where I’m stuck

      I created a simple scene that mimicks the donkey kong gif below:
      A9525CFE-CFC8-4272-B51B-6B9D4C1B80A7.gif

      except, in my game scene, donkey kong chases mario throughout the different floor levels. No other elements.

      I read this excellent Enemy A.I. tutorial from hyperPad:
      https://hyperpad.zendesk.com/hc/en-us/articles/360029968391-How-to-Create-Artificial-Intelligence-for-an-Enemy-Slime

      It teaches how to have the enemy, attack a player within “x” proximity.

      It also explains

      • tag system
      • get position behavior

      These logic systems, provides the enemy with player coordinate awareness. Wonderful! but how do I get the enemy to chase the player?

      That question, is where I’m stumped, any nudge in the right direction will help me tons. Thank you

      TutorialDoctorT Offline
      TutorialDoctorT Offline
      TutorialDoctor
      wrote on last edited by TutorialDoctor
      #2

      @dumbTactics as a quick guess, I suppose you can use the move to point behavior. You may have to keep track of all player positions in an array and move the enemy to each point after a certain amount of time using a timer behavior.

      For basic player follower functionality you can use a Timer, Get Position, and Move to Point behavior to move an enemy to a player position every ‘x’ amount of seconds.

      1 Reply Last reply
      1
      • RobinsonXR Offline
        RobinsonXR Offline
        RobinsonX
        wrote on last edited by
        #3

        To move a physical object, you can use Set Velocity or Apply Force. Set velocity is great to getting the object to the exact x and y velocity you want - however, since you can manipulate velocity, you have the risk of having your object clip through walls if it's going fast enough. Apply force is great for making your object move naturally as if another player is controlling it. This also makes the object less likely to clip through walls because the object's velocity isn't being replaced but rather added / subtracted.

        1 Reply Last reply
        0
        • RobinsonXR Offline
          RobinsonXR Offline
          RobinsonX
          wrote on last edited by RobinsonX
          #4

          The x and y velocity / force will push the object to move.
          X = Horizontal
          Y = Vertical

          You can use If behaviors to compare the position between the enemy and player.

          Example:
          If player X is greater than enemy X -> enemy moves right

          1 Reply Last reply
          1

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Search