Announcement

Collapse
No announcement yet.

Random array picking of multiple Blueprints

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Random array picking of multiple Blueprints

    If I have many copies of one Blueprint in my level, and I want to pick a random one of them from an array and make it do something, how could I do this?

    #2
    Something like this could work, if they are all the same class:

    Click image for larger version

Name:	eeMV7bB.png
Views:	1
Size:	47.2 KB
ID:	1066378

    edit: if you already have them in an array, then obviously you don't need the Get All actors of class
    Last edited by Mosel3y; 02-12-2015, 10:56 AM.

    Comment


      #3
      If you do a get all actors of class, get the length and plug that into the max value of a "Random Integer in Range" node, then plug that into the index value of a "get" array node, you will achieve what you are looking for.

      Attached Files
      Adam Davis | Marketplace Support | Epic Games
      How to report a bug? | Installation & Setup issues? | Answerhub Bug Reports | Twitter

      Comment


        #4
        Originally posted by Mosel3y View Post
        Something like this could work, if they are all the same class:



        edit: if you already have them in an array, then obviously you don't need the Get All actors of class

        You beat me to it
        Adam Davis | Marketplace Support | Epic Games
        How to report a bug? | Installation & Setup issues? | Answerhub Bug Reports | Twitter

        Comment


          #5
          I did what you did Adam (except I replaced the Print with a simple Set Actor Location, to make whatever random one picked float up so I can see it), but it doesn't seem to work sometimes. I added another part to check the random item for a Boolean variable, and supposedly it should check to see if the variable is false, and if so, it raises the object and sets the variable to true. However, it doesn't seem... accurate. It will raise some of the random items multiple times when it shouldn't allow this, and some of the items it doesn't ever raise. I have no idea why it's doing this and I can't put up a picture currently .

          Comment


            #6
            i havent done that, but why not having the gamestate or gamemode or a Manager Class holding an array of your actors references? I mean event construct of your blueprint will add a new item to that array. Would mean a bit of performance on Loading game but will save you the impact of Get all actors of class during runtime.
            Live long and prosper.

            Comment


              #7
              Click image for larger version

Name:	blueprintmess1.PNG
Views:	1
Size:	103.0 KB
ID:	1066607Click image for larger version

Name:	blueprintmess2.PNG
Views:	1
Size:	100.2 KB
ID:	1066608
              Here is the blueprinting. The blue lines from each picture going off the screen are the same lines. I can't figure out where the error is, it still allows actions for tables that should be unable to be acted upon. I've turned the boolean variable to a default of true for experimenting with it and it works fine then - the problem must be with changing the variable of the Target.
              Last edited by loony123; 02-17-2015, 10:14 AM.

              Comment


                #8
                Hello,
                I deleted last post where i mistaken random int in range instead of random int. I got recently weird issues with random int and it solved when i set a variable once and use this variable instead of output to be sure always have the same random.

                Edit : Not weird if you consider that all non exec nodes are called by each exec node. Then a different number each time.
                Last edited by Fen; 02-19-2015, 04:13 PM.

                Comment


                  #9
                  Well I have it all done and working (did it a day ago but just posting), consider the matter closed.

                  Comment

                  Working...
                  X