Hi there, I’m currently making a combat system. My last post was about detecting and tracking player states on the client. This is now about sharing and detecting other player / NPCs states on the server.
If I have a server-sided script that handles blocking and parrying, I would have to set up all of these values:
And check if they are blocking (The bool value isBlock is equal to true) and so on. I want to find another way around this as this feels very “hacky” and inefficient due to the time it takes for me to set up all of these values and calling them from multiple scripts.
Any help is appreciated!
Well personally I would use attributes. Genearlly when I’ve done similar things in the past I’ve just had a single variable that takes a string as a state. That way instead of checking isBlocking I would check State == “blocking”. And my code would just change that string whenever the character moves onto something else. Might not be the best style for you, but it’s my preference for sure.
Hi, thank you very much for your reply! I have almost totally forgotten about string values, I will definitely use that for tracking states across multiple scripts. But that’s just for states only though, right ? Like is attacking, is sprinting, is blocking, etc. How would I go about passing all the information in the original image I posted (The time when the player blocks, their block bar, etc, …). I’m very certain that remote events works, but that only applies for players vs players, not players vs NPCs. Is that possible ? Or am I bound to using values ?
Remote events work for client/server communcation so they are only usable between a local script and a server script. But there are bindable events which will work between scripts of the same type.
Generally though I would design the system on a basis of letting other systems in on the minimum amount of information necessary. Why do you need to know when a player started their block from another script? If it’s for something that the script managing the block state can do, I would heavily recommend doing it there instead.
Bindable events work for players vs npcs, but doesn’t for players vs players I assume. The block time is pretty much the tick(), or when they started their block, I use that value to perform perfect blocking, comparing the time when they took damage with when they started blocking