I’m making a top-down tank game like diep.io, with the camera fixed to the tank (no camera rotation), the tank barrel should follow the mouse and WASD keys are used for movement along the global X and Z axis.
The camera bit is finished, when a player joins, a tank is cloned from ServerStorage, and the player’s camera is moved off the character to above the tank’s base, with a CFrame update on RenderStepped, so it follows the movement of the tank.
As for movement and rotation, I got the best results with the tank’s base anchored above the ground, and connecting RenderStepped on the client to a RemoteEvent that updates the CFrame of the tank on the server according to the mouse Hit position (using tank’s Y position), and the server also received two parameters velocityX and velocityZ that are either -1, 0 or 1, depending on which of WASD keys are pressed.
However this made the rotation lag while the tank is moving, would probably choke the server with more than a few players, and I’d have to add additional checks to see if the tank position is out of bounds (instead of having a wall for tanks to collide with) which would surely choke the server.
Plus, I don’t want instant movement on WASD keypresses, rather a gradual increase/decrease in speed like in diep. This would call for a more complex script, when I know there are BodyMovers that can achieve this and replicate automatically without RemoteEvents. But I didn’t have much luck with BodyMovers either, I don’t know much about them.
So in short: I need something that will move the tanks only on global X and Z, that will have smooth gradual speed increase/decrease, and allow having a final bound on the map which the tank can’t cross. The tank should rotate on the global Y axis towards where the mouse is pointing, even when the tank is moving, but X and Z rotation should be locked. And I need all of this to replicate smoothly to all clients… I think a few frames of lag should be fine, but nothing more than that, as everyone needs to know where to aim and stuff.
Any suggestions are greatly appreciated.