Jump to content
  • Advertisement

Recommended Posts

Hi ,

I've been working on some on a game server in Unity. And I was wondering how I should handling collision detection.
I'm using TCP at the moment.


I thought I'd write a custom tool , that would find all objects in the game scene. And push that to a file. And let the Server read it out. So it know's where are collision objects are.
Not sure if this is the best approach.

I also wonderd how to handle character movement correctly. My client sends each 100ms a update of he's position (if they moved).
The server sends each 150ms to all clients all positions.
But I want to check if there are players in he's area. But that would be again a lot of calculations for the server.



Edited by Dennis de Bruijn

Share this post

Link to post
Share on other sites

For a first person shooter, you will typically run the same gameplay/physics code on the server as on the client. This allows the server to make determinations about things like "was the door open" or "could A see B when shooting?" Players will then send their control inputs, rather than their positions/velocities, to the server. This lets the server avoid cheating players that would try to teleport across the level by sending a different position than they were previously in.

If you want a simpler physics model, then yes, you will have to somehow extract collision geometry, and use some collision testing library to check player movement. If you don't care about teleporting (or want to apply a maximum movement speed) then you could check the path from previous player position to current player position every 100 ms. Note that, if the player controls the actor at a higher frame rate, the player may be able to turn a corner that the "straight cut" wouldn't let them turn. Thus, the packets you receive every 100 ms might contain a number of updates -- say, the last 6 simulation steps, if you simulate at 60 fps.

Or you can use a platform that just does all this for you. Unreal Engine or Roblox come to mind as having ready, built-in networked physics, where you don't need to worry so much about it yourself.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!