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

Spawning

Scheduled Pinned Locked Moved Help and Support
24 Posts 4 Posters 9.1k 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.
  • S Offline
    S Offline
    Stephenn
    wrote on last edited by
    #1

    I want to spawn objects on random places but I don't want to have more than one object in the same place, can someone tell me how I can do this?

    Jack de WildeJ 1 Reply Last reply
    0
    • Michael KhalfinG Offline
      Michael KhalfinG Offline
      Michael Khalfin
      wrote on last edited by
      #2

      I could only guess that this will work...

      Assuming you will have a limit to the number of objects at a time and assuming that that limit is 25, I would create an array with 25 slots. The first value would be the position, and you would format it as x, y. The next 24 values would be 0, but would be replaced whenever a new object is spawned.

      You will need a lot of logic behind combining and trimming the text, and in general, the reason the array will have to be so uniform is because you will have to be able to do logic with values not yet existent. To get values such as 24 to 24.00, you may want to experiment with combining and trimming text behaviors, or you could just round everything and put it on a grid. Your choice.

      And if you don't understand, tell me and I'll make an example project sometime over the next few days...

      1 Reply Last reply
      0
      • S Stephenn

        I want to spawn objects on random places but I don't want to have more than one object in the same place, can someone tell me how I can do this?

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

        @Stephenn You could make them unpassable physics so they push each other out the way, otherwise it would get pretty complex.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Stephenn
          wrote on last edited by
          #4

          They are unpassable.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Stephenn
            wrote on last edited by
            #5

            @GameCRAZY I don't really understand what you are saying to do, here is what I did0_1494537973245_IMG_1351.PNG

            Michael KhalfinG Jack de WildeJ 2 Replies Last reply
            0
            • S Stephenn

              @GameCRAZY I don't really understand what you are saying to do, here is what I did0_1494537973245_IMG_1351.PNG

              Michael KhalfinG Offline
              Michael KhalfinG Offline
              Michael Khalfin
              wrote on last edited by
              #6

              @Stephenn Well, does it work? Tell me if you would like me to make you the project...?

              1 Reply Last reply
              0
              • S Stephenn

                @GameCRAZY I don't really understand what you are saying to do, here is what I did0_1494537973245_IMG_1351.PNG

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

                @Stephenn You could use dynamic attributes to store whether an object has already been spawned, assuming you don't need to spawn any more after the objects have moved or been destroyed. For example, you could use combine text to combine the X and Y spawning position with a space in between, and get that dynamic attribute. If the attribute is not equal to 1, spawn an object at that position and set that dynamic attribute to 1. If the get attribute was equal to 1, try again. I think it should be something like this:
                0_1494540393747_IMG_3252.PNG
                It's not the most efficient way because it can loop a lot if you have a lot of the grid filled already, but it's pretty simple and this also lets you set certain areas to be blocked from spawning in. For example, if you don't want an object being able to spawn at 14,12, you can set the attribute "14 12" to 1, and then when something tries to spawn it'll get that attribute, see that it is 1, and pick a different position.

                It isn't efficient but it is pretty simple behaviours so shouldn't cause too much lag, just make sure you don't run the spawn behaviour more times than can fit in the grid, otherwise it'll get stuck in an infinite loop looking for places to spawn.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Stephenn
                  wrote on last edited by
                  #8

                  Ok, I am going to bed right now, I will try tomorrow and tell if I can get it to work, thanks

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Stephenn
                    wrote on last edited by
                    #9

                    I can't seem to get it to work

                    Michael KhalfinG 1 Reply Last reply
                    0
                    • S Stephenn

                      I can't seem to get it to work

                      Michael KhalfinG Offline
                      Michael KhalfinG Offline
                      Michael Khalfin
                      wrote on last edited by
                      #10

                      @Stephenn Give me till Saturday night... I will comment when it is published to the hub.

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        Stephenn
                        wrote on last edited by
                        #11

                        Thank you

                        Jack de WildeJ 1 Reply Last reply
                        0
                        • Aidan_FireA Offline
                          Aidan_FireA Offline
                          Aidan_Fire
                          wrote on last edited by Aidan_Fire
                          #12

                          I've created a working one. It simply uses an array with all the possible positions you want the object to spawn (and because of private messaging I have the array of positions @Stephenn wants for their project). The object will move to a random position given from the array, then delete the position from the array. If the array has nothing in it, the object will destroy itself. Here's the link:
                          http://bit.ly/2qcqa76

                          1 Reply Last reply
                          0
                          • S Stephenn

                            Thank you

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

                            @Stephenn mine works too: http://bit.ly/2qboXgz
                            But Aidan's is probably better since it doesn't loop (although you have to enter every position in the array for his).

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

                              @Stephenn mine works too: http://bit.ly/2qboXgz
                              But Aidan's is probably better since it doesn't loop (although you have to enter every position in the array for his).

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

                              @Jack8680 entering all the values actually wasn't that hard. Did them all for the first bunch of x values then just copy and paste with a new x value.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                Stephenn
                                wrote on last edited by
                                #15

                                @Jack8680 I can't get your link to work

                                Jack de WildeJ 1 Reply Last reply
                                0
                                • S Stephenn

                                  @Jack8680 I can't get your link to work

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

                                  @Stephenn copy the link and paste it into safari, works for me.

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    Stephenn
                                    wrote on last edited by
                                    #17

                                    Ok, so it worked, it just loaded a blank page but I opened with hyperPad

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      Stephenn
                                      wrote on last edited by
                                      #18

                                      I loaded it and it plays, but I can't see any behaviors in it

                                      Jack de WildeJ 1 Reply Last reply
                                      0
                                      • S Stephenn

                                        I loaded it and it plays, but I can't see any behaviors in it

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

                                        @Stephenn sorry, forgot to say they're in the global behaviours (you should put them in an object in your scene, otherwise they load on every scene)
                                        0_1494710090399_IMG_3256.JPG

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          Stephenn
                                          wrote on last edited by
                                          #20

                                          Ok thanks

                                          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