Download

Networking | How to get a specific actor.

So i’m currently working on a multiplayer project, and i have a object which is a buff, but the thing is. How do i get the specific actor which collided with the buff and call the event on that character. Because what i had before was when the buff was “taken” it gave the buff to the player 1 no matter which player took it. Is there any specific node on how to get the actor which did the action?

bump

Does anyone have a clue?

so you pick it up on collision? make “On Hit Event” or “On start overlap event”. -> get the Hit Actor/other actor node -> drag a wire from it and make a cast to your char. then on the blue nod of the cast you can drag a wire and call the function of the specific char you want the function/event to be executed.

You can get the colliding actor by using the “OnComponentBeginOverlap” node for your collision. From there you can get the “Other actor” and cast/check which actor is colliding. If the actor is your player, then you can call a server side event on the character or through the pickup.

Capture.JPG

Hope this helps!

I think i didn’t word my question right, my problem is that i have 4 characters, and i don’t know how to get which actor took the buff. :stuck_out_tongue:

save the cast in a reference variable and that one is the char that took the buff.

I don’t quite understand what you mean by “save the cast in a reference variable”, As of now i have 4 pawn blueprints, which give me the option to cast to 4 different characters, but how does the buff know who took it and give the character who took it, the buff?

if they share one parent you can still cast. and the outcome is your char. this char you can safe.
or make a reference variable of type Character or Pawn and store the cast output (cast to character or pawn) into this.
what ever gets saved in that variable after the cast is the character that picked the buff. you can directly address him then with the variable

Can you try to blueprint this, i’m not sure if you’ve understood my question. Cause they’re all individuals characters and don’t share anything. They got their own floats and values so own.

If that cast to character is not the right character, on the output “cast failed” have it cast to your next character type. ect ect.

But there isn’t any “right character” cause any character is available to take the buff.

-To make it clear once for all!-

932cb99cc6ca9a324838605a8ab8b15f2d1a3f4f.jpeg
This is what i want do.

your problem is the way you made the chars. they should share the same parent if they share functions like give buff.
now if they have the same parent you only would have to cast to the parent and execute the give buff function. nothing more. he would apply it to only the overlapping actor no matter of the colour.

what vandalay corectly said is that in your case you will have to cast first to blue char, if its a blue char you execute “give buff”, if its not blue char, you cast to red char and on sucess you execute “give buff” and so on.

But as vandalay said, if the “Cast Fails” it should cast to the next character. But the cast would never fail cause what stops it from casting to the blue character? As of now i have it whenever a actor overlapses the buff collisions box, the buff destroy itselfs and then proceeds to cast to BlueChar so how would it fail? Cause casting doesn’t check if it’s actually the blue char overlapping the buff.

you should maybe read up about casts and how they work. :slight_smile: “Cause casting doesn’t check if it’s actually the blue char overlapping the buff.”
<- yes, it does exactly that, if the blue char is a seperate blueprint.
if the overlapped char is blue and you cast for blue char bp, he will succeed and you can execute his function. if it fails you make a second cast that is plugged in to the first casts “failed” path. and now you cast for the red player. if it succeeds you can execute the function. if not, cast for green and so on.

youre basically asking this: i got an overlapp, is this overlap a bluechar bp ? if yes then use exactly this char reference and execute his “give buff” function. if not, you ask for the other sorts of bps

I honestly didn’t know, my bad. :smiley: :rolleyes:
I’ll try it out and report back if it works!