Game Development Community

Camera fix to use vehicle camera nodes when mounted

by Jason "fireVein" Culwell · in Torque Game Engine · 01/05/2005 (6:18 am) · 7 replies

Heres a fix for the camera to use the vehicle's camera nodes when mounted to a vehicle. This will make the camera use the vehicle's eye transform instead of the player objects eye transform, as well as the third person node transform. Thus allowing for velocity lag, and correct first person views while mounted to a vehicle.

Open shapeBase.cc and goto the function ShapeBase::getCameraTransform

After:

if (isServerObject() && mShapeInstance)
      mShapeInstance->animateNodeSubtrees(true);

   if (*pos != 0)
   {

ADD:

// begin change ... use 3rd person came of vehicle when mounted
	// special thanks: M.T. Maas
	if ( isMounted() )
	{
		getObjectMount()->getCameraTransform( pos, mat );
		return;
	}
	// end change

That will fix the third person camera.

Now, in the same file and same function, look near the end of the function and change...

else
   {
      getRenderEyeTransform(mat);
   }

To:

else
   {
		if(isMounted())
			getObjectMount()->getRenderEyeTransform(mat);		
		else
			getRenderEyeTransform(mat);
   }

And that should fix you up in a jiffy. Hope it helps.

-Jase

About the author

http://www.microdotproductions.com - I am a self taught programmer that has been hacking away at code for a little over 10 years now. I am a very passionate and persistent programmer, and gamer. I love challenges and problem solving.


#1
01/05/2005 (4:39 pm)
Thank you! I was getting ready to do a few searches through the resources and then try to figure it out myself when I came across this thread. It's little things like this that make a game feel polished.
#2
01/05/2005 (5:37 pm)
-nod nod- My feelings exactley. I just love velocity lag! It adds so much depth... I'm glad it helped you.

-Jase
#3
01/05/2005 (7:57 pm)
Yes, yes it does. I should probably get around to adjusting the mipmap level so it doesn't switch before the camera gets as far back as possible though. Ruins it a bit. Or maybe I'm just a detail freak.
#4
01/06/2005 (10:02 am)
Many thanks Jase for this post.

You are the best.
#5
07/10/2008 (7:14 pm)
I was wondering if there was a way to handle this using just TorqueScript in TGE 1.5.2 ? It ssems to me you would just have to get the Cam node transform of the DefaultCar and set it as the player's camera. I may be wrong...not the best coder. Thanks in advance!
#6
07/10/2008 (7:23 pm)
You would need to edit the source, unless you are using AdvancedCamera which in that case I am not sure.
#7
07/16/2008 (9:06 pm)
UPDATE: I made my car into a flying vehicle and figured out that the camera works off the vehicles nodes as I wanted. So I grabbed the camera settings from the flying vehicle and dropped them into my car script. It works the same as the flying vehicle.