Game Development Community

Question about Ray casting and server/client IDs

by Jason Gossiaux · in Torque Game Engine · 02/28/2008 (6:23 am) · 4 replies

Well I've decided to add some simple pathfinding to my game, and am pretty much starting from the AIPlayer example in the starter.fps code. I've done my homework reading extensively about server/client/ghosts but am still somewhat confused as to how the engine decides which IDs are returned.

For example, in my AIPlayers::think() routine I have them do a %hitobject = ContainerRayCast(%eyeloc, %endloc, %maskbits, %obj); between two points. Then I do a %serverid = getWord(%hitobject,0) to get its ID. I am noticing this ID is the client ID I think (same # as shown in the editor. But isn't this code running server-side? By what mechanism did it pull up the clientID?

Going beyond this I'm somewhat confused how people loop through objects in their gameworld for processing. I understand we have MissionGroup and MissionCleanup we can loop through - but is this really the most efficient way?

Say I want to find the nearest barrel object to raycast to. Right now I am kind of looping through my MissionGroup/Cleanup and looking for it by it's name/datablock. Oddly those too return what appear to be clientIDs though. I've honestly searched for some examples of people doing this but just can't get my head wrapped around it yet :P

Thanks a bunch for any help clarifying this for me!

#1
02/28/2008 (7:34 am)
Depending on the raycast's mask, it should be a player object or perhaps a shapebase, which is representative of the Player Object attached to the client. You can't directly raycast collide and find a client (GameConnection object). hehe

Those are server side object IDs. Every player is associated with a client object.

As far as looping goes, they tend to be pretty efficient as you decide what goes in the group, therefore what gets cleaned up. The engine can serve many different game styles, so having specific control over what gets cleaned up/looped through is important.

You have initContainerRadiusSearch which will look for objects in a radius, check out the code in sceneObject.cc

ConsoleFunction( initContainerRadiusSearch, void, 4, 4, "(Point3F pos, float radius, bitset mask)"
"Start a search for items within radius of pos, filtering by bitset mask.")

And this handy reference for its related commands.: http://tdn.garagegames.com/wiki/TorqueScript_Console_Functions_16

TDN Page
#2
02/28/2008 (1:54 pm)
Hmm, I think I have some more questions but will have to get farther along before I dare ask them :P Thank you for the explaination. In some ways I'm just making it more complicated then it is!
#3
02/28/2008 (2:19 pm)
> same # as shown in the editor.
if you mean the world editor, i think the IDs in there are server-side.
#4
02/28/2008 (3:26 pm)
Oh...well that would explain a good deal of it then. Thanks :P