Hello I am developing a game and in that game there is an ocean and ships. I want to take the game to the next level so I decided to build custom Gerstner waves. Thankfully for me Gerstner waves are heavily documented and explained even outside of Roblox but I am having a lot of trouble getting parts to float on my waves.
I am trying to keep the waves on the client side for server performance and they do look good but now I am having trouble making the server understand where to float parts that I add. I have found a few methods in my research that people use. 1) Using getServerTimeNow() on both the client and the server and running the calculations on the server but I am struggling to figure out a way to locate which grid I am in to see which y value I should set it at. 2) Use a module script that both the client and the server look to find the y value which to me doesn’t seem safe or efficient.
Maybe there is something that I am missing I would appreciate any input or help that anyone can provide.
I don’t really know much about Gerstner waves but you might be able to use octrees to create an get the grid you are in or you could just use linerVelocitys to simulate buoyancy.
First off I really appreciate the help and I will look into octrees to see if that will be of any help sorting the grids and I think your right about using liner Velocity. Is it efficient to loop through all the bones in the Gerstner wave on the server even if im not changing anything? I’m not know how demanding that would be.
I believe it would have some sort of impact on the server’s performance so I suggest you only query bones on the client and in a radius of the player, again octrees will help you find object in a radius. Also if you want to simulate buoyancy you should take a look at this post:
If I’m doing this in the radius of a player on the client then how would i locate parts for buoyancy on the servers end? I have created my waves sort of like chunks and they only start motion within that area. As I continue doing this my question is more of how do I locate wave height of a certain location on the server which would have to be completely separate from my clients graphical waves.
Firstly I want to point out that rendering players ‘ships’ for other players should not be handled via the server but instead the rendering information should be communicated directly between the clients. What I mean by this is that players ‘ships’ should only render on other clients once it is in visible range and should not be rendered on the server all the time.
If however you need the information on the server i suggest using a table that only contains the ‘ship’ itself and the x,y coordinate of the bones (the x,y coordinates should be relative to the world). Also you might be able to reverse engineer the wave formular by inputting the current height of the bones to find the next height. This would save you from needing to constantly update the server on the height of the bones but at the cost of a slight desynchronisation