Clients can't request to delete actor?

So I am trying to have an actor destroy when someone presses the interact key.

So on pressing interact, a trace for objects will be called. If the object can be destroyed, then it will call “DestroyHitActor”.

This should destroy the actor hit by the trace…

(Note that Actor to Destroy should be conneted to the destroy actor function.)

Problem is that the server will not allow the client to “Call DestroyHitActor”.

Sorry if this is a dumb question, I’m pretty new at this.

Also, is it normal that when I have two players in a game, one is acting as a server? How can I make them both act as a client?

Hey there!

What you’re running into here is a client/server replication issue - you’ll need to tell the server to delete the actor for you in a multiplayer game. I’d suggest reading these to get your feet wet:

https://docs.unrealengine.com/latest/INT/Gameplay/index.html (Scroll down to the sections on replication near the bottom)

As for the second part of your question, the default behavior for UE4 is to have one instance as a listen server and the rest as connected clients.You can override this by expanding the advanced play options (the small triangle near the play button) and ticking “Dedicated Server”.

So I looked over that, and didn’t really find anything that I didn’t already know. I looked around a little more, and this is all I could find that maybe would fix the problem.

This is my level blueprint.

It didn’t work…

When you say “you’ll need to tell the server to delete the actor for you in a multiplayer game” what do you mean? Is that not what I am doing here? What I’m getting out of it is that the server is just refusing to delete the actor.

Truth be told, I’m not very good with replication. I know where the issue is, but fixing it is a whole other can of worms.

Does the actor disappear on any of the clients, or does simply nothing at all happen? Additionally, could you try adding a breakpoint right before your DestroyActor to see if the execution ever reaches that node?

When the client calls the function: I placed a print string node at the beginning of the function to see if it was ever being called on the server. It appears that the client is calling the function, but the server isn’t doing anything.

The “CheckForPickup” function is being called, but nothing else happens. The actor isn’t destroyed on the client or server.

When the server calls the function: The function works as expected.

I wonder if this might be a problem with the event delegate. I haven’t completely grasped how replication works yet, but I know that the delegate will only fire on actors to which it is registered. You could add a Print node between the Event and the actual Destroy Actor call to see whether the event even reaches the client.

Add two more Print nodes after your cast (success/failed) to verify that the following two assumptions are actually correct:

  • Does Get Player Character return a valid First Person Character for both client and server? (maybe the client characters are created later)
  • Are the returned characters different? (maybe the first index is always the server’s character)

I put a print string node in at the beginning of the function and nothing happened. Its almost as if the server is completely ignoring the client.

I think I have the basics of replication down, but to my knowledge, this isn’t a problem with replication. When the client calls the event, the event is neither occurring on the server or client.

I cant really answer your other two questions, because it doesn’t appear that the event is ever being executed in the first place.

I really can’t grasp what the issue could be here. I’ve tried everything I can possibly think of, but the client just refuses to ask the server to delete the actor.

When the server character calls the destroy event, everything works as planned.

Maybe I can make this easier to answer if I state what I want to happen.

When a client presses the interact key, a trace function will be called, and if the trace hits an actor in the “Pickup” group, then that actor will be destroyed.

I meant output the Get Player Character result in the BeginPlay event when you’re registering the delegate. I suspect that your DestroyHitActor event only gets registered on the server and I’m trying to find out why.

I am having a similar issue with a door I have created. I have it so that the door can be opened and closed by the server, visually showing the door open and close to all clients connected, and the clients connected can walk through it, etc. But the server has to do all of the interaction. I can’t seem to make it so that clients can trigger the door, send that information to the server and have the server replicate the data to all clients.

Where I am having a hard time is having my collision box read when the client is hitting the F key… It knows when the server does…