I’m trying to create a combat system with client-rendered effects, and I’d like to know if there’s a way to capture the animation event on all clients without the need for a remote event or function. Additionally, I don’t want to trigger the animation on the server. I’m trying to do this efficiently to optimize the game, but I’m having trouble synchronizing the VFX effects with the animation itself.
I have no idea how to do it efficiently; can someone help me?
The server is used to synchronize things across clients. What you are thinking of is a remote event, but you specifically say you don’t want to use remote events.
The thing is, I would have to use the client’s remote event to trigger it, then the server receives it and forwards it to the other clients, but this would create a lot of delay. The server renders the hitbox, which is an invisible part to which the visual effect is attached with welding. However, due to all this lag, the effect would likely look messed up.
Get each character’s Animator object, and listen to its AnimationPlayed event. The event passes the newly playing animation track, so you can identify exactly which animation is playing by checking the track’s Animation property. Then you can listen to the track’s events and create the proper effects entirely on the client.
I’ve never tried this before, so let me know if it works.
In this case, I can capture any animation that another player is playing and wait to hear the event from it. So, as soon as the player joins the game, I would need to set up an initialization for them to connect all the players present to this listening function. Also, every time someone new joins the server, I would have to connect this event, correct?
Or I could pass this to the server, and the server only returns the player of the animation currently playing, so that everyone can connect to that player’s event and wait for the animation event to happen. Once it’s done, we could simply disconnect the event to avoid having multiple connected events on the client.
What would be the more optimized option, or would it not affect the game’s performance?
Yes. You would also need to disconnect any connections when a player’s character is removed.
I wouldn’t involve the server at all; everything would be much easier to handle solely on the client. You would have to use almost the exact same setup on the server with all the connections and disconnecting as the fully client-based method (except for connecting to all present players) plus some networking for the remote, and there is also the issue of latency (an animation event might get skipped for especially laggy clients) and high network usage if you send a lot of data through remotes often.
“Okay, I will give it a try. I’ll integrate this system into the rest of the combat system on the client-side. I’ll post the results here later this week. Thanks for the help so far.”
I’ve been testing, and I can replicate the animation events through the passed event; it worked quite well. I still have some issues related to player and character loading, but nothing I can’t solve with the game’s loading system.
Thank you very much for your help; it made all the difference.