Improbable Icon

Server side collision Questions


#1

I am using the Wizard demo as a starting point for my own project. I have replaced the player character with my own assets and now I have completely disabled all of the NPCs and other features of the wizard demo and replaced the world with my own. I am now trying to get the player character to be able to walk around on my custom terrain. I am guessing the Physics server is authoritative over the player’s position and movement. When I walk around the avatar doesn’t walk on the terrain like expected but stays at a steady y position. I’ve set the Rigidbody to respond to gravity and everything but it still just stays at the same y position. If I set the client’s version of the Avatar to react to Gravity then there is a constant fight between where the client wants the avatar and where the server wants it which creates a lot of jumping around.

Is the Wizard Demo’s Character controller just not set up for anything but the flat terrain or am I missing something?

Also yes I have the same terrain in the client scene and in the Physics Scene and yes they match up properly with position and everything.


#2

Hey @revivalinme, I’ve done some digging in Wizards and from what I can tell positions should work fine in all 3 dimensions.

The client is authoritative over the player’s movement (although the physics worker is authoritative over the position component itself). The client in the script PlayerControlsSender.cs takes the position of the player’s Rigidbody and uses this to send a PlayerControls component update. The physics worker in the PlayerControlsVisualizer.cs script listens for updates to the PlayerControls component, and when it gets an update, it tries to move it’s copy of the player’s Rigidbody to the specified position. Then on every tick in physics worker’s TransformSender.cs script it checks if it’s local position has been changed, and if so, sends a Position component update with the new position.

Basically, the client is authoritative over the position of it’s own player. It sends it’s position to the physics worker, which then sends out the official update to all other physics workers and clients that have your player checked out.

So I don’t think that the problem you are experiencing has to do with the way the transforms are being communicated between the client and server, and I’d guess it might be problem with your local client physics. Have you tested your terrain physics in an offline environment?


#3

I haven’t tested it this time offline but I’ve used the same method for terrain in past prototypes and it;s worked fine. It’s basically just a grid of 3x3 Unity Terrains.