Alt+c camera stuck on dead body
by Keith "The Dip" Wagner · in Torque Game Engine · 12/02/2004 (4:23 am) · 4 replies
I added a simple gui to my game to allow the player to change their character in-game. The following script facilitates the change:
Which works great for the test I needed to do to see if it worked. The only thing is that if I alt+c, the camera is stuck on the old player's body, and all I can do is rotate it (no wasd control). The only workaround I have found for this so far is to F11 into the mission editor, switch to camera mode if not already there, then F11 back. Is there some code I need to do to get the camera unstuck?
function GameConnection::changeChar(%this, %charid)
{
%this.player.kill("Suicide");
%this.charid = %charid;
%this.spawnPlayer();
}Which works great for the test I needed to do to see if it worked. The only thing is that if I alt+c, the camera is stuck on the old player's body, and all I can do is rotate it (no wasd control). The only workaround I have found for this so far is to F11 into the mission editor, switch to camera mode if not already there, then F11 back. Is there some code I need to do to get the camera unstuck?
#2
Try that... Might not do it, but it might get you onto the right path..
- Brett
12/02/2004 (11:56 am)
function GameConnection::changeChar(%this, %charid)
{
%this.setControlObject(%this.camera);
%this.player.kill("Suicide");
%this.charid = %charid;
%this.spawnPlayer();
%this.setControlObject(%this.player);
}Try that... Might not do it, but it might get you onto the right path..
- Brett
#3
Originally I looked at the code in camera.cs and tried doing a setMode("observer",%this.player) in my function (after the spawnPlayer), which didn't work. The reason for using kill("suicide") is because of the player penalty for switching character types after the game starts. There will be more code added to that for different cases, but I wanted to get a base case working first.
12/06/2004 (6:01 pm)
Thanks for the ideas. What eventually worked was this:function GameConnection::changeChar(%this, %charid)
{
%this.cameFromCharChange = true;
%this.player.kill("Suicide");
%this.charid = %charid;
%this.spawnPlayer();
}and this (in GameConnection::onDeath)// Switch the client over to the death cam and unhook the player object.
if (isObject(%this.camera) && isObject(%this.player)) {
if (%this.cameFromCharChange) {
%this.camera.setMode("Observer",%this.player);
%this.setControlObject(%this.camera);
%this.cameFromCharChange = false;
}
else {
%this.camera.setMode("Corpse",%this.player);
%this.setControlObject(%this.camera);
}
}
%this.player = 0;Originally I looked at the code in camera.cs and tried doing a setMode("observer",%this.player) in my function (after the spawnPlayer), which didn't work. The reason for using kill("suicide") is because of the player penalty for switching character types after the game starts. There will be more code added to that for different cases, but I wanted to get a base case working first.
#4
01/06/2006 (2:47 am)
Ahah, this works great. I was having the same problem with the camera getting stuck to the corpse after the player respawns. Problem solved. Thanks!
Zod
Instead of using kill("Suicide"); use some other unique damage name and filter for it in ::onDeath to set the mode to your new one.