Game Development Community

Simple vehicle mount in 1.5 ??

by Mike Rowley · in General Discussion · 12/31/2006 (10:50 am) · 6 replies

I've been trawling the resources trying to figure out how to add a vehicle to starter.fps and allow the player to mount it. So far, my attempts have failed. The 2 resources implement key presses to mount the car (which isn't working, and I just want to player to run into the car to jump in) and both are really outdated.
I know there is already a lot of the code in the player.cs, but I can't seem to get the player to jump into the default GG buggy.
Any ideas?
Thanks.
Mike

#1
12/31/2006 (11:31 am)
Hi mike. Well could things. If you want actual hop in animations you'll need to build those with your 3d art tool for characters. But it would be easier to just shift into the vehicle without.

Couple things that might help is the car packs and the tank pack as far as examples.

I didn't hit the search myself but keep looking in there under vehicles and various other related words. Should be some tips buried in there.
#2
12/31/2006 (11:46 am)
Copy car.cs from "starter.racing/server/scripts" to "starter.fps/server/scripts".

Then open game.cs (in "starter.fps/server/scripts") and add after "exec("./aiPlayer.cs");"

exec("./car.cs");

looking at my clean 1.4.2 you dont have to change the armor::onCollision method anymore so go to the mission editor, create a buggy (make sure you use the one in the "shapes" group and not the "static shapes" and when you walk up to it you should mount.

if not you should check if the player.mountVehicle and vehicle.mountable are both true

EDIT:

ofcourse you should also copy the car/buggy map (in "starter.racing/data/shapes") from starter.racing to starter.fps
#3
12/31/2006 (12:12 pm)
Quote:if not you should check if the player.mountVehicle and vehicle.mountable are both true

%player.mountVehicle is set to true by default, but I don't find a "vehicle.mountable" in player.cs or car.cs
I'll keep looking tho. I'm also going to try a diffferent buggy that I know has mountpoints. I don't know if the default GG buggy has mountpoints.

Thanks for the help Gentlemen.
#4
12/31/2006 (12:34 pm)
You can add "mountable" as "dynamic field" to the buggy in the mission editor or change "function wheeledVehicleData::onAdd( ... )" to look like this:

function WheeledVehicleData::onAdd(%this,%obj)
{
   // Setup the car with some defaults tires & springs
   for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
      %obj.setWheelTire(%i,DefaultCarTire);
      %obj.setWheelSpring(%i,DefaultCarSpring);
      %obj.setWheelPowered(%i,false);
   }
   
   // Steer front tires
   %obj.setWheelSteering(0,1);
   %obj.setWheelSteering(1,1);

   // Only power the two rear wheels...
   %obj.setWheelPowered(2,true);
   %obj.setWheelPowered(3,true);

   %obj.mountable = true; // make the vehicle mountable
}

The first way ive just tested and it works, the code should also work
#5
12/31/2006 (1:54 pm)
Exactly
#6
12/31/2006 (2:24 pm)
Thankyou. I've been looking at my 3dgap1 book, and between that, and here, I got it to work.
Thanks again. :-)