Attaching a camera to a bot
by Mark Hu · in Torque Game Engine · 10/02/2003 (11:55 am) · 13 replies
I was hoping that someone could help me out. I am looking for a way to "attach" the camera to a scripted bot so I can watch him run and play and....
#2
Here's a function that attaches the camera to any AIPlayer object you pass in...
works like a charm ;)
02/13/2004 (2:05 pm)
Hey, thats a cool idea :)Here's a function that attaches the camera to any AIPlayer object you pass in...
function serverCmdAttachCamToObject(%client, %bot)
{
// Set the control state to the camera
%client.setControlObject(%client.camera);
// Set the camera "follow" mode (orbit)
// params:
// 1. object to attach to
// 2. attach object's tranformation
// 3. min distance (from attach object)
// 4. max distance (from attach object)
// 5. current distance (from attach object)
// 6. (bool) using self (ownClientObject)
%client.camera.setOrbitMode( %bot, %bot.getTransform(), -1.5, 2.0, 0.05);
}Use it like this: (I call this from a client-side gui script)commandToServer('AttachCamToObject', $currentBot);where $currentBot is an AIPlayer instance... :)works like a charm ;)
#3
02/13/2004 (2:34 pm)
Before you ask, here is the code to give the control back to the client ;)function serverCmdResetCam(%client)
{
%control = %client.player;
%control.mode = observerFly;
%client.setControlObject(%control);
}:)
#4
Nice one
Anyway to tie this to a new gametsctrl so you can have 2 or 3
differnt views ?
02/14/2004 (2:42 am)
Hi guys Nice one
Anyway to tie this to a new gametsctrl so you can have 2 or 3
differnt views ?
#6
I tried it, but to bad its not working on clients .
Im not a skilled coder so i cant fix it either :(
thx anyway
02/14/2004 (5:57 pm)
DylanI tried it, but to bad its not working on clients .
Im not a skilled coder so i cant fix it either :(
thx anyway
#7
%client.camera.setOrbitMode( %bot, %bot.getTransform(), 0, 0, 0);
Is it possible to let the bot control the viewing angle rather than the player with the mouse. I tried setting the bot as control object but that gives the player control of the bot.
Hopefully I won't have to hack through the camera engine code to sort this out :P
Cheers
02/15/2004 (2:32 pm)
Using...%client.camera.setOrbitMode( %bot, %bot.getTransform(), 0, 0, 0);
Is it possible to let the bot control the viewing angle rather than the player with the mouse. I tried setting the bot as control object but that gives the player control of the bot.
Hopefully I won't have to hack through the camera engine code to sort this out :P
Cheers
#8
I have added a new follow mode, which basically copies the orbit mode but sets the whole camera transform instead of only the position... I can make this a resource if you have problems getting it to work....
02/15/2004 (11:58 pm)
Well, yes, you have to edit the camera engine code :PI have added a new follow mode, which basically copies the orbit mode but sets the whole camera transform instead of only the position... I can make this a resource if you have problems getting it to work....
#9
If it is going to be too much work for you to post a resource, could you just quickly explain to me the difference between processTick() and interpolateTick().
Thanks
02/16/2004 (6:47 am)
Yeah, I was already trying something along those lines but haven't made much progress so far. If it isn't much hassle you could post a resource, otherwise I'll post one when I work it out.If it is going to be too much work for you to post a resource, could you just quickly explain to me the difference between processTick() and interpolateTick().
Thanks
#10
Added to the end of camera::setOrbitMode did the trick. :)
02/16/2004 (10:29 am)
AIPlayer *aiPlayer = dynamic_cast<AIPlayer*>(obj);
if (aiPlayer != NULL)
((ShapeBaseData*)aiPlayer->getDataBlock())->observeThroughObject = true;Added to the end of camera::setOrbitMode did the trick. :)
#11
02/16/2004 (10:53 am)
Whoo, very cool :) never heard of that, how did you find it? ;)
#12
02/16/2004 (1:38 pm)
I looked at Camera::getCameraTransform and say that flag, and tried it :)
#13
%client.camera.setOrbitMode( %bot, %bot.getTransform(), -0.2, 0.2, 0.05);
I just changed the maxdist and mindist... but I get pretty jerky movements of the camera. Using the distances you posted, however, everything works perfect (-1.5, 2.0, 0.05).
I need the camera to be really close to the object I'm following. It's a car, and I want the camera to simulate the driver's point of view.
04/15/2004 (4:01 am)
Stefan, I've tried the control camera thing with some bots of mine which are moving along a path... this way:%client.camera.setOrbitMode( %bot, %bot.getTransform(), -0.2, 0.2, 0.05);
I just changed the maxdist and mindist... but I get pretty jerky movements of the camera. Using the distances you posted, however, everything works perfect (-1.5, 2.0, 0.05).
I need the camera to be really close to the object I'm following. It's a car, and I want the camera to simulate the driver's point of view.
Employee Scott Burns
GarageGames
// attaching the camera to an object
// this can be any object you have a "handle" to
// this can be set on each client (as needed)
//
// Authors: AA WM
// Get the object
$objName = ClientGroup.getObject(0); // Get's the 1st player (object)
// Set the control state to the camera
$objName.camera.setControlObject($objName.camera);
// Set the camera "follow" mode (orbit)
// params:
// 1. object to attach to
// 2. attach object's tranformation
// 3. min distance (from attach object)
// 4. max distance (from attach object)
// 5. current distance (from attach object)
// 6. (bool) using self (ownClientObject)
$objName.setOrbitMode( $objName.player, $objName.player.getTransform(), -1.5, 1.5, 0.05);