Spawned actor casting back to its spawner.

So I’m trying to have my spawned actor cast back to switch a boolean of the actor that spawned it. I know 2 workarounds but I want to know how to do it correctly.

A little bit of context for how my blueprint works: I have a planter box and when I interact with it, it spawns a plant actor that goes through a timeline. After the timeline finishes I want it to cast back to the planter box it’s in so it can swap a boolean in the planter letting it know that the plant is fully grown.

One of the workarounds I have is that I get the overlapping actor for the plant growing and use that as the object I cast to which works. However, if in another instance my plants wasn’t overlapping the box it wouldn’t know what to reference. Seems like a bad habit so I don’t want to do that.

The next workaround I have is to just set a delay in the planter box BP as the same length it takes to grow the plant and then flip the boolean, but that also feels wrong and it would require editing multiple variables If I wanted to change the grow timer for the plant.

Heres my Blueprints for more info:
Planter BP


Growing plant BP

You could use the Owner:

My Products

1 Like

plant box


plant

The plant interface just has function “FullyGrown”

1 Like

image

Owner is already here.

have my spawned actor cast back to switch a boolean of the actor that spawned it

While an Interface + Owner would, ofc, work well enough, isn’t this an obvious job for an Event Dispatcher? As in:

3 Likes

This. :point_up_2:

Event dispatchers might help you with this.

In the spawner class bind a dispatcher that will broadcast once the plant actor finishes what its doing. No need to cast back up.

Thanks for all the answers, I’m still very new to BP and I don’t know a lot of the things I can use besides some of the basic stuff. I also didn’t even notice the drop down in Spawn Actor to get Owner, I only saw Instigator. Event dispatchers seem useful so I’ll also have to look up some stuff to that. I got it fixed because of your suggestions and now know multiple ways to get do it next time I do something similar.

1 Like