Hi,
I’m working on a RTS prototype and am trying to implement an optimized and clean Fog of War.
The main issue I’m having is regarding the multiplayer implementation, i.e. proximity-checking
for units, and runtime instantiation of units when they “appear” on a client’s screen.
##The basic concept
-
The camera hovers at a distance from the ground, and can move freely on the (x, z) plane
(basic case: y/height is ignored for now). -
Between the camera and the ground floats an opaque, black-texture plane. Its position is
tied to the camera’s, and the plane’s texture is updated in real time with a shader. -
The units lie on the ground, below the plane. They are either visible, or not (boolean state),
and aren’t affected by the opaque plane.
###The issues
###Multiplayer implementation
Since the game is supposed to go multiplayer at some point, there is a security issue to handle :
the client doesn’t know where the enemies units are, until they enter one of their units’ view radius.
My guess is that the server sees every unit in the game, all the units have circle colliders, and
whenever there is a OnCollision/TriggerEnter, it does the relevant checks (height comparison, mainly),
and if the unit can see the other unit, the FoW manager of the client is notified.
I have two issues with this:
-
First, regarding the “circle collider” method: how optimized is it? What is the most efficient way
of getting a notification when two entities get close to each other? The game could have around 600
units at the same time, so this part is important. -
For security reasons, the client has no idea where the enemy units are, until the server tells him.
Client-side, what actually happens to the enemy units when they don’t see them? They don’t exist?
What happens when the server tells the client “Hey, there is a unit there!”? Is the unit instantiated
at runtime, with its current animation/position/health/etc?
####Height implementation
Looking at modern RTS, you can usually zoom the camera in very close to the units. The camera ends up
being around the same height as the units… Which means that there is no such “opaque plane”.
Do these games use some sort of volumetric fog? How do they implement their FoW?
Thanks in advance for any help.