Expanded from Tutorial, need getEyeTransform help
by Jeff Trier · in Torque Game Engine · 03/19/2003 (5:05 am) · 5 replies
Hi guys and gals, it's me again with another daily question! *Wheeee* :)
I completed GarageGames Interact Key scripting tutorial, and I added some extra functionality. It will call different functions depending on what object is raycasted. All of them work pretty well... except case "playable".
When I walk up to a bot and press the interact key, my control is transfered to it, but my view camera remains with my old model. What I don't understand is, if %player is recognized as the client, and %object is recognized as the object scanned, shouldn't this work? I viewed a few functions utilizing getEyeTransform, and I can't see what I am doing wrong (I know I am doing *something* wrong).
EDIT: Typo's
Any help would be appreciated.
Thanks,
-Jeff
I completed GarageGames Interact Key scripting tutorial, and I added some extra functionality. It will call different functions depending on what object is raycasted. All of them work pretty well... except case "playable".
When I walk up to a bot and press the interact key, my control is transfered to it, but my view camera remains with my old model. What I don't understand is, if %player is recognized as the client, and %object is recognized as the object scanned, shouldn't this work? I viewed a few functions utilizing getEyeTransform, and I can't see what I am doing wrong (I know I am doing *something* wrong).
function serverCmdinteract(%client)
{
%player = %client.player;
%eye = %player.getEyeVector();
%vec = vectorScale(%eye, 4);
%startPoint = %player.getEyeTransform();
%endPoint = VectorAdd(%startPoint,%vec);
%searchMasks = $TypeMasks::ShapeBaseObjectType | $TypeMasks::vehicleObjectType | $TypeMasks::PlayerObjectType;
%object = ContainerRayCast (%startPoint, %endPoint, %searchMasks, %player);
if (%object) {
%target = %object.getDataBlock().category;
echo(%target);
switch$ (%target){
case "Switch":
%object.getDataBlock().interact(%object,%client);
echo (" USING SWITCH");
case "Vehicles":
onMountVehicle(%object.getDataBlock(), %client.player, %object);
echo (" USING VEHICLE");
case "Bunker":
onMountVehicle(%object.getDataBlock(), %client.player, %object);
echo (" USING BUNKER");
case "Playable":
echo("CHANGING CONTROL");
%player.setControlObject(%object);
%client.camera.setTransform(%object.getEyeTransform());
}
}
}EDIT: Typo's
Any help would be appreciated.
Thanks,
-Jeff
About the author
Originally a Classical/Metal musician, I've always been attracted to anything involving computers, including: Networking, PC Building and Repair, software design and coding. I've been involved with game design and development for over 10 years.
#2
Now I just need to figure out what functions will transfer the player to the bot in entirety. For instance, when I control the bot, my old body still has "Test Guy" above him, and is the only one I can make fire weapons. Doh!
Plus I can only change bodies once, which frustrates me a bit, because yesterday I was able to switch multiple times, then I broke it while fudging around. Gah! Boy, I can't wait til I know what I am doing! lol... Thats the price of switching engines I suppose. :)
Thanks for the help Daniel.
-Jeff
03/20/2003 (3:44 am)
Thanks, that did it! Now I can control the bot and be in his view. :)Now I just need to figure out what functions will transfer the player to the bot in entirety. For instance, when I control the bot, my old body still has "Test Guy" above him, and is the only one I can make fire weapons. Doh!
Plus I can only change bodies once, which frustrates me a bit, because yesterday I was able to switch multiple times, then I broke it while fudging around. Gah! Boy, I can't wait til I know what I am doing! lol... Thats the price of switching engines I suppose. :)
Thanks for the help Daniel.
-Jeff
#3
set the name on the original player object as "" ad set your player name on the new object. (refer to createPlayer function for the exact command)
Are you saying that when you are controlling the bot and you press fire, your old player model fires?? or are you saying that your bot dosnt fire? Your bot does have a weapon right?
If you are changing on a permanet basis you should probably set the variables for the client too
eg.
%oldplayer = %client.player;
%client.player = %botobject
%botobject.client = %client
%oldplayer.client = 0;
That shoudl stop bad effects like you taking damage if the old player is shot and stuff.
03/23/2003 (2:55 pm)
ok, well the name is easyset the name on the original player object as "" ad set your player name on the new object. (refer to createPlayer function for the exact command)
Are you saying that when you are controlling the bot and you press fire, your old player model fires?? or are you saying that your bot dosnt fire? Your bot does have a weapon right?
If you are changing on a permanet basis you should probably set the variables for the client too
eg.
%oldplayer = %client.player;
%client.player = %botobject
%botobject.client = %client
%oldplayer.client = 0;
That shoudl stop bad effects like you taking damage if the old player is shot and stuff.
#4
I fixed the control issue. I just needed to add "%Client.player = %obj;". :)
I am guessing that the function I need to change the names lies within "%player.setShapeName(%this.name);", I am going to have to see where that takes me. ;)
Thanks a lot for the help!
-Jeff
03/23/2003 (5:27 pm)
Thanks Daniel,I fixed the control issue. I just needed to add "%Client.player = %obj;". :)
I am guessing that the function I need to change the names lies within "%player.setShapeName(%this.name);", I am going to have to see where that takes me. ;)
Thanks a lot for the help!
-Jeff
Torque Owner Daniel Neilsen
%player.setControlObject(%object);
should be
%client.setControlObject(%object);
This may fix the camera issue, not sure.