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. Patrolling enemies.

Patrolling enemies.

Scheduled Pinned Locked Moved Help and Support
12 Posts 6 Posters 2.7k Views 3 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.
  • JiiSJ Offline
    JiiSJ Offline
    JiiS
    wrote on last edited by
    #1

    I got great help from the developer, but it seems I need more.

    I have a patrolling enemy that is a physics object. It seems that collision with it makes it sometimes change the patrolling area, gain speed, walk on air...
    ...so, how to make a patrolling enemy in a platformer respect the laws of physics and not patrol in the air?

    I want it also to leave a body behind. That I can manage, but if the patrolling is on the body seems to be placed two or three pixels too high.

    Sorry about the confused and confusing question, but the main thing is: how do you guys make your platformer enemies behave like a normal regular enemy in a NES game and not freak out?

    Thanks!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Thecheater887
      wrote on last edited by
      #2

      Gravity?

      1 Reply Last reply
      0
      • JiiSJ Offline
        JiiSJ Offline
        JiiS
        wrote on last edited by
        #3

        I have gravity in the world settings and I have tried setting a gravity to the enemy too, but I can’t seem to figure it out.
        I have not set the enemy to do damage yet so if I push it with the player character the enemy just runs across the air. Patrol is set to ”linear”.

        Jack de WildeJ 1 Reply Last reply
        0
        • JiiSJ JiiS

          I have gravity in the world settings and I have tried setting a gravity to the enemy too, but I can’t seem to figure it out.
          I have not set the enemy to do damage yet so if I push it with the player character the enemy just runs across the air. Patrol is set to ”linear”.

          Jack de WildeJ Offline
          Jack de WildeJ Offline
          Jack de Wilde
          wrote on last edited by
          #4

          @jiis the patrol behaviour doesn't play well with physics. I'd suggest maybe using the set velocity behaviour on a timer instead, something like this:
          0_1558712386475_0EA9637E-8712-4C37-BC3D-390B3782C181.png

          Basically, it multiplies horizontal velocity by -1 every second (or however long you want the patrol duration), but also switches when it collides with something on the left or right.

          Colliding also runs the behaviour on for the Wait2, which has the effect of resetting the wait so you don't run into the issue where it bounces and then changes direction again right after.

          You might want to use a tag in the collided behaviour so you can tag whatever objects should cause the enemy to bounce, or just get rid of it altogether.

          The reason I put set velocity on a timer like this is so you don't have to worry about friction and air resistance slowing the enemy down.

          I'm not great at explaining things so let me know if you need me to explain further. Here's a link to that project, behaviours are inside the red square object. http://bit.ly/2HLIM5e

          JiiSJ 2 Replies Last reply
          1
          • Jack de WildeJ Jack de Wilde

            @jiis the patrol behaviour doesn't play well with physics. I'd suggest maybe using the set velocity behaviour on a timer instead, something like this:
            0_1558712386475_0EA9637E-8712-4C37-BC3D-390B3782C181.png

            Basically, it multiplies horizontal velocity by -1 every second (or however long you want the patrol duration), but also switches when it collides with something on the left or right.

            Colliding also runs the behaviour on for the Wait2, which has the effect of resetting the wait so you don't run into the issue where it bounces and then changes direction again right after.

            You might want to use a tag in the collided behaviour so you can tag whatever objects should cause the enemy to bounce, or just get rid of it altogether.

            The reason I put set velocity on a timer like this is so you don't have to worry about friction and air resistance slowing the enemy down.

            I'm not great at explaining things so let me know if you need me to explain further. Here's a link to that project, behaviours are inside the red square object. http://bit.ly/2HLIM5e

            JiiSJ Offline
            JiiSJ Offline
            JiiS
            wrote on last edited by
            #5

            @jack8680

            Wow, thank you very much. I need to test this.

            I have used Game Maker before, but I’m extremely new at Hyperpad. Hyperpad is more intuitive to me, but I got stuck with the patrolling.

            I’ll tell the results after testing!

            1 Reply Last reply
            0
            • Jack de WildeJ Jack de Wilde

              @jiis the patrol behaviour doesn't play well with physics. I'd suggest maybe using the set velocity behaviour on a timer instead, something like this:
              0_1558712386475_0EA9637E-8712-4C37-BC3D-390B3782C181.png

              Basically, it multiplies horizontal velocity by -1 every second (or however long you want the patrol duration), but also switches when it collides with something on the left or right.

              Colliding also runs the behaviour on for the Wait2, which has the effect of resetting the wait so you don't run into the issue where it bounces and then changes direction again right after.

              You might want to use a tag in the collided behaviour so you can tag whatever objects should cause the enemy to bounce, or just get rid of it altogether.

              The reason I put set velocity on a timer like this is so you don't have to worry about friction and air resistance slowing the enemy down.

              I'm not great at explaining things so let me know if you need me to explain further. Here's a link to that project, behaviours are inside the red square object. http://bit.ly/2HLIM5e

              JiiSJ Offline
              JiiSJ Offline
              JiiS
              wrote on last edited by
              #6

              @jack8680
              I have tinkered with this in the project you sent and it works perfectly for me...

              ...BUT, I have gone insane trying to figure out where that ”Set input field” action comes from. I understand it may be a custom name, but I just can’t find a behavior that functions like that when making my project.

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

                @JiiS The custom input field can be created from a behavior. When you select a behavior, you can see some behaviors have a green inbox icon where you can place in variables, text, etc.

                You can touch the green inbox icon when viewing the behaviors to get a custom input field. :)

                1 Reply Last reply
                0
                • MurtazaM Offline
                  MurtazaM Offline
                  Murtaza
                  Admin
                  wrote on last edited by
                  #8

                  See documentation on sharing values. There is a section on Change input field (Set Input field)

                  https://hyperpad.zendesk.com/hc/en-us/articles/202467445-Sharing-Values-Between-Behaviors

                  1 Reply Last reply
                  0
                  • JiiSJ Offline
                    JiiSJ Offline
                    JiiS
                    wrote on last edited by
                    #9

                    Thank you all very much! Still have trouble flipping the graphic when enemy turns with this method, but other than that, works like a dream!
                    Incredibly helpful community here.

                    Aidan_FireA 1 Reply Last reply
                    0
                    • JiiSJ JiiS

                      Thank you all very much! Still have trouble flipping the graphic when enemy turns with this method, but other than that, works like a dream!
                      Incredibly helpful community here.

                      Aidan_FireA Offline
                      Aidan_FireA Offline
                      Aidan_Fire
                      wrote on last edited by
                      #10

                      @jiis Using that method, can you see when the enemy changes directions? Every time the behaviours run that switch his direction, run some logic like this:
                      0_1559347112745_D8874083-07F4-4547-A01F-6CA516736354.png
                      The first one of the "Set Graphic Flip" behaviours will have "Flip X" switched on, and the other will have it switched off (turned on will flip it, turned off will change it back to original). The "Execute Sequence" behaviour will alternate between the two behaviours every time it is run.

                      1 Reply Last reply
                      0
                      • MurtazaM Offline
                        MurtazaM Offline
                        Murtaza
                        Admin
                        wrote on last edited by
                        #11

                        Another option to the flip graphic behaviour is to scale it by -100%. Scaling it by a negative will also flip the collision box, where as flip graphic will not.

                        1 Reply Last reply
                        0
                        • JiiSJ Offline
                          JiiSJ Offline
                          JiiS
                          wrote on last edited by JiiS
                          #12

                          Thank you and thank you!

                          Now I have my first fully functional enemy!

                          Still one of the original problems remain. :D The reason I rejected the patrol function was that the physics didn’t work right. One thing still remains, ”the floating body”. When I stomp the enemy with the detective it plays the animation of captured enemy. Problem is, the captured enemy floats few pixels in the air. It otherwise obeys the gravity.
                          I think the problem is the graphic or the function ”play animation”. The sprite should be same size, the captured one just has more empty pixels on top. It almost feels like the pixels from top go to the bottom. :O
                          The frames are all different small images, not from a tileset.

                          Here is a pic:
                          0_1559371608714_9A9FA9D0-3C80-4156-8DA3-1E64BC53E89F.jpeg

                          EDIT: Spawn object seems to work well enough, it just needs the captured object to be hidden out of sight in the level.

                          1 Reply Last reply
                          0

                          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