Download

How to communicate between two seperate actors using BPIs? pls halp

I’ve been trying to get water splashes to work with the UIWS water actors alongside ALS v4.

Since ALS already has an animNotify for footsteps:

So I made a BPI and setup a function that will be used in the UIWS actor as an event:

Then inside the UIWS Water Actor, I set it as an event and whenever the event is fired, I used a UIWS prebuilt method to create splashes at the location of the actor:

The problem is, the event isn’t firing. The method and all works all dandy n fine when I connect it to an event tick with a custom location, it spawns the splash particle.

The anim notify is also triggering the BPI function as I tried to debug it with a simple print string and it works.

However, what I suspect is that I may need to set the target in the BPI’s function to the UIWS actor, as in all other tutorials, the target was the mesh component of the actor of the animnotify itself. Like this:

I’m guessing this is what’s causing the event inside the UIWS water actor to not fire. I don’t know how to target the UIWS water actor as my actor and the water actor aren’t linked by hierarchy so I can’t cast.

pls halp

Also, ignore the comment in the first image. It’s not the level blueprint, it’s the UIWS water actor’s BP.

If anyone is having the same issue as me, you can look up the same question on answers.unreal. It has been answered there. How to communicate between two seperate actors using BPIs? pls halp - UE4 AnswerHub

basically, as @ClockworkOcean has stated,
"You can do GetActorOfClass and get a reference to the water BP. "

This is all you need to get a reference to any actor

image
You should really only do this once during the lifetime of the actor and keep the references in a variable.

2 Likes

I see. Is it very performance intensive? I have this in an animNotify, it’s fired every time my character takes a step

How can I do this once? How do I make a reference that can be used all throughout the game

Do it in the BeginPlay event. Set the array to a variable, then do all your stuff from that variable.

The reason it’s a slow operation is because I think it runs through all actors in the level to find which one’s a match, then adds it to the result. Doing this every frame is not only unnecessary, but expensive.

I don’t have it firing every tick, but on every footstep, and footsteps are slower than event tick. Problem is, I have a VERY large landscape, using level streaming and there are separate water actors for each level, which was recommended to me in terms of optimization. If I was to fire this only once in eventBeginplay, it’d work for the first instance and then stop as I move into another water actor and animNotify would still be trying to send the command to the first instance.

Do you think that lineTraceByChannel would work for getting that reference? like it’s done for footik? line trace is kinda less resource intensive than getactorByClass right?

I’ve still got to find a way to make the getactor thing work for all water actors so I’m thinking of giving linetrace a go instead of getactor and only use getactor when I’m absolutely desperate.

Oh I should add that since I’m using UIWS, I have to make blueprinted actors out of the original water actor in order to add blueprint code and I’m not sure if those blueprinted actors are children of the original water actor class or completely separate duplicates. Up till now, I’ve been calling the single water actor directly through the class which was literally named after the the particular water actor. I didn’t try getting it through the base class and then finding the one water subclass where my actor is. But in order to find that, I’d still need to do some sort of line trace to find which water actor instance I’m on, right? get an equivalence ( == ) node and a loop to check which of the actors from the array match and thennn, send the splash message to that particular water actor.

Of course if linetrace can just get me the actor reference itself, I wouldn’t need all that and just use the ALS’s already built foot ik system to get that reference, which means 0 extra cost cause foot ik is already sending line traces anyway

Still bad. You only do the GetActor function in the BeginPlay event (i.e. only once for the lifetime of the actor) and set that to an array variable, then in the footstep, you access the variable instead of the GetActor function; basically, you replace the GetActor function with a variable.

Yes, in fact, I would do this instead; this way logically makes sense. It will also allow you to work with any material, not just water.

Good optimization!

They’re different in what they do (line trace is for physics, GetActorByClass isn’t), so they’re not really comparable to each other.

1 Like

Thanks! I’ll try Line Tracing when I start setting up water again, bit busy with general landscaping rn

other option ins “current floor”

1 Like

ooohh imma try that when I start setting up water again