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. Homing projectile vs multiple targets

Homing projectile vs multiple targets

Scheduled Pinned Locked Moved Help and Support
59 Posts 5 Posters 29.5k Views 2 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.
  • SplitMindGamingS SplitMindGaming

    @Aidan-Oxley I swear your brilliant when it comes to those tricky codings. If my game gets big and I need a bigger team of developers. Just know your hired lol.

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

    @SplitMindGaming I like seeing how different people have their strengths and weaknesses. I haven't seen your game yet, but from what you've said so far you seem to be good at the designing of games, but you struggle with the actual coding (which is why you want single behaviours that do a lot of things at once for you). I have the opposite, I like accepting challenges of making something most people don't know how to do, but I struggle with actually designing a game. By far most of my time spent in any of my projects is just making decisions.

    bosswaveB SplitMindGamingS 2 Replies Last reply
    0
    • Aidan_FireA Aidan_Fire

      @SplitMindGaming I like seeing how different people have their strengths and weaknesses. I haven't seen your game yet, but from what you've said so far you seem to be good at the designing of games, but you struggle with the actual coding (which is why you want single behaviours that do a lot of things at once for you). I have the opposite, I like accepting challenges of making something most people don't know how to do, but I struggle with actually designing a game. By far most of my time spent in any of my projects is just making decisions.

      bosswaveB Offline
      bosswaveB Offline
      bosswave
      wrote on last edited by
      #11

      @Aidan-Oxley I’ve never tried working with arrays before. Seems like I have my work cut out lol.

      And where the heck is the set input field behavior? Am I needing to purchase an upgrade to have access to it or something?

      Aidan_FireA SplitMindGamingS 4 Replies Last reply
      0
      • Aidan_FireA Aidan_Fire

        @SplitMindGaming I like seeing how different people have their strengths and weaknesses. I haven't seen your game yet, but from what you've said so far you seem to be good at the designing of games, but you struggle with the actual coding (which is why you want single behaviours that do a lot of things at once for you). I have the opposite, I like accepting challenges of making something most people don't know how to do, but I struggle with actually designing a game. By far most of my time spent in any of my projects is just making decisions.

        SplitMindGamingS Offline
        SplitMindGamingS Offline
        SplitMindGaming
        wrote on last edited by
        #12

        @Aidan-Oxley yes I thought the same thing. Both of us would actually compliment each other if we ever did decide to team up. It would be a force to be reckon with. Here’s a video of me showing a time lapse of something I did in photoshop a long time ago. Although doesn’t have to do with games but it kind of shows where my skills are at in terms of designing.

        1 Reply Last reply
        0
        • Aidan_FireA Offline
          Aidan_FireA Offline
          Aidan_Fire
          wrote on last edited by
          #13

          When missile spawns, it will run this loop that will repeat the logic under it once for every target object that exists, and it will do this very quickly (this completely freezes hyperPad if the loop tries to repeat too many times, that's how fast they are). In the loop, it will get the ID of a target object and calculate the distance to it. It will group the ID and calculated distance together in an array with the order of distance, ID. Then it will store this information in another array, and move on to the next target object, if there is one. Once it's finished the loop, it will sort the array from smallest calculated distance to largest, then all it needs to do is get the data from the start of the array (because it's the smallest), get the ID of the object with that distance and go home in on it.

          Don't know if this is helpful in understanding the logic, but there you go.

          1 Reply Last reply
          0
          • bosswaveB bosswave

            @Aidan-Oxley I’ve never tried working with arrays before. Seems like I have my work cut out lol.

            And where the heck is the set input field behavior? Am I needing to purchase an upgrade to have access to it or something?

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

            @bosswave Press here:816E405B-5DD1-4F6F-8801-72249AB86517.jpeg

            Jack de WildeJ 1 Reply Last reply
            0
            • Aidan_FireA Aidan_Fire

              @bosswave Press here:816E405B-5DD1-4F6F-8801-72249AB86517.jpeg

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

              @Aidan-Oxley Really all you need to do is loop through a list of targets and keep track of which one is closest, no? Rather than sorting the whole array.

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

                @Aidan-Oxley Really all you need to do is loop through a list of targets and keep track of which one is closest, no? Rather than sorting the whole array.

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

                @Jack8680 Yeah but that takes more behaviours :P need another box container to keep the minimum value, then get the minimum value every loop.

                EDIT: actually Jack's idea is more efficient and probably takes same amount of behaviours, and makes me wonder why I did it the way I did in the first place.

                1 Reply Last reply
                0
                • bosswaveB bosswave

                  @Aidan-Oxley I’ve never tried working with arrays before. Seems like I have my work cut out lol.

                  And where the heck is the set input field behavior? Am I needing to purchase an upgrade to have access to it or something?

                  SplitMindGamingS Offline
                  SplitMindGamingS Offline
                  SplitMindGaming
                  wrote on last edited by
                  #17

                  @bosswave you mentioned you want it to look at a group of spawned objects. Are these objects constantly spawning or do they spawn in once.

                  Aidan_FireA 1 Reply Last reply
                  0
                  • SplitMindGamingS SplitMindGaming

                    @bosswave you mentioned you want it to look at a group of spawned objects. Are these objects constantly spawning or do they spawn in once.

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

                    @SplitMindGaming Doesn't matter. When the missile spawns or the homing logic is triggered, it will look at all objects that currently exist with the tag "target".

                    Jack de WildeJ 1 Reply Last reply
                    0
                    • Aidan_FireA Aidan_Fire

                      @SplitMindGaming Doesn't matter. When the missile spawns or the homing logic is triggered, it will look at all objects that currently exist with the tag "target".

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

                      @Aidan-Oxley We think in different ways when making something like this lol.

                      1 Reply Last reply
                      0
                      • bosswaveB bosswave

                        @Aidan-Oxley I’ve never tried working with arrays before. Seems like I have my work cut out lol.

                        And where the heck is the set input field behavior? Am I needing to purchase an upgrade to have access to it or something?

                        SplitMindGamingS Offline
                        SplitMindGamingS Offline
                        SplitMindGaming
                        wrote on last edited by
                        #20

                        @bosswave here’s my ghetto way of doing it. It doesn’t use arrays. Very simple logic really. But this only works assuming you already spawned in your objects. You can always just already have the objects spawned in but hidden away far off screen. Then have certain events move that object to scene when you want it. You will notice that this method does work and it will follow the closest square that’s next to it. So go ahead move each square next to the missile and it will follow the closest one. Maybe this can be a temporary approach until you learn arrays and know the ways of master aiden. Use safari to download and open this project.Homing missile.tap

                        Jack de WildeJ 1 Reply Last reply
                        0
                        • SplitMindGamingS Offline
                          SplitMindGamingS Offline
                          SplitMindGaming
                          wrote on last edited by
                          #21

                          Here’s a video showcasing it follow the closest squareFullSizeRender.mov

                          1 Reply Last reply
                          0
                          • SplitMindGamingS SplitMindGaming

                            @bosswave here’s my ghetto way of doing it. It doesn’t use arrays. Very simple logic really. But this only works assuming you already spawned in your objects. You can always just already have the objects spawned in but hidden away far off screen. Then have certain events move that object to scene when you want it. You will notice that this method does work and it will follow the closest square that’s next to it. So go ahead move each square next to the missile and it will follow the closest one. Maybe this can be a temporary approach until you learn arrays and know the ways of master aiden. Use safari to download and open this project.Homing missile.tap

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

                            @SplitMindGaming I think Aidan's reworking his to not use arrays right now lol

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

                              @SplitMindGaming I think Aidan's reworking his to not use arrays right now lol

                              SplitMindGamingS Offline
                              SplitMindGamingS Offline
                              SplitMindGaming
                              wrote on last edited by
                              #23

                              @Jack8680 yeah he’s about to poop on mine right now just wait for it.

                              Jack de WildeJ 1 Reply Last reply
                              0
                              • bosswaveB bosswave

                                @Aidan-Oxley I’ve never tried working with arrays before. Seems like I have my work cut out lol.

                                And where the heck is the set input field behavior? Am I needing to purchase an upgrade to have access to it or something?

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

                                @bosswave Don't use the other example, use this one instead: https://go.aws/2zEM8XH
                                Jack made me realise what I was doing before is really over complicating the problem, this one is way simpler and doesn't even use arrays.

                                It's so funny how you can make something complicated, but then it ends up being dumb because of how simple it can actually be.

                                SplitMindGamingS 1 Reply Last reply
                                1
                                • SplitMindGamingS SplitMindGaming

                                  @Jack8680 yeah he’s about to poop on mine right now just wait for it.

                                  Jack de WildeJ Offline
                                  Jack de WildeJ Offline
                                  Jack de Wilde
                                  wrote on last edited by Jack8680
                                  #25

                                  @SplitMindGaming Haven't looked at yours yet, but I think the best way is something like this:

                                  minDistance = -1;
                                  foreach(potentialTarget in tag)
                                  {
                                      distance = CalculateDistance(self, potentialTarget );
                                      if(minDistance == -1 OR  distance < minDistance)
                                      {
                                          minDistance = distance;
                                          target = potentialTarget;
                                      }
                                  }
                                  

                                  Or if there's a maximum range, you can just do

                                  minDistance = maxRange;
                                  foreach(potentialTarget in tag)
                                  {
                                      distance = CalculateDistance(self, potentialTarget );
                                      if(distance < minDistance)
                                      {
                                          minDistance = distance;
                                          target = potentialTarget ;
                                      }
                                  }
                                  

                                  Too bad having an OR in hyperPad isn't quite the same as in a normal programming language; if you put two ifs next to each other connected to the same group of behaviours, it's possible for them to both be true and run the behaviours underneath twice, so it gets a bit messy.

                                  1 Reply Last reply
                                  1
                                  • Aidan_FireA Aidan_Fire

                                    @bosswave Don't use the other example, use this one instead: https://go.aws/2zEM8XH
                                    Jack made me realise what I was doing before is really over complicating the problem, this one is way simpler and doesn't even use arrays.

                                    It's so funny how you can make something complicated, but then it ends up being dumb because of how simple it can actually be.

                                    SplitMindGamingS Offline
                                    SplitMindGamingS Offline
                                    SplitMindGaming
                                    wrote on last edited by
                                    #26

                                    @Aidan-Oxley the thing I notice with yours is that it doesn’t follow the closest square. It only follows and locks on 1 target. It doesn’t redirect. Did u check out my video on how mine behaves?

                                    Aidan_FireA 1 Reply Last reply
                                    0
                                    • SplitMindGamingS SplitMindGaming

                                      @Aidan-Oxley the thing I notice with yours is that it doesn’t follow the closest square. It only follows and locks on 1 target. It doesn’t redirect. Did u check out my video on how mine behaves?

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

                                      @SplitMindGaming It finds the nearest target ONCE, and chases that one forever. It can be told to redirect whenever you want, just activate the behaviour bundle called "Homing trigger" and it will redirect to the nearest target and then chase that one forever. For example: edit the project and add a timer and connect Homing trigger (with all the behaviours under it) underneath the timer. Don't make the timer too fast or you could lag/freeze the project if you have spawned in lots of targets. 0.5s would be fine.

                                      I did look at yours. I moved the blue and green squares both to the top right of the screen and the missile just stopped and sat there.

                                      SplitMindGamingS 2 Replies Last reply
                                      0
                                      • Aidan_FireA Aidan_Fire

                                        @SplitMindGaming It finds the nearest target ONCE, and chases that one forever. It can be told to redirect whenever you want, just activate the behaviour bundle called "Homing trigger" and it will redirect to the nearest target and then chase that one forever. For example: edit the project and add a timer and connect Homing trigger (with all the behaviours under it) underneath the timer. Don't make the timer too fast or you could lag/freeze the project if you have spawned in lots of targets. 0.5s would be fine.

                                        I did look at yours. I moved the blue and green squares both to the top right of the screen and the missile just stopped and sat there.

                                        SplitMindGamingS Offline
                                        SplitMindGamingS Offline
                                        SplitMindGaming
                                        wrote on last edited by
                                        #28

                                        @Aidan-Oxley yeah I was going to say the same thing. When your missile hits the edge of the screen it just stops there and freezes.

                                        1 Reply Last reply
                                        0
                                        • Aidan_FireA Aidan_Fire

                                          @SplitMindGaming It finds the nearest target ONCE, and chases that one forever. It can be told to redirect whenever you want, just activate the behaviour bundle called "Homing trigger" and it will redirect to the nearest target and then chase that one forever. For example: edit the project and add a timer and connect Homing trigger (with all the behaviours under it) underneath the timer. Don't make the timer too fast or you could lag/freeze the project if you have spawned in lots of targets. 0.5s would be fine.

                                          I did look at yours. I moved the blue and green squares both to the top right of the screen and the missile just stopped and sat there.

                                          SplitMindGamingS Offline
                                          SplitMindGamingS Offline
                                          SplitMindGaming
                                          wrote on last edited by
                                          #29

                                          @Aidan-Oxley 8AEC4F6A-BC05-4262-864B-D400B6E2A4AD.png

                                          Aidan_FireA 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