How start my game in third person?
by University of Pisa (#0006) · in Torque Game Engine · 06/09/2006 (2:07 am) · 12 replies
I would like start my game in third person.
I tried to use the function togglefirstperson(1) in the function createPlayer but sometimes
game crash in mission loading.
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 Player() {
dataBlock = PlayerBody;
client = %this;
};
// create advanced camera
%this.advCamera = new AdvancedCamera()
{
dataBlock = AdvCameraData;
};
MissionCleanup.add(%this.advCamera);
%this.advCamera.scopeToClient(%this);
MissionCleanup.add(%player);
// Player setup...
%spawnPoint = pickSpawnPoint();
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
%player.setInventory(Gun,1);
%player.setInventory(GunAmmo, Gun.initialAmmo);
%player.mountImage(GunImage, 0);
%player.availableWeapons[%weapNum++]= Gun.getId();
GunImage.onReload(%player, $WeaponSlot);
%this.camera.setTransform(%player.getEyeTransform());
%this.player = %player;
%this.setControlObject(%player);
// Camera settings
%this.advCamera.setPlayerObject(%player);
%this.advCamera.setThirdPersonMode();
%this.advCamera.setFollowTerrainMode(true);
$firstPerson=false;
%this.advCamera.Mode = 0;
%this.advCamera.setLookAtOffset("0.0 3.8 1.8");
%this.advCamera.setThirdPersonOffset("0.0 -7.0 7.0");
%this.advCamera.setVerticalFreedomMode(true);
$verticalFreedomMode=true;
%this.setCameraObject(%this.advCamera);
$firstPerson=true;
toggleFirstPerson(1);
}
I resolved with a trick but I looking for a best solution.
I add this function in client/script/ServerConnection.cs
function StartThirdPerson()
{
ServerConnection.setFirstPerson( false );
}
and then I add schedule(150, 0, StartThirdPerson);
in function GameConnection::initialControlSet below Canvas.setContent.
Help me please.
Thanks in advance.
I tried to use the function togglefirstperson(1) in the function createPlayer but sometimes
game crash in mission loading.
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 Player() {
dataBlock = PlayerBody;
client = %this;
};
// create advanced camera
%this.advCamera = new AdvancedCamera()
{
dataBlock = AdvCameraData;
};
MissionCleanup.add(%this.advCamera);
%this.advCamera.scopeToClient(%this);
MissionCleanup.add(%player);
// Player setup...
%spawnPoint = pickSpawnPoint();
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
%player.setInventory(Gun,1);
%player.setInventory(GunAmmo, Gun.initialAmmo);
%player.mountImage(GunImage, 0);
%player.availableWeapons[%weapNum++]= Gun.getId();
GunImage.onReload(%player, $WeaponSlot);
%this.camera.setTransform(%player.getEyeTransform());
%this.player = %player;
%this.setControlObject(%player);
// Camera settings
%this.advCamera.setPlayerObject(%player);
%this.advCamera.setThirdPersonMode();
%this.advCamera.setFollowTerrainMode(true);
$firstPerson=false;
%this.advCamera.Mode = 0;
%this.advCamera.setLookAtOffset("0.0 3.8 1.8");
%this.advCamera.setThirdPersonOffset("0.0 -7.0 7.0");
%this.advCamera.setVerticalFreedomMode(true);
$verticalFreedomMode=true;
%this.setCameraObject(%this.advCamera);
$firstPerson=true;
toggleFirstPerson(1);
}
I resolved with a trick but I looking for a best solution.
I add this function in client/script/ServerConnection.cs
function StartThirdPerson()
{
ServerConnection.setFirstPerson( false );
}
and then I add schedule(150, 0, StartThirdPerson);
in function GameConnection::initialControlSet below Canvas.setContent.
Help me please.
Thanks in advance.
About the author
#2
Function =GameConnection::GameConnection()
Code change =
//first person
mFirstPerson = true;
change to
//first Person
mFirstPerson = false;
You can still use the TAB key to change back to 1st person camera if you really want to.
-James
06/09/2006 (3:08 am)
FILE = gameConnection.ccFunction =GameConnection::GameConnection()
Code change =
//first person
mFirstPerson = true;
change to
//first Person
mFirstPerson = false;
You can still use the TAB key to change back to 1st person camera if you really want to.
-James
#3
I tried to change mFirstPerson = false but game crash again on mission loading.
How can I resolve my problem?
06/09/2006 (5:29 am)
I have already search on forum.I tried to change mFirstPerson = false but game crash again on mission loading.
How can I resolve my problem?
#4
I tried to change mFirstPerson = false but game crash again on mission loading.
How can I resolve my problem?
06/09/2006 (5:36 am)
I have already search on forum.I tried to change mFirstPerson = false but game crash again on mission loading.
How can I resolve my problem?
#5
I tried to change mFirstPerson = false but game crash again on mission loading.
How can I resolve my problem?
06/09/2006 (6:09 am)
I have already search on forum.I tried to change mFirstPerson = false but game crash again on mission loading.
How can I resolve my problem?
#6
also:
what "$firstPerson=true;" does here?
06/09/2006 (6:49 am)
You are using Advanced Camera so try look in www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5471also:
%this.setCameraObject(%this.advCamera); [b]$firstPerson=true;[/b] toggleFirstPerson(1);
what "$firstPerson=true;" does here?
#7
ServerConnection.setFirstPerson(false);
as the last line of in GameConnection::onClientEnterGame in the server game.cs. and it works beautifully for me, I enter the game 3rd person as default. I think that this is basically the same thing that you have except called directly instead of on a schedule
If you are using advance camera I can't guarentee that this will work. Setting up the advance camera stuff is still to come for me, but I was under the impression that it still would have the same 1st/3rd person switch functions.
You can check here for more stuff too. Hope that helps out a bit.
-David
06/09/2006 (7:11 am)
I simply put:ServerConnection.setFirstPerson(false);
as the last line of in GameConnection::onClientEnterGame in the server game.cs. and it works beautifully for me, I enter the game 3rd person as default. I think that this is basically the same thing that you have except called directly instead of on a schedule
If you are using advance camera I can't guarentee that this will work. Setting up the advance camera stuff is still to come for me, but I was under the impression that it still would have the same 1st/3rd person switch functions.
You can check here for more stuff too. Hope that helps out a bit.
-David
#8
Thank you for this 'just-in-time' solution.
:)
06/09/2006 (7:56 am)
Wow, this is exactly the thread I was needing for a little problem I was having. Thank you for this 'just-in-time' solution.
:)
#9
but sometimes crash again.
I think depend from client and server synchronization.
Crash again at the end of missiong loading.
06/09/2006 (10:38 am)
I tried to put ServerConnection.setFirstPerson(false) in GameConnection::onClientEnterGame(%this)but sometimes crash again.
I think depend from client and server synchronization.
Crash again at the end of missiong loading.
#10
As I said, it worked for me on a completely clean engine. Plus the only modifications I'd made to starter.fps were completely unrelated to the camera. So perhapse something else you've modified is messing with it.
Also, I'm looking at the advanced camera things atm, and I don't know if this simple fix will work with it.
06/09/2006 (3:17 pm)
Hmm. That's got me stumped then :)As I said, it worked for me on a completely clean engine. Plus the only modifications I'd made to starter.fps were completely unrelated to the camera. So perhapse something else you've modified is messing with it.
Also, I'm looking at the advanced camera things atm, and I don't know if this simple fix will work with it.
#11
If I use advanced camera and start starter.fps in third person game crash.
It's very strange.If I build the engine in debug mode work and in release crash when I try to use advanced camera and start in third person.
06/10/2006 (2:50 am)
I tried with starter.fps demo.With standard camera game start in third person and not crash.If I use advanced camera and start starter.fps in third person game crash.
It's very strange.If I build the engine in debug mode work and in release crash when I try to use advanced camera and start in third person.
#12
06/10/2006 (9:29 am)
I thought that if you followed the instructions in the advanced camera resource it automatically set you up in the advanced camera 3rd person view? At least I gathered that much from the quick scan of the example script.
Torque Owner Martin de Richelieu