Any way to get the players current pos?
by Dan - · in Torque Game Engine · 08/29/2004 (10:43 am) · 3 replies
I want to have some engine code that acts differently depending how close the player is. The problem is that I am unable to "find" the player. I tried:
gClientSceneGraph->getCurrCameraPosition() - Always returns 0,0,0
gClientSceneGraph->getBaseCameraPosition() which seems to vary depending on the direction you are looking instead of the pos.
Anyone have any ideas how to get the players current position?
Thank you,
gClientSceneGraph->getCurrCameraPosition() - Always returns 0,0,0
gClientSceneGraph->getBaseCameraPosition() which seems to vary depending on the direction you are looking instead of the pos.
Anyone have any ideas how to get the players current position?
Thank you,
#2
What I am looking for is where the player is on the map. Player::getPosition is not a globally available function with in the engine. I was hoping to not make a global instace of the players location for use. I figured it had to already exist somewhere. Thats why I was heading down the route of gClientSceneGraph. You can get lights, the sky and a bunch of other neat things from it.
Why do I want to know where the player is? I have some shadow code and I figured why bother even looking at the render of the shadow if the player is too far from the object to really notice the shadow.
So my thought was:
After stating that, what I am really looking for is the distance from the current instance of an object to the player.
Clearer? Any words of wisdom?
08/29/2004 (11:16 am)
Ian,What I am looking for is where the player is on the map. Player::getPosition is not a globally available function with in the engine. I was hoping to not make a global instace of the players location for use. I figured it had to already exist somewhere. Thats why I was heading down the route of gClientSceneGraph. You can get lights, the sky and a bunch of other neat things from it.
Why do I want to know where the player is? I have some shadow code and I figured why bother even looking at the render of the shadow if the player is too far from the object to really notice the shadow.
So my thought was:
if distance(CurrentObjectThatIAmShadowingLocation to PlayerLocation) > SomeAmount
Return
else
Render ShadowAfter stating that, what I am really looking for is the distance from the current instance of an object to the player.
Clearer? Any words of wisdom?
#3
I did have to add #include "game/gameConnection.h" which I am not too happy about.
I am also not sure I get the performance increase I had hoped for but its semi ok right now.
Of course open to engine wizards to point out my ignorance or issues with the solution above.
Thank you,
08/29/2004 (6:12 pm)
Thanks to a smart cookie on IRC who pointed me down a new path I have come up with the following code... or rather discovered the following code:GameConnection* conn = GameConnection::getLocalClientConnection();
if (!conn)
return;
conn->getControlObject();
ShapeBase* controlObj = conn->getControlObject();
if (!controlObj)
return;
Point3F pos = getPosition();
VectorF diff = controlObj->getPosition() - pos;I did have to add #include "game/gameConnection.h" which I am not too happy about.
I am also not sure I get the performance increase I had hoped for but its semi ok right now.
Of course open to engine wizards to point out my ignorance or issues with the solution above.
Thank you,
Associate Ian Omroth Hardingham
Mode 7 Games
Or are you looking for something specific to the camera? Your post isn't quite clear.
Ian