jbs 12 Report post Posted November 3, 2019 So, im doing a first person shooter using three.js. Now the question, that i have, is, how do I do physics. First of all, player movement, so the player can not walk through obstacles and jump on crates and not fall into the ground. I gotta do this client-side (for prediction) and server side (so players can not cheat). I dont know, whats the best way to go here, since it also has to be done server side, it shouldnt be too expensive. Do i use a physics engine like cannon and just let the engine handle everything, client and server side aswell ? Quote Share this post Link to post Share on other sites
Snubber 0 Report post Posted November 5, 2019 So I am working on a 3rd person game in three.js and I can kinda help here. I use a RayCaster: https://threejs.org/docs/#api/en/core/Raycaster to detect any collisions with the environment. I do this whenever the player character moves from point A to B. So let's say the player is at A and is moving to point B (in the next frame). I create a RayCaster that originates at point A and is directed at point B. If the RayCaster collides with the environment then I do not allow the movement. This approach is pretty simple and there's a couple issues with it that I am working on figuring out: It's inefficient. Because I'm checking if the RayCaster collides with the entire environment (not just the player's immediate area). I plan on fixing this using spacial indexing, I just need to figure out how to do that. I don't know how to do this on the server side (to prevent cheating like you mentioned) Any ideas there would be amazing. I hope this helps! Quote Share this post Link to post Share on other sites