x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Proper way to destroy replicated Actor?

Can anyone in here explain how to properly destroy a replicated object?

For instance, if I have a replicated Actor blueprint and I want to destroy the Actor while running an internal function, can't I just use a run-on-server RPC and Destroy Actor in the event?

When I try this, it doesn't work. It also doesn't work if I try with multicast (thinking maybe it's only getting destroyed on server but not on clients). Is there something basic I'm missing? Do I need to call into game mode? (that didn't seem to work either)

This would be a server owned Actor with a function triggered by a pawn overlapping. The function definitely runs, but Destroy Actor doesn't destroy actor.

Specifically, the functionality is "reduce health on the Actor, if it gets to less than 0, destroy it". Health is verifiably 0, as far as I can tell "Destroy Actor" should run, but no errors are displayed and the actor is not destroyed. What gives?

Product Version: UE 4.13
Tags:
more ▼

asked Nov 07 '16 at 04:53 AM in Blueprint Scripting

avatar image

dave_sullivan
70 4 7 13

avatar image Rekenq Nov 07 '16 at 05:07 AM

If you destroy a replicated actor on the server it should automatically be destroyed on every client. Can you show some screenshots of your code?

avatar image dave_sullivan Nov 07 '16 at 06:00 AM

Yes, please see attached. First image is the "die" function which plays some explosions and then destroys the actor (the explosions play, the actor does not destroy). The second is of the "laser hit" function where a laser overlaps the object and triggers and adjustment to health (and possibly a call to "die"). The actor and all variables concerned (except HUD, which is kept dumb) are replicated.

alt text

alt text

avatar image Rekenq Nov 07 '16 at 06:22 AM

Wait are you getting the value, to check if the player should die or not, from a widget?

First thing, widgets are local, so even if you are feeding it the replicated data from your player it might not have the correct data when you do that check, why risk it? Why not get it directly from the player?

Secondly, why are you calling a multicast inside a multicast? Multicast functions only work when they are called inside the server. Even if your first multicast (MulticastOverlapEvent) is called in the server, every client will receive the order to execute it and so then every client will try to execute your Die multicast which will not work since it isn't being called inside the server in the first place. Besides that, multicast RPCs should preferably be used only for aesthetic utility and not heavy gameplay logic, like a collision or dying.

So there might be multiple problems here. One of them is that your Die function is not getting to all clients since it is inside another multicast. The other problem is that your Health Val Percent variable doesn't even has the correct value so it is failing the condition.

Edit: Can you show the code for the overlap event too please? The actual BeginOverlap node that calls your multicast overlap

avatar image dave_sullivan Nov 08 '16 at 05:12 PM

Hey, thanks for your reply. I'm attaching a screenshot of what ended up working.

As you suggest, there were a few things wrong. I think what may have been messing me up is the HUD is a 3d hud on the AICore object, so changes to that end up needing to be multicast, while the actor destruction only needs to happen on the server.

2 multicasts in a row is silly, you're right.

Anyway, thanks again!

alt text

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question