Hi, I am looking to understand when to add code server side or client side.
For most features, the answer is clear, but in some situations I get a bit torn.
For example, let’s say we want to make an enemy in a game. The enemy just walks back and forth. When the player touches the enemy, the player is stunned. When the player jumps on top of the enemy, the enemy dies and the player is rewarded a coin.
The resources used are a BodyVelocity updating the movement of the enemy. Particle effect played on player when stunned as well as stopping players movement and jump. When enemy is killed it also plays an effect as well as flashes its parts from opaque to transparent for a second, rewards the player, and then is deleted from the game.
Now implementing this server side initially makes sense to me. You have an enemy that everyone needs to see. It will be moving back and forth, so you would want to be sure that its’ position is the same on everyone’s machine. Rewarding the player server side instead of client side is safer.
But, I have read many posts regarding keeping the server code light. So this leads me to question, is doing it on the server the correct way? If not, I have a hard time understanding how parts of this could be implemented client side, such as moving the enemy (since if one clients code is moving the enemy, then all clients are moving the enemy).
Overall, I think I am looking for a set of guidelines I can checkoff when implementing a feature that help me determine the best place to put my code.
Thank you all for your help