Question on Ghosting of players and AI's
by Vince Gee · in Torque 3D Professional · 01/18/2012 (5:54 am) · 8 replies
I have a question about how the server handles ghosts. Does the server ghost all objects in the zone to each player or does it cull out the objects which are beyond a certain range from the player?
If it sends every object down to the player, has anyone written a resource to only send objects to the player within a certain radius?
Vince
If it sends every object down to the player, has anyone written a resource to only send objects to the player within a certain radius?
Vince
About the author
www.winterleafentertainment.com
#2
01/18/2012 (6:16 am)
So the "visibleDistance" param in the mission file tells the server what radius around the player to ghost objects?
#3
So is this how all objects are determined if they are in scope?
01/18/2012 (7:02 am)
void NetObject::onCameraScopeQuery(NetConnection *cr, CameraScopeQuery* /*camInfo*/)
{
// default behavior -
// ghost everything that is ghostable
for (SimSetIterator obj(Sim::getRootGroup()); *obj; ++obj)
{
NetObject* nobj = dynamic_cast<NetObject*>(*obj);
if (nobj)
{
AssertFatal(!nobj->mNetFlags.test(NetObject::Ghostable) || !nobj->mNetFlags.test(NetObject::IsGhost),
"NetObject::onCameraScopeQuery: object marked both ghostable and as ghost");
// Some objects don't ever want to be ghosted
if (!nobj->mNetFlags.test(NetObject::Ghostable))
continue;
if (!nobj->mNetFlags.test(NetObject::ScopeAlways))
{
// it's in scope...
cr->objectInScope(nobj);
}
}
}
}So is this how all objects are determined if they are in scope?
#4
Specifically the section, "Network Ghosts and Scoping".
The gist of it is all world objects in the engine derive from the NetObject class (the actual hierarchy looks something like NetObject -> SceneObject -> ...). The NetObject class, by default, attempts to scope all objects to every client (as you can see from the bit of code you posted above). This behavior is overridden by the child classes in their own onCameraScopeQuery() methods. This allows each class to adjust the scoping rules to their specific needs.
01/18/2012 (8:14 am)
http://docs.garagegames.com/tgea/official/content/documentation/Engine%20Overview/Networking.htmlSpecifically the section, "Network Ghosts and Scoping".
The gist of it is all world objects in the engine derive from the NetObject class (the actual hierarchy looks something like NetObject -> SceneObject -> ...). The NetObject class, by default, attempts to scope all objects to every client (as you can see from the bit of code you posted above). This behavior is overridden by the child classes in their own onCameraScopeQuery() methods. This allows each class to adjust the scoping rules to their specific needs.
#6
01/18/2012 (8:48 am)
Awesome! And it would be cool to make those adjustments visible in the game options dialog somewhere, too.
#7
01/18/2012 (8:57 am)
Well, you have to assume their will be people who will build a ai radar for your game sooner or later, this at least allows you to limit what they are ghosted. I really don't have a need to allow a user to change the radius because of server load issues. Yes their client might support the additional rendering, but I don't want the bandwidth to my server consumed by someone wanting to download the whole zone.
#8
And some games have used radar systems with adjustable ranges (5km, 10km, 25km selectable) as well.
"Many applications and possibilities for this" in tuning and gameplay - that's kind of where I was going with that.
01/19/2012 (6:22 am)
Well, the default camera scoping system prevents the "download the whole zone" approach. Your idea is nice for setting separate view distances, etc, as in most mass market games today. You can set view distances on various categories of objects like grass, trees, detail objects, "people" within the limits set in the UI. Some of these aren't really affected by ghosting (grass, in Torque) while others obviously are.And some games have used radar systems with adjustable ranges (5km, 10km, 25km selectable) as well.
"Many applications and possibilities for this" in tuning and gameplay - that's kind of where I was going with that.
Torque Owner Richard Ranft
Roostertail Games