Game Development Community

Where to put %player.getTransform??

by Steve Howson · in Torque Game Engine · 09/12/2005 (10:56 pm) · 7 replies

Hi all!
I've been searching through the forums and resources for about two hours now and can't find this.
I find a bunch of references to it, but none of them tell where to put it, just they syntax..

Where do I put %player.getTransform or %client.player.getTransform (or getPosition, or getLocation) to make it work?
Seems like no matter where I put it I get the following in the console:
Unable to locate '' while doing getTransform... or something along those lines.

I'm using the starter.fps and trying to spawn an item at the player's location.. a very simple thing..

Thanks for any help.
Steve

#1
09/12/2005 (11:38 pm)
Try replacing %player with your player's ID for the console.

You need to do a %player = %client.GetID(); in a command to client/server function i believe. Not sure tho, so dun quote me.
#2
09/13/2005 (1:43 am)
It could be done in many places.
If you tell what type of game, ie.singleplayer or multyplayer and what and when will you be triggering this spawn it may be very eazy to anser, but without that info its hard to tell you.
try this
http://www.garagegames.com/mg/forums/result.thread.php?qt=17951
#3
09/13/2005 (4:19 am)
1) During gameplay type ~ to get the console.
2) Type tree(); to see the tree view. Press ~ again to get rid of the console.
3) Look under Server Connection - GameConnection to find Player. See what # it was assigned... In my case it was 1428, but it may be different each time.
4) Select player in the Tree View, and then hit "Expand All" in the left window to see the player properties.
5) Remove the tree windows (X) if you want. Press ~ again to get the console back.
6) Remember the # for the player? Replace it where i have 1428 in this example that is typed into the console: echo(1428.getTransform());

The console will print 7 numbers for the Transform: First three are location (x,y,z), next 4 are angled vector (3 #s for the x/y/z direction of a unit vector, and a finally a rotation about that direction in radians).
#4
09/13/2005 (7:41 am)
Thanks all!

Some more information:
I want to make this a multiplayer game. I'm using it as a learning exercise for Torque, so I want to use as many "functions" of Torque as I can.

One of my weapons/ammo is created by the player.. so I have a progress bar and at the end of that progress I want to trigger the spawn of the ammo.
I have the key bound in default.bind.cs and I have a function in playGui.gui for the progress bar to pop up and function (seemed logical to me since it's basically a gui element), and that's working fine.

What I'm trying to do is have that item spawn at the player's location... another option I'm trying is to have it added directly to inventory (without spawning) so I'm trying to use %player.incInventory for that as well, but again get the message 'unable to location '' blah blah blah'.

So basically I'm not sure where to put anything with %player where it knows what %player is, or how to pass the pointer (is that what it is essentially?) to my function.

Thanks for any help!
Steve
#5
09/13/2005 (5:45 pm)
Anyone have more information on this?
#6
09/13/2005 (6:23 pm)
How are you updateing the progress bar?

Sounds like you will need something like this on the client called from a keybind..

function requestAmmoFromServer(%val)
{
if (%val)
commandToServer('requestAmmoFromServer');
}

Then on the server you have this..

function serverCmdRequestAmmoFromServer(%client)
{
if (%client.progress == 100)
%client.player.setInventory(CrossbowAmmo,10);
}
#7
09/13/2005 (7:16 pm)
Bazz.. you are the MAN!
I'm doing things a bit different than you posted, but it's close enough where I was able to get it working.

One of the (many) things I tried before was putting a ServerCmdRequest function in commands.cs.. but forgot to add the %client variable.. DOH!

Thanks a lot man!