Here’s screenshot showing the boars following the terrain as they move around:
I’ve been thinking about how I want to do things like this. Specifically, how much I want the client to control the world, and how much the server should control. Right now the server only keeps up with the x and z coordinates of each boar. The client (browser) then takes those coordinates and figures out the terrain’s height at that point, then draws the boar there. I’m doing it this way because determining the terrain’s height requires access to the terrain data as well as the THREE.js raycasting function, and giving the server access to that information would make it much more complicated so I just haven’t done it yet. This probably isn’t a workable scheme in the long run. Soon enough I’ll want players to be able to attack the boars, but to do that I’ll need to know if the boar is within the player’s attack range, which will require definitive information about the boar and player’s x, y, and z positions. In order to prevent cheating or otherwise messing with the game, I think I’m going to have to assume the client is completely untrustworthy. It’s basically a terminal that displays what the server tells it to.
This is, of course, not the final answer on this topic. It’s something I will need to do much more research and testing on because I’m making some significant assumptions to come up with the conclusion above. But for now the boars roam around on the terrain and everyone is happy.