Announcement

Collapse
No announcement yet.

How to.. Get Array that Actor is part of

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

    How to.. Get Array that Actor is part of

    I have an array named Unit1 (with the unit being hit in it)
    I have GetHitResultUnderCursorByChannel

    Assuming the actor hit by the trace is in Unit1, how can I get it to return the array so I can use it as the input for the ForEachLoop?

    I've looked for nodes to use for a while and can't figure anything out :/
    Thanks for any help!

    #2
    You can't really do it this way. The array stores just a reference, the actor is not aware which arrays (plural) reference it. Many arrays can reference the very same actor at the same time so... you see the point, I'm sure.

    You could use tags for this. As soon as the actor gets added to a group (and / or an array), give it a specific tag - this can be done dynamically. When an actor is hit, get its tag and then use this tag to find all actors that have the same tag as well.

    Click image for larger version

Name:	tags.PNG
Views:	175
Size:	178.2 KB
ID:	1620725

    Vid:

    https://i.gyazo.com/723090cf9e975a7e...5e722b4329.mp4

    Comment


      #3
      That looks great! But I'm confused about how setting tags works, how do I pick what tag from the tag array the actor gets?



      Maybe i'm missing something but I don't see how I get to choose which array item it gets
      Or do I just create this array with only one item then clear it for use again later?


      Never mind got it!

      It gives all the tags in the array, and you just have to clear it after using it I assume?
      Last edited by Flohhhh; 05-19-2019, 11:41 AM.

      Comment


        #4
        There's a new problem though, and I have no idea where it's coming from, I simplified the movement down as much as possible and it still happens!

        https://i.gyazo.com/30022bc28252f808...2dd47f9e54.mp4


        https://gyazo.com/4646611eba87f08add50575f01a4171b

        Comment


          #5
          Originally posted by LS Floh View Post

          It gives all the tags in the array, and you just have to clear it after using it I assume?
          You do not need to clear them, but you can replace all of them (as you do it with Set), you can change one of them (in order to assign the object to a different group, for example; with Set Array Element), you can Get one, any or all of them as I did in the image above. And you can also assign default ones to an object class:


          Click image for larger version

Name:	Untitled.png
Views:	164
Size:	39.7 KB
ID:	1621449

          Do note that components that are a part of the actor can have their own tags as well.

          Comment


            #6
            Originally posted by LS Floh View Post
            There's a new problem though, and I have no idea where it's coming from, I simplified the movement down as much as possible and it still happens!
            What still happens? I see little people jogging around.

            Comment


              #7
              Originally posted by LS Floh View Post
              There's a new problem though, and I have no idea where it's coming from, I simplified the movement down as much as possible and it still happens!

              One thing that can be improved here is storing the Out Actors in a variable, right click that pin and promote it. Then use it, it will much safer this way.

              Comment


                #8
                I left click to select all of them, then an apparently random selection of the characters move when I right click.

                They all for sure have the same tag, "Unit1" (I double checked in the tags in the outliner while playing.)
                I also made sure that all of them were part of the array on left click as well.

                A better video:
                https://i.gyazo.com/fd371afd3398367e...e0a08e203c.mp4
                Last edited by Flohhhh; 05-19-2019, 12:18 PM.

                Comment


                  #9
                  Check my comment above. The way you pull data out of the node does not seem safe at the moment. Do tell if it improves things.

                  Comment


                    #10
                    That wasn't it, definitely will help in the future though.

                    Here's where I'm at now, result hasn't changed from videos above.

                    It must be the way i'm getting the controllers, or the way they're moving.

                    Comment


                      #11
                      I saw you print the result of the Out Actors - are the expected numbers?

                      Comment


                        #12
                        Yup, exactly correct.

                        Comment


                          #13
                          Consider doing something like this in the ai class to visualise the tags / groups:

                          Click image for larger version

Name:	Capture.PNG
Views:	162
Size:	63.1 KB
ID:	1621505

                          Perhaps it will shed some light on it, in case that's the culprit here.

                          Comment


                            #14
                            Seems to be working properly, if this is what you meant.

                            https://i.gyazo.com/a4ad8b2008fd74e5...a9bd802a67.mp4

                            It's such a simple string of code why is this so difficult
                            Last edited by Flohhhh; 05-19-2019, 04:10 PM.

                            Comment


                              #15
                              If Unit1 -> Contains( hitActor ) then Unit1 -> do stuff.
                              If Unit2 -> Contains( hitActor ) then Unit2 -> do stuff.
                              | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                              Comment

                              Working...
                              X