Game Development Community

Camera???

by CodingChris · in Torque Game Engine Advanced · 12/27/2007 (8:42 am) · 5 replies

Hi,
I simply want to change my control object when the player collides with a WheeledVehicle... Now I made this:
function Player2Body::onCollision(%this,%obj,%col)
{
  

   // Mount vehicles
   %this = %col.getDataBlock();
   if (%this.className $= WheeledVehicleData) {
 
	%obj.setControlObject(%col);
	 
   }
}
But this only sets the control object and has now effect on the camera... How do I make the camera follow the car?

#1
12/28/2007 (7:07 am)
Make sure the car has a cam and eye node. it should use one of those automatically.
#2
12/28/2007 (7:50 am)
This might be what you are looking for.
#3
12/28/2007 (10:35 am)
Is it possible to do it without engine modifications?
#4
12/28/2007 (12:14 pm)
You could in onCollision save the data of both the player and the vehicle ,delete both then respawn the player as the vehicle in the position where the vehicle was with a mounted player/AI .

Take a look at how the racing example creates a player as a vehicle.
#5
12/28/2007 (2:05 pm)
Now I made this:
function Player2Body::onCollision(%this,%obj,%col)
{
  

   // Mount vehicles
  
   if (%col.getDataBlock().className $= WheeledVehicleData) {
  %car = new WheeledVehicle() {
      dataBlock = %col.getDatablock().getName();
      client = %this;
   };
   MissionCleanup.add(%car);

   // Player setup...
   %car.setTransform(getLoc);
   %car.setShapeName(%this.name);
   obj.player.delete();
   // Update the camera to start with the player
   %this.camera.setTransform(%car.getEyeTransform());
	%obj.setControlObject(%car);


   }
}
function getLoc()
{
	echo(ServerConnection.getControlObject().getTransform());
	return ServerConnection.getControlObject().getTransform();
}
What's wrong here?
Console.log says it could not use my delete function... And set the transform of the new car...