Getting the "Local" player on the client side?
by Erik Karulf · in Torque Game Engine · 04/07/2005 (11:06 am) · 2 replies
I'm doing some stuff where I need to know what the local Player object is on the client side in C++ (the player this client is controling). I know I can get this from the GameConnection if I can find the right one, using the getControlObject function, but I can't for the life of me figure out where to find it. Has anyone figured this out? Or do I need to send the information from the server?
About the author
#2
Josh
04/07/2005 (1:51 pm)
Hmm, that's strange. I tried the exact same thing, but it was always getting the values from the Player that was controled by the server, not the one controled on the client. I'll try again to be sure.Josh
Associate Manoel Neto
Default Studio Name
First include gameConnection.h to your file, then you can:
GameConnection* conn = GameConnection::getServerConnection(); if (!conn) return; ShapeBase* control = conn->getControlObject(); if (!control || !(control->getType() & PlayerObjectType)) return;Of course, you should also make sure this code only runs on the client. If you're making a GUI, it's fine, since their calls are never run on the server, but you'll need to use isClientObject() or isGhost() if you're working with networkable objects.