Announcement

Collapse
No announcement yet.

Actor reference with variables..

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

    Actor reference with variables..

    Hello i need some help here...
    I have several different actors that spawns 1 specific actor.
    From the spawned actor is it possible to get the variables from the different actors that are spawning without doing 20 or more casts? I tried set owner but it doesnt output any variables like it does with casting..

    Thanks

    #2
    Muntrax

    Everyone's use case is different.... How many variables are we talking about?

    1. If its just a select few, you could look at passing them in during the spawn by exposing variables on the Spawn Actor node.

    2. You could also add them into a Globals BP-Function-Library using helper functions.

    3. If there's too many you could embed them inside a Struct, give them their own BP, or use arrays (if they're of the same type). See if BP supports Array-of-structs...

    4. At a more basic level, you could do all your Casting in Begin-Play and then just use local BP variables, so at least you don't have Cast nodes everywhere...

    Comment


      #3
      Not entierly sure what you mean but Google is my friend
      To make it clearer, I have actor 1, 2,3,4,5,6 wich are very different but they all spawn Actor 99.
      Inside the Actor99 blueprint i need to reference the actor that spawned me, and it could be Actor 1 to 6. And when i get the reference i want variables that are inside the spawner actor, for example actor 5.
      If something happens to actor 5 i want to update Actor99 that was spawned from actor 5 without having to cast-check every actor...

      But I will look up what you said and see what it all means.

      Thanks for the reply!

      Comment


        #4
        Muntrax

        Google is your friend? Hardly... Try a privacy based web search engine (but NOT Startpage / DuckDuckGo)
        Startpage! .........

        Ok, here's the thing. As soon as Actor99 needs to directly access vars from 1-6, you're into Casting. Two commonly used solutions to help are Interfaces and Event-Dispatchers. These are like adding options 5 and 6 to the list above. However, they'll both take some learning investment from you upfront, but it'll be worth it long-term. Both have pros / cons so take your time, as its a critical area! Can't recommend tutorials, just not a fan of any. Instead I always recommend deconstructing existing working projects, as its the most immediate and powerful learning there is in my view... Good Luck!
        Last edited by EntrpriseCustomr; 01-29-2020, 06:31 AM.

        Comment


          #5
          Originally posted by franktech View Post
          Muntrax

          Google is your friend? Hardly... That's Startpage! .........

          Ok, here's the thing. As soon as Actor99 needs to directly access vars from 1-6, you're into Casting. Two commonly used solutions to help are Interfaces and Event-Dispatchers. These are like adding options 5 and 6 to the list above. However, they'll both take some learning investment from you upfront, but it'll be worth it long-term. Both have pros / cons so take your time, as its a critical area! Can't recommend tutorials, just not a fan of any. Instead I always recommend deconstructing existing working projects, as its the most immediate and powerful learning there is in my view... Good Luck!
          Thanks alot for the help. I know them a bit but I will dig into it.
          Appreciate it.

          Comment


            #6
            For information, this was solved using a event dispatcher in the actor99 that called it. And then bind the event from the spawner actors. I set some booleans as input on the dispatcher. Thats all i needed, thanks again franktech

            Comment

            Working...
            X