Game Development Community

need to do a camera trick, any ideas?

by deepscratch · in Torque 3D Professional · 07/03/2009 (12:05 pm) · 8 replies

hi all,
I need to do a camera trick, but I have absolutly no idea where to start.

the trick being:
I'm using the GMK, basically just for the ragdoll, the ragdoll gets spawned when the player, or ai player dies,
what I'm trying to do, is when the main player dies, reparent the first person camera to the ragdoll objects eye node. the ragdoll object does indeed have an eye node in its dsq file.
now when the main player dies, the cam goes into orbit mode, that will have to be stopped as well,
you get the idea of the effect I'm after?
you get killed, the ragdoll gets spawned, the cam does not go into orbit mode, but instead reparents its self to the ragdolls eye node, giving you the "flop about with the ragdoll" kind of camera view.
whew!
make sence?
so, any one got any ideas how to go about doing this?
thanks all.

#1
07/03/2009 (12:17 pm)
Just a thought (haven't tried this -- but I like the idea), take a look at NAMESPACE::onDeath()
// Switch the client over to the death cam and unhook the player object.
if (isObject(%client.camera) && isObject(%client.player))
{
   %client.camera.setMode("Corpse", %client.player);
   %client.setControlObject(%client.camera);
}

Instead of setting the camera mode to "Corpse" and changing the controlObject to the camera, why not just change the controlObject to your ragdoll object -- but disallow player input in regards to movement.

You would then have to setup to allow re-spawning from the ragdoll instead of from the observer camera.

But then it may be more complicated than that, I only gave it about 5 seconds of thought ;)
#2
07/03/2009 (1:55 pm)
I tried that, finding no change, I removed that entire call, like this,
// Switch the client over to the death cam and unhook the player object.
//if (isObject(%client.camera) && isObject(%client.player))
//{
//   %client.camera.setMode("Corpse", %client.player);
//   %client.setControlObject(%client.camera);
//}
to see what would happen, and the regular chain of events happened.
meaning that
// Switch the client over to the death cam and unhook the player object.
if (isObject(%client.camera) && isObject(%client.player))
{
   %client.camera.setMode("Corpse", %client.player);
   %client.setControlObject(%client.camera);
}
is not responsible for doing the whole camera change thing,
I wonder what is actually creating it.

your idea sounds very reasonable Michael
#3
07/03/2009 (2:19 pm)
ok, I had that section of script twice, dont ask, removed the second call, now, on death, I get a blank green screen, so, getting somewhere....
#4
07/03/2009 (2:41 pm)
When you're in first person you're not seeing things through the client's camera, the player that client is controlling is the camera.

Just switch %client.setControlObject() to your ragdoll model and you should see it from first person.
#5
07/03/2009 (3:52 pm)
@Manoel,
I dont understand,
Quote:Just switch %client.setControlObject() to your ragdoll model and you should see it from first person.
can you explain?
#6
07/06/2009 (4:23 am)
My friend Deepscratch. What he means to say is. I have a Red Commandar, Blue Commandar and a cookie monster. [Grins Evily] And I slay the red commandar normally what happens is the camera that is attached to the player gets its mode changed to "corpse" mode. This means it is not affected by movement keys or spamming buttons or making cookies! But what you want to do is change out the corpse and the camera to the COOKIE Monster so you wiggle him around. So you have to tell the dumb game that instead of switching the camera to "corpse" mode you want to attach him to the COOKIE Monster and wiggle him around. To do client object possession a nifty function was already created. The setControlObject(); Just bear with me and I'll show you the order of this stuff.

It is a simple command just keep in mind that Torque is actualy a SERVER that runs a client next to it. Each client that connects to the game the SERVER puts in its client array called [clientGroup]. So you make a server and connect yourself into game. Now you see yourself in the GUI. This means that the world's data (Physics / terrain objects / etc. ) are present on the server and your GUI is recieing a mirror image of it (we call it ghosting). Ok, so in order to play possession of other things like the COOKIE Monster you have to tell the SERVER make me a COOKIE Monster then make me control the COOKIE Monster.

Program Me a COOKIE MONSTER when I kills the Red COMMANDAR.
function REDCOMMANDAR::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc)
{
//MAKE MY COOKIEMONSTER
%CookieM = new Player()
    {
        dataBlock = COOKIEMonster;
    };
    MissionCleanup.add(%CookieM);
    %CookieM.setShapeName("COOKIE MONSTER");
    %CookieM.setTransform(%damLoc);  //wherever you want I just put him where the damage hit.
    %client = %this.getcontrolobject();
    client.setControlObject(%CookieM);
   
    //WIGGLE COOKIE MONSTER
    client.player.playThread(0, "COOKIEWIGGLE"); // I had to name it something!
}
#7
07/06/2009 (5:55 am)
that would work if CookieM was a player class, but he is not, he is a CookieMonster class, that uses the players datablock.
so it would have to be:
%CookieM = new CookieMonster()
but that doesnt work, cause the engine knows that the CookieMonster class is a physics object, and beyond user control.

like I said in the original post, the player gets deleted and a ragdoll is spawned.
that ragdoll uses the player datablock, and the player model, but is not a player.

its kind of like trying to give a rigid object, you know, those rocks that roll? a camera that is mounted to a node in the rock. rock rolls, camera follows, but rock is not a player, its a rock.
thats the problem
#8
07/06/2009 (8:56 am)
SUCCESS!!
I had to implement 3 new functions in the ragdoll.cpp file, and 1 console method, then call those new functions from script, setting the ragdoll object to be the control object, then get the eyeTransform.

quite fun seeing it happen the first few times, camera flowing with the ragdolls head as he gets flung about, seeing arms and legs flapping.