logo hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    Patrolling enemies.

    Scheduled Pinned Locked Moved
    Help and Support
    6
    12
    875
    Loading More Posts
    • 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
      JiiS
      last edited by

      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 Reply Quote 0
      • T
        Thecheater887
        last edited by

        Gravity?

        1 Reply Last reply Reply Quote 0
        • JiiSJ
          JiiS
          last edited by

          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”.

          Jack8680J 1 Reply Last reply Reply Quote 0
          • Jack8680J
            Jack8680 @JiiS
            last edited by

            @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 Reply Quote 1
            • JiiSJ
              JiiS @Jack8680
              last edited by

              @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 Reply Quote 0
              • JiiSJ
                JiiS @Jack8680
                last edited by

                @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 Reply Quote 0
                • RobinsonXR
                  RobinsonX
                  last edited by

                  @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 Reply Quote 0
                  • MurtazaM
                    Murtaza Admin
                    last edited by

                    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 Reply Quote 0
                    • JiiSJ
                      JiiS
                      last edited by

                      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 Reply Quote 0
                      • Aidan_FireA
                        Aidan_Fire @JiiS
                        last edited by

                        @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 Reply Quote 0
                        • MurtazaM
                          Murtaza Admin
                          last edited by

                          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 Reply Quote 0
                          • JiiSJ
                            JiiS
                            last edited by JiiS

                            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 Reply Quote 0
                            • First post
                              Last post