hello , I’d like some help
here’s a screen of my character plan , it’s a multiplayer game , when the Ctest function is triggered , it spawns an object , this function works well on the client side and on the server side , but on the sound side it doesn’t work properly :
the server and client hear the sound when they trigger it
the client hears the sound triggered by the server
-the server does not hear the sound triggered by the client
I’ve looked at several tutorials and I don’t understand where I’m making the mistake? attach to component is linked to the line trace on the actor with which I’m performing a certain action.
This sounds like an issue with the Replication you have setup. Where do you run the CTest function from? If your calling it from Client on a Server owned Object then the Server RPC won’t run. It needs to be called from a Client Owned object, *Player Controller, Pawn or Components on these).
Alternatively if your spawning an object can you just have the sound run on the Begin Play of that object instead of running a separate RPC. This way, if the Object is replicated this will play on all Clients and the Server automatically and it saves on a potentially expensive Multicast.
Basically I have a machine that spawns a random actor if the player has money, I know my configuration is weird and I don’t know why it’s like this but it’s the only way I’ve managed to make it work here screen.
Basically, if I want to place a piano on a map and when a player passes by and presses f using a Blueprint interface just to trigger the sound of the piano, the client must own the actor? but how can I do that if I have a lot of interactive objects, for example?
So for something like that case I would move the logic slightly so that when the Player presses F it runs the “Interact” function on the Client but also sends an RPC to the Server to say Im trying to interact. Then from that point you can run the logic you need on the server as well to try interact and if this is succesful Play the sound for everyone.