Mouse controlled player movement
by Ron Yacketta · 12/14/2002 (7:35 am) · 67 comments
RTS/RPG Mouse controlled player movement
The following is a long awaited resource that I have been struggling to get out the door for a couple of the months now. The idea of the resource came from playing the likes of Dungeon Siege, Diablo, Baldurs Gate and Never Winter Nights.
I started off by utilizing a couple resources located on the GarageGames web site as well as document sent to me by Jason from 21-6 productions (still needs to be worked in) and one sent my way for review from Davide (do not recall the chaps Surname).
The first resource I used was "Object Selection in Torque" (www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2173). The only exception was that I did not add the selection code mentioned in the resource. I also made a few modifications to the serverCmdSelectObject() function, which I will outline
One could change the name of the function to something more suitable like "serverCmdSetDestination", but I will leave that up to you to decide.
The following bit of information was taken from Davide's document with additions and modifications made by me.
How to make an RPG-like interface
Instead of using the default "first person" or "fixed third person" that cames with the Torque demo, you can
program a classic RPG interface, that is, the camera follows the player and to move the camera around you
have to move the cursor to the end of the screen, and the camera turn around the player but he doesn't change
his direction.
In the FILE "fps/client/ui/playgui.gui" remove the following:
This will enable the cursor to be displayed at all times.
In the FILE "fps/client/scripts/default.bind.cs" INSERT BOTTOM these functions:
The functions are self explanatory, the variable $CameraDist and $CameraZooming will be added later in the
engine code.
Now in the FILE "config.cs" and "default.bind.cs", bind the keys with these function (really you have to write these lines also in the default.bind.cs
but if you already have the config.cs file you have to write these lines in this file because is the last file loaded and it delete
the previsious moveMap), to do this INSERT BOTTOM
Note that I have changed the bind of the toggleFirstPerson, don't use the tab key, because when the cursor is
on, when you press the tab key, the engine thinks that you want to change control and it doesn't execute the
toggleFirstPerson function.
Ok, now let's go into the engine code
First we add the two variable's to
File : gameConnection.h
class : GameConnection
in the private section, after the mCameraSpeed add:
File : gameConnection.cc
after the S32 GameConnection::smVoiceConnections[MaxClients]; add:
File : gameConnection.cc
Function: getControlCameraTransform(......)
change the block that starts with if (dt) { .... } with
change the next line from
to
File : gameConnection.cc
Funciton: GameConnection::readPacket( ....)
find the block
and replace the mCameraPos = 1; with mCameraPos = mCameraDist;
Now we export the variables so we can use them in the script
File : gameConnection.cc
Function: GameConnection::consoleInit()
add these 2 lines
Now, we have to manage the mousemove event, so when the cursor is near the margin of the window, the
camera has to move.
File: : gameTSCtrl.h
Class : GameTSCtrl
add the following variable decleration in the public section
File : gameTSCtrl.cc
Function: GameTSCtrl::GameTSCtrl()
add the following
File : gameTSCtrl.cc
Function: onMouseMove(..)
Comment out (or remove) the code already present and replace it with this:
Ok, the last step. We have to send the MouseMove event to this class, which is the correct class to manage this
type of event (at least I think so!! :-)), but in the script playGui.gui is defined the GuiShapeNameHud that is
almost the same size as the canvas itself, so every mouse message is sent to this class, so we have to pass the
message to the parent of this class
File : guiShapeNameHud.cc (located ./engine/game/fps ver. 1.1.2)
class : GuiShapeNameHud
In the public section add:
then in the same file, for example before the onRender method, add:
Ok, that's all.
Try to run the game, if everything is ok, you can move the mouse at the edge of the screen and you should see the camera rotating around the
player, use the mousewheel to zoom in and out.
Davide
I noticed that the rotation is clamped, that is you can not do a full 360 rotation around the player. To solve this I modified the following
FILE : Player.cc
Function: updateMove
I replace the following block of code
with
Now onto the part you all have been waiting for. Mouse controlled player movement.
I started out with a copy of aiPlayer.cc and went forth, after a few emails to Tim Gift; he sent me down the road to glory. On the way he snuck in behind me (just kidding Tim) and released a new aiPlayer.cc that contained basicly what I was setting out to-do. Wonder if that boils down to great minds think alike? Nah, I am not even in the same league as Tim, he is up their with the likes of Carmak!!
Anways, on to the changes
FILE : fps\client\server\scripts\game.cs
Function : createPlayer
Replace the entire function with
I think that should wrap it up for this tutorial.
The following is a long awaited resource that I have been struggling to get out the door for a couple of the months now. The idea of the resource came from playing the likes of Dungeon Siege, Diablo, Baldurs Gate and Never Winter Nights.
I started off by utilizing a couple resources located on the GarageGames web site as well as document sent to me by Jason from 21-6 productions (still needs to be worked in) and one sent my way for review from Davide (do not recall the chaps Surname).
The first resource I used was "Object Selection in Torque" (www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2173). The only exception was that I did not add the selection code mentioned in the resource. I also made a few modifications to the serverCmdSelectObject() function, which I will outline
function serverCmdSelectObject(%client, %mouseVec, %cameraPoint)
{
//Determine how far should the picking ray extend into the world?
%selectRange = 200;
// scale mouseVec to the range the player is able to select with mouse
%mouseScaled = VectorScale(%mouseVec, %selectRange);
// cameraPoint = the world position of the camera
// rangeEnd = camera point + length of selectable range
%rangeEnd = VectorAdd(%cameraPoint, %mouseScaled);
%searchMasks = ($TypeMasks::TerrainObjectType | $TypeMasks::InteriorObjectType |
$TypeMasks::PlayerObjectType | $TypeMasks::StaticShapeObjectType |
$TypeMasks::VehicleObjectType | $TypeMasks::ForceFieldObjectType |
$TypeMasks::PhysicalZoneObjectType | $TypeMasks::StaticTSObjectType);
%scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks, %player);
// a target in range was found so select it
if (%scanTarg)
{
$pos = getWords(%scanTarg,1,3);
%client.player.setMoveDestination($pos);
}
}One could change the name of the function to something more suitable like "serverCmdSetDestination", but I will leave that up to you to decide.
The following bit of information was taken from Davide's document with additions and modifications made by me.
How to make an RPG-like interface
Instead of using the default "first person" or "fixed third person" that cames with the Torque demo, you can
program a classic RPG interface, that is, the camera follows the player and to move the camera around you
have to move the cursor to the end of the screen, and the camera turn around the player but he doesn't change
his direction.
In the FILE "fps/client/ui/playgui.gui" remove the following:
noCursor=true;
This will enable the cursor to be displayed at all times.
In the FILE "fps/client/scripts/default.bind.cs" INSERT BOTTOM these functions:
function incCameraDistance()
{
$CameraDist = ($CameraDist + 1.0) > 5.0 ? 5.0: $CameraDist+1.0;
$CameraZooming = true;
}
function decCameraDistance()
{
$CameraDist = ($CameraDist - 1.0) < 1.0 ? 1.0 : $CameraDist-1.0;
$CameraZooming = true;
}
function changeCameraDistance(%val)
{
if (%val>0) incCameraDistance();
else decCameraDistance();
}The functions are self explanatory, the variable $CameraDist and $CameraZooming will be added later in the
engine code.
Now in the FILE "config.cs" and "default.bind.cs", bind the keys with these function (really you have to write these lines also in the default.bind.cs
but if you already have the config.cs file you have to write these lines in this file because is the last file loaded and it delete
the previsious moveMap), to do this INSERT BOTTOM
moveMap.bind(keyboard, "m", toggleFirstPerson); moveMap.bind(mouse, "xaxis", yaw); moveMap.bind(mouse, "yaxis", pitch); moveMap.bind(mouse, "zaxis", changeCameraDistance); //mousewheel moveMap.bind(keyboard, "i", incMaxCameraDistance); //these two lines are here if you don't have a mousewheel moveMap.bind(keyboard, "k", decMaxCameraDistance); moveMap.bind(keyboard, "c", toggleMouseLock);
Note that I have changed the bind of the toggleFirstPerson, don't use the tab key, because when the cursor is
on, when you press the tab key, the engine thinks that you want to change control and it doesn't execute the
toggleFirstPerson function.
Ok, now let's go into the engine code
First we add the two variable's to
File : gameConnection.h
class : GameConnection
in the private section, after the mCameraSpeed add:
static F32 mCameraDist; static bool mCameraZooming;
File : gameConnection.cc
after the S32 GameConnection::smVoiceConnections[MaxClients]; add:
F32 GameConnection::mCameraDist = 3.0f; //3.0 is the distance I have chosed, change it as you will bool GameConnection::mCameraZooming = false;
File : gameConnection.cc
Function: getControlCameraTransform(......)
change the block that starts with if (dt) { .... } with
if (dt)
{
if (mFirstPerson) mCameraDist = 0.0; //When you change to first person the camera has a distance of 0.0
else
if (mCameraDist == 0.0) //If you aren't in first person but the distance is 0.0
{
mCameraDist = 3.0f; //move the camera back
mCameraZooming = true;
}
if (mCameraZooming || mFirstPerson || obj->onlyFirstPerson())
{
if (mCameraPos > mCameraDist)
{
if ((mCameraPos -= mCameraSpeed * dt) <= mCameraDist)
{
mCameraPos = mCameraDist;
mCameraZooming = false;
}
}
else
if (mCameraPos < mCameraDist)
if ((mCameraPos += mCameraSpeed * dt) > mCameraDist)
{
mCameraPos = mCameraDist;
mCameraZooming = false;
}
}
}change the next line from
if (!sChaseQueueSize || mFirstPerson || obj->onlyFirstPerson())
to
if (!sChaseQueueSize || mCameraZooming || mFirstPerson || obj->onlyFirstPerson()) obj->getCameraTransform(&mCameraPos,mat);
File : gameConnection.cc
Funciton: GameConnection::readPacket( ....)
find the block
bool fp = bstream->readFlag();
if(fp)
mCameraPos = 0;
else
mCameraPos = 1;and replace the mCameraPos = 1; with mCameraPos = mCameraDist;
Now we export the variables so we can use them in the script
File : gameConnection.cc
Function: GameConnection::consoleInit()
add these 2 lines
Con::addVariable("CameraDist", TypeF32, &mCameraDist);
Con::addVariable("CameraZooming", TypeBool, &mCameraZooming);Now, we have to manage the mousemove event, so when the cursor is near the margin of the window, the
camera has to move.
File: : gameTSCtrl.h
Class : GameTSCtrl
add the following variable decleration in the public section
F32 mMouseMove;
File : gameTSCtrl.cc
Function: GameTSCtrl::GameTSCtrl()
add the following
mMouseMove = 0.009f;
File : gameTSCtrl.cc
Function: onMouseMove(..)
Comment out (or remove) the code already present and replace it with this:
Point2I ext = getExtent()- evt.mousePoint;
Point2I pos = evt.mousePoint - getPosition();
F32 YawSpeed = MoveManager::mYawRightSpeed;
F32 PitchSpeed = MoveManager::mPitchUpSpeed;
if (ext.x < 50 ) //50 is the distance from the margin
{
MoveManager::mYawRightSpeed -= mMouseMove ;
}
else
if (pos.x < 50)
{
MoveManager::mYawRightSpeed += mMouseMove ;
}
if (ext.y < 50)
{
MoveManager::mPitchUpSpeed += mMouseMove ;
}
else
if (pos.y < 50)
{
MoveManager::mPitchUpSpeed -= mMouseMove ;
}
//if you enter this function and the speed isn't changed this means that the cursor is out of the "moveble area" so
//stop the movement
if (MoveManager::mYawRightSpeed == YawSpeed)
MoveManager::mYawRightSpeed = 0;
if (MoveManager::mPitchUpSpeed == PitchSpeed)
MoveManager::mPitchUpSpeed = 0;Ok, the last step. We have to send the MouseMove event to this class, which is the correct class to manage this
type of event (at least I think so!! :-)), but in the script playGui.gui is defined the GuiShapeNameHud that is
almost the same size as the canvas itself, so every mouse message is sent to this class, so we have to pass the
message to the parent of this class
File : guiShapeNameHud.cc (located ./engine/game/fps ver. 1.1.2)
class : GuiShapeNameHud
In the public section add:
virtual void onMouseMove(const GuiEvent& event);
then in the same file, for example before the onRender method, add:
void GuiShapeNameHud::onMouseMove(const GuiEvent &event)
{
//Let's let the parent execute its event handling (if any)
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->onMouseMove(event);
}Ok, that's all.
Try to run the game, if everything is ok, you can move the mouse at the edge of the screen and you should see the camera rotating around the
player, use the mousewheel to zoom in and out.
Davide
I noticed that the rotation is clamped, that is you can not do a full 360 rotation around the player. To solve this I modified the following
FILE : Player.cc
Function: updateMove
I replace the following block of code
if (move->freeLook && ((isMounted() && getMountNode() == 0) || (con && !con->isFirstPerson())))
{
mHead.z = mClampF(mHead.z + y,
-mDataBlock->maxFreelookAngle,
mDataBlock->maxFreelookAngle);
}with
if (move->freeLook && ((isMounted() && getMountNode() == 0) || (con && !con->isFirstPerson())))
{
mHead.z += y;
}Now onto the part you all have been waiting for. Mouse controlled player movement.
I started out with a copy of aiPlayer.cc and went forth, after a few emails to Tim Gift; he sent me down the road to glory. On the way he snuck in behind me (just kidding Tim) and released a new aiPlayer.cc that contained basicly what I was setting out to-do. Wonder if that boils down to great minds think alike? Nah, I am not even in the same league as Tim, he is up their with the likes of Carmak!!
Anways, on to the changes
FILE : fps\client\server\scripts\game.cs
Function : createPlayer
Replace the entire function with
function GameConnection::createPlayer(%this, %spawnPoint)
{
if (%this.player > 0) {
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}
// Create the player object
%player = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setEnergyLevel(60);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform();
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%this.camera);
}I think that should wrap it up for this tutorial.
About the author
#2
Create an object in 3DS Max or Milkshape. When the client connects, have them load it. Save off the full position from the RayCast(that's slot 1, 2, 3). Then set the transform on the object when you right-click to move. Once you get near enough to the object, you could make it "go away"(read, transform it to 0 0 0).
An idea if nothing else :)
Looks interesting Ron, thanks for the effort.
12/13/2002 (5:02 pm)
Just a side bit of information, in regards to what I do that is simiilar. I have the client load an object (client side obviously) right as they enter the game. This object is bound to the right mouse, and it moves to the location of the right click. I think you could easily do something similar for a 3d pointer of sorts. Create an object in 3DS Max or Milkshape. When the client connects, have them load it. Save off the full position from the RayCast(that's slot 1, 2, 3). Then set the transform on the object when you right-click to move. Once you get near enough to the object, you could make it "go away"(read, transform it to 0 0 0).
An idea if nothing else :)
Looks interesting Ron, thanks for the effort.
#3
12/19/2002 (8:01 am)
I've not had chance to look at this yet (well, I haven't had time to play with Torque for ages..) but this looks to be a great addition, opening the door to different gametypes.
#4
I understant you're replacing a player creation with an aiplayer creation, but those functions
%player.setTransform(%spawnPoint);
%player.setEnergyLevel(60);
%player.setShapeName(%this.name);
are not declared in aiplayer ;
mmmm Ron, you are saying that there is a new aiPlayer.cc that works perfecly with this, and i'm afraid i haven't got the good version of the file (so, many things may be missing)... Can you upload or mail it please ?
01/27/2003 (9:28 am)
*sight* This ressource is The one i have ever dreamed of, but i can't make this work (the deplacement part) !I understant you're replacing a player creation with an aiplayer creation, but those functions
%player.setTransform(%spawnPoint);
%player.setEnergyLevel(60);
%player.setShapeName(%this.name);
are not declared in aiplayer ;
mmmm Ron, you are saying that there is a new aiPlayer.cc that works perfecly with this, and i'm afraid i haven't got the good version of the file (so, many things may be missing)... Can you upload or mail it please ?
#5
All the changes were added to the head (aiPlayer.c/.h changes that is) by Tim Gift www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3248
Everything I posted above works without a hitch with the changes Tim posted.
-Ron
01/27/2003 (2:41 pm)
Thomas,All the changes were added to the head (aiPlayer.c/.h changes that is) by Tim Gift www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3248
Everything I posted above works without a hitch with the changes Tim posted.
-Ron
#6
01/28/2003 (2:57 am)
Excelent resource for all who wants to make an rpg or adventure game!
#8
lagkitten.purrsia.com/torque/camera.patch
This patch fixes two relatively minor issues with the camera:
1. If you are using both the camera and the player, both call setCompressionPoint on the stream in their writePacketData/readPacketData functions and then attempt to compress points using the 'saved' compression point. This works fine if you only are contending with one or the other, but if you're manipulating an external camera, say for a 3rd person RPG/RTS-style control system, then you'll soon notice the rounding errors.
The patch corrects Player, Camera, and Vehicle to save the last compression point they sent or received, and to set that before attempting to read or write compressed points.
(I also note that GameConnection uses compressed points, but it doesn't appear to try to preserve the compressed point for writing compressed points in updates)
2. guiShapeNameHud (per Robert Blanchet's note) uses getEyeTransform, not getRenderEyeTransform. This creates problems if you have the player and camera moving, because the camera will interpolate its position, and the player will interpolate its RenderEyeTransform, but not the RenderTransform, but if you're setting the label at the EyeTransform, the apparent position of the label will appear to jitter or vibrate.
I picked up the head changes tonight and applied these changes to it, then compiled and verified it worked.
03/21/2003 (11:35 pm)
I've noted that there are some problems that may strike people who are using an external camera to control the player, and made a patch to fix the problem.lagkitten.purrsia.com/torque/camera.patch
This patch fixes two relatively minor issues with the camera:
1. If you are using both the camera and the player, both call setCompressionPoint on the stream in their writePacketData/readPacketData functions and then attempt to compress points using the 'saved' compression point. This works fine if you only are contending with one or the other, but if you're manipulating an external camera, say for a 3rd person RPG/RTS-style control system, then you'll soon notice the rounding errors.
The patch corrects Player, Camera, and Vehicle to save the last compression point they sent or received, and to set that before attempting to read or write compressed points.
(I also note that GameConnection uses compressed points, but it doesn't appear to try to preserve the compressed point for writing compressed points in updates)
2. guiShapeNameHud (per Robert Blanchet's note) uses getEyeTransform, not getRenderEyeTransform. This creates problems if you have the player and camera moving, because the camera will interpolate its position, and the player will interpolate its RenderEyeTransform, but not the RenderTransform, but if you're setting the label at the EyeTransform, the apparent position of the label will appear to jitter or vibrate.
I picked up the head changes tonight and applied these changes to it, then compiled and verified it worked.
#9
One question though. So do you need to implement the "Object Selection in Torque" mod first then apply this on top of it to get this effect?
Thanks!
07/04/2003 (3:17 pm)
Very cool idea that would fit in with something I want to do.One question though. So do you need to implement the "Object Selection in Torque" mod first then apply this on top of it to get this effect?
Thanks!
#10
08/02/2003 (7:08 pm)
Ok, finally got it all working! very nice!
#11
gameConnection.obj : error LNK2001: unresolved external symbol "private: static bool GameConnection::mCameraZooming" (?mCameraZooming@GameConnection@@0_NA)
gameConnection.obj : error LNK2001: unresolved external symbol "private: static float GameConnection::mCameraDist" (?mCameraDist@GameConnection@@0MA)
../example/torqueDemo_DEBUG.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
torqueDemo_DEBUG.exe - 3 error(s), 1 warning(s)
Any idea why this might be? Am I missing something really obvious, or did I do something wrong?
thanks in advance for any help you can give
j037
10/21/2003 (9:10 pm)
Quick question - when I compile with this resource, I get the errors:gameConnection.obj : error LNK2001: unresolved external symbol "private: static bool GameConnection::mCameraZooming" (?mCameraZooming@GameConnection@@0_NA)
gameConnection.obj : error LNK2001: unresolved external symbol "private: static float GameConnection::mCameraDist" (?mCameraDist@GameConnection@@0MA)
../example/torqueDemo_DEBUG.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
torqueDemo_DEBUG.exe - 3 error(s), 1 warning(s)
Any idea why this might be? Am I missing something really obvious, or did I do something wrong?
thanks in advance for any help you can give
j037
#12
10/22/2003 (7:52 am)
please?
#13
function serverCmdSelectObject(%client, %mouseVec, %cameraPoint)
{
//Determine how far should the picking ray extend into the world?
%selectRange = 200;
// scale mouseVec to the range the player is able to select with mouse
%mouseScaled = VectorScale(%mouseVec, %selectRange);
// cameraPoint = the world position of the camera
// rangeEnd = camera point + length of selectable range
%rangeEnd = VectorAdd(%cameraPoint, %mouseScaled);
// Search for anything that is selectable – below are some examples
%searchMasks = $TypeMasks::PlayerObjectType | $TypeMasks::CorpseObjectType |
$TypeMasks::ItemObjectType | $TypeMasks::TriggerObjectType;
// Search for objects within the range that fit the masks above
// If we are in first person mode, we make sure player is not selectable by setting fourth parameter (exempt
// from collisions) when calling ContainerRayCast
%scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks);
echo("function ServerSelectObject launched");
// a target in range was found so select it
if (%scanTarg)
{
echo("selection found");
%targetObject = firstWord(%scanTarg);
%client.setSelectedObj(%targetObject);
return;
}
%searchMasks = $TypeMasks::TerrainObjectType | $TypeMasks::CorpseObjectType |
$TypeMasks::ItemObjectType | $TypeMasks::TriggerObjectType;
%scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks);
echo("Ray launch for pos");
if (%scanTarg)
{
echo("pos found");
%targetObject = %client.getSelectedObj();
if ( %targetObject )
{
echo("obj found");
$pos = getWords(%scanTarg,1,3);
%targetObject.setMoveDestination($pos);
echo("Moving to "@ $pos );
}
}
10/23/2003 (7:36 am)
I modified the command function, in order to be able to click a unit to select it, and to click on the terrain to order the unit to move :function serverCmdSelectObject(%client, %mouseVec, %cameraPoint)
{
//Determine how far should the picking ray extend into the world?
%selectRange = 200;
// scale mouseVec to the range the player is able to select with mouse
%mouseScaled = VectorScale(%mouseVec, %selectRange);
// cameraPoint = the world position of the camera
// rangeEnd = camera point + length of selectable range
%rangeEnd = VectorAdd(%cameraPoint, %mouseScaled);
// Search for anything that is selectable – below are some examples
%searchMasks = $TypeMasks::PlayerObjectType | $TypeMasks::CorpseObjectType |
$TypeMasks::ItemObjectType | $TypeMasks::TriggerObjectType;
// Search for objects within the range that fit the masks above
// If we are in first person mode, we make sure player is not selectable by setting fourth parameter (exempt
// from collisions) when calling ContainerRayCast
%scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks);
echo("function ServerSelectObject launched");
// a target in range was found so select it
if (%scanTarg)
{
echo("selection found");
%targetObject = firstWord(%scanTarg);
%client.setSelectedObj(%targetObject);
return;
}
%searchMasks = $TypeMasks::TerrainObjectType | $TypeMasks::CorpseObjectType |
$TypeMasks::ItemObjectType | $TypeMasks::TriggerObjectType;
%scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks);
echo("Ray launch for pos");
if (%scanTarg)
{
echo("pos found");
%targetObject = %client.getSelectedObj();
if ( %targetObject )
{
echo("obj found");
$pos = getWords(%scanTarg,1,3);
%targetObject.setMoveDestination($pos);
echo("Moving to "@ $pos );
}
}
#14
"S32 GameConnection::smVoiceConnections[MaxClients];"
is no longer in gameConnection.cc, so I was adding the declaration lines in the wrong place. Seems to work ok if I add those back to gameConnection.cc, though I'm still having positioning problems with the camera (starts out under the terrain). I'll let everyone know if I figure out why.
thanks for all the help
10/23/2003 (9:09 am)
Thanks for the update Nicolas. As to my problem, it appears that in build 1.2, the line "S32 GameConnection::smVoiceConnections[MaxClients];"
is no longer in gameConnection.cc, so I was adding the declaration lines in the wrong place. Seems to work ok if I add those back to gameConnection.cc, though I'm still having positioning problems with the camera (starts out under the terrain). I'll let everyone know if I figure out why.
thanks for all the help
#15
thanks
10/24/2003 (2:39 pm)
Another quick question - when using this resource, is there any way to alter the code so the "forward" key, when pressed, moves the camera horizontal to the ground instead of into the viewpoint. I've tried searching forums and resources, and looking at the engine itself, but I'm not sure where this is set. Any help, or at least a point in the right direction, would be appreciated.thanks
#16
File : gameConnection.cc
after the S32 GameConnection::smVoiceConnections[MaxClients]; add:
in the walkthrough
but i can't find this line in that file... where do I put those lines now?
06/05/2004 (10:05 pm)
I got to File : gameConnection.cc
after the S32 GameConnection::smVoiceConnections[MaxClients]; add:
in the walkthrough
but i can't find this line in that file... where do I put those lines now?
#17
------ Build started: Project: Torque Demo, Configuration: Debug Win32 ------
Linking...
gameConnection.obj : error LNK2001: unresolved external symbol "private: static bool GameConnection::mCameraZooming" (?mCameraZooming@GameConnection@@0_NA)
gameConnection.obj : error LNK2001: unresolved external symbol "private: static float GameConnection::mCameraDist" (?mCameraDist@GameConnection@@0MA)
../example/torqueDemo_DEBUG.exe : fatal error LNK1120: 2 unresolved externals
Build log was saved at "file://c:\torque\engine\out.VC6.DEBUG\BuildLog.htm"
Torque Demo - 3 error(s), 0 warning(s)
and while do have experience with some limiited programming, this is the first attempt at a project of this size....any suggestions?
06/05/2004 (11:38 pm)
just as a side note i tried adding everything else but those lines and get -------- Build started: Project: Torque Demo, Configuration: Debug Win32 ------
Linking...
gameConnection.obj : error LNK2001: unresolved external symbol "private: static bool GameConnection::mCameraZooming" (?mCameraZooming@GameConnection@@0_NA)
gameConnection.obj : error LNK2001: unresolved external symbol "private: static float GameConnection::mCameraDist" (?mCameraDist@GameConnection@@0MA)
../example/torqueDemo_DEBUG.exe : fatal error LNK1120: 2 unresolved externals
Build log was saved at "file://c:\torque\engine\out.VC6.DEBUG\BuildLog.htm"
Torque Demo - 3 error(s), 0 warning(s)
and while do have experience with some limiited programming, this is the first attempt at a project of this size....any suggestions?
#18
06/06/2004 (10:39 pm)
Solved on the foums... just added the declations. seems to be a bit slow, but at least it works in the latest TGE.
#19
Can somebody help me!
I have a problem with object selection.
I have deleted this in "\common\editor.cs" :
if (!$missionRunning)
{MessageBoxOK("Mission Required", "You must load a mission before starting the Mission Editor.", ""); return; }
to enable WorldEditor on the client computer, but when I try to select objects I can't.
A yellow triangle appears but objects are not selected. Do Somebody have idea why?
How i can corect this problem?
I am a novice in Torque (about a month) and very much like any help and advice anyone can give.
06/15/2004 (2:05 pm)
Hi,Can somebody help me!
I have a problem with object selection.
I have deleted this in "\common\editor.cs" :
if (!$missionRunning)
{MessageBoxOK("Mission Required", "You must load a mission before starting the Mission Editor.", ""); return; }
to enable WorldEditor on the client computer, but when I try to select objects I can't.
A yellow triangle appears but objects are not selected. Do Somebody have idea why?
How i can corect this problem?
I am a novice in Torque (about a month) and very much like any help and advice anyone can give.
#20
Thanks.
Edit: Found the solution. Those entries can go after 'S32 GameConnection::mLagThresholdMS=0;' which is before the constructor, 'GameConnection::GameConnection()'.
Ok, now for new questions:
1) I can pan my view left, right and down. However up doesn't work. Is this because of that message box that gets put at the top of the screen? Will this work if I remove or move the box? Is there some way to make it work with the box in the way?
Update - My chat hud was blocking the mouse viewing up. I resized it and moved it out of the way, and now I can look up.
2) Actual movement I can only get to happen if I hit "F8" to "Drop Camera at Player". As soon as I do that, my guy runs off happily, while the camera sits still, until either he gets there or I hit alt-c to "Toggle Camera". Is there a fix to make this a one-step process? To just be able to click and have the player and the camera move?
06/16/2004 (11:41 am)
Jeff, you noted that your problem was solved in the forums. Could you please either add the link to the post or give a short explanation of what the solution was? I'm having the same problem.Thanks.
Edit: Found the solution. Those entries can go after 'S32 GameConnection::mLagThresholdMS=0;' which is before the constructor, 'GameConnection::GameConnection()'.
Ok, now for new questions:
1) I can pan my view left, right and down. However up doesn't work. Is this because of that message box that gets put at the top of the screen? Will this work if I remove or move the box? Is there some way to make it work with the box in the way?
Update - My chat hud was blocking the mouse viewing up. I resized it and moved it out of the way, and now I can look up.
2) Actual movement I can only get to happen if I hit "F8" to "Drop Camera at Player". As soon as I do that, my guy runs off happily, while the camera sits still, until either he gets there or I hit alt-c to "Toggle Camera". Is there a fix to make this a one-step process? To just be able to click and have the player and the camera move?

Associate Ron Yacketta
This is my first actual usfull (I hope) code/script resource, so please be kind.
This resource was a pain to compile. I had source all over the place (commented). If you give this a whirl and find something missing/not working please dont flame me, just toss me an email.
I would also like to than Time Gift who gave me a great deal of insight with AI and Player Movement, Just from 21-6 for the awsome camera tutorial and Davide (known Surname) for his camera tutorial.
Most of this was a complilation of existing resources with a splash here and their of my own ignorance.
-Ron