Game Development Community

Jet Bike Pack Pro and TGE 1.5

by William Baker · in Torque Game Engine · 04/12/2007 (11:12 am) · 20 replies

Hello,

I bought the Jet Bike Pack Pro product and was able to install the product with no problems. The character will deploy the Jet Bike as it should but can't find how to mount the bike. I am using the FPS Starter Kit to test. I must mention that I am not the best at using Torque yet so any help would be awesome.

Q: How do I mount the bike using FPS Starter Kit in TGE 1.5?
Q: Do I need to do some Key Mapping? If so... How? or link to explanation.

Thank you for your help

#1
04/14/2007 (7:59 pm)
Did you remember to go through and transfer the mount code in the player.cs provided. They should be clearly labeled, i was able to get the pack to load and mount and dismount with no issues. i use AFX1.5 btw
#2
04/14/2007 (8:59 pm)
Yes for whatever reason when you hit ctrl-j you aren't automaticlly mounted. I just press the spacebar and jump on.

Now I just have to figure out the steering....
#3
04/15/2007 (5:11 am)
Hmm thats wierd, by default ctrl-j for me summons the jetbike, and steering is just like movment, w increases, s slows teh bike down, and ctrl -X is the dismount. if you have ctrl-j as your mount function, you might be conflicting with the summon jetbike command thats defaulted inthe jetbike script
#4
04/15/2007 (9:26 am)
Yes Ctrl-j summons the jetbike for me as well. I then just use the spacebar and jump on. I am able to use "W" for forward momentum, "S" is backwards, "spacebar" is brake. I can not get it to turn however. Is there a way to find were that is being called, or how it can be added?
#5
04/15/2007 (9:37 am)
The turning arc on it i find is a bit slow sometimes depending on the terrain. But i havent had a issue with the actual mechanics, i find that you do have to be moving to get it to turn, the mouse control works best for the manuevering i found.
#6
04/15/2007 (4:03 pm)
Yes you do have to be moving. The jet bike is just a standard vehicle, with invisible wheels. I was able to convert it over to a hovercraft with minimal effort. It's a lot more fun to drive that way.
#7
04/15/2007 (5:26 pm)
I used my flying vehicle class to make my hovercraft
#8
04/27/2007 (10:20 am)
Just FYI, I also just recently downloaded the jetbike. If you integrated both the player.cs code provided and the jetbike.cs, then "mounting" is done simply by colliding with the bike. When the bike is summoned though, it's dropped on top of you, and the collsion can't be detected. Move away from the bike, then walk back up to it to mount it. Jumping will also probably work, as the collision will be redetected at that point.

By default, the vehicle is a wheeled vehicle (I have no idea why) and drives pretty much like the dune buggy does in the starter.racing kit. Once mounted, "mouse-look" turns your invisible front wheels left and right, but you have to be moving to experience any turning.

I set the bike up to play in in the starter.racing race track, and what's funny is that once I wrapped my head around the fact that it's a wheeled vehicle, it actually performs pretty well. I was able to powerslide my way around turns by slamming the wheel opposite the turn and slapping the brakes, then accelerate away.

Agreed though, I have no idea why the default mode is a wheeled vehicle, and I'll be converting mine to a hoverbike as well.
#9
04/27/2007 (10:53 am)
I just updated to TGE1.5.1 and reinstalled the Jetbike Kit. It worked just as it was ment to. I find the steering to be a bit slow in the turns and would like to see how everyone is converting it to hover from wheele based vehicle. Any information on how to make this change would be awesome. Thank you for the help! GG has a great community!

William
#10
04/28/2007 (7:21 am)
There are a number of hovercraft datablocks floating around, William. I must say that it'll take a good bit of trial and error to get it to 'feel' right. But once you get the right combination of values it's a joy to fly.

The only issue I had was needing to keep the mass quite low, 5-10. This has the unfortunate side effect of the bike flying off into space when hit by an impulse from a crossbow explosion. I attempted to scale up the force values relative to the stock bike's default mass of 195. Didn't quite work out so well for me. The bike behaved very erratically. I guess that has something to do with why all the hover datablocks posted on the forums have incredibly low mass as well.
#11
04/28/2007 (11:49 am)
@ Jacobin - Thank you for following up with me. I am so new at the coding and scripting part of Torque that I really didn't understand what you were trying to explain to me. I hate to ask but could you give a bit more detail as to what I would need to do. Step By Step please or maybe a link to an explanation. Thank you for your help and sorry for being such a newb.

William
#12
04/28/2007 (1:51 pm)
datablock HoverVehicleData(JetBike)
{
   
   spawnOffset = "0 5 1";
   category = "Vehicles";
   shapeFile = "~/data/shapes/jetbike/rjetbike01.dts";
   mountPose[0] = scoutroot;
   emap = true;

   // Rigid Body 
   mass = 5; 
   bodyFriction = 0; 
   bodyRestitution = 0.5; 
   drag = 0.6;

   // Hovervehicle
   floatingGravMag = 5; 
   minRollSpeed	= 2000;     
   integration = 6;          
   collisionTol = 0.2; 
   contactTol = 0.1;
   dragForce = 1.9; 
   vertFactor = 0.5; 
   floatingThrustFactor = 0.35; 
   mainThrustForce = 100; 
   reverseThrustForce = 70; 
   strafeThrustForce = 70; 
   turboFactor = 1.5; 
   brakingForce = 30; 
   brakingActivationSpeed = 30; 
   stabLenMin = 6; 
   stabLenMax = 7.25; 
   stabSpringConstant = 15; 
   stabDampingConstant = 10; 
   gyroDrag = 36; // 16 
   normalForce = 10; 
   restorativeForce = 100; 
   steeringForce = 90; 
   rollForce = 7; 
   pitchForce = 10;  
   
  // 3rd person camera settings
   cameraRoll = false;         
   cameraMaxDist = 4.8;
   cameraOffset = 0.3;        
   cameraLag = 0.1;          
   cameraDecay = 0.75;
   
   maxDamage = 120; 
   destroyedLevel = 120; 
   minImpactSpeed = 29; 
   speedDamageScale = 0.010; 
   minMountDist = 4; 
    
};

No problem william. There's the hovercraft datablock that I used. I cobbled it together from examples I found while searching the forums. Although, there seems to be a lot of incorrect information in some of those threads. Such as people's explanations for the stabLen variables didn't quite mesh with the actual documentation found through TDN.

To use it, simply replace the flyingvehicle datablock in your jetbike.cs with the above posted datablock. In the script where it's creates a new jetbike (addjetbike) make sure you are creating a hoverbike instead of the 'car' version.

%vehicle = new HoverVehicle()
#13
04/28/2007 (4:34 pm)
Jacobin,

Thank you very much for your help. This will be my first time of truely altering code. This should give me alot to work on this weekend. I'll report back and let you know how it turns out. Thank you.

William
#14
04/30/2007 (12:43 pm)
@ Jacobin- Not sure if I did things right or not but I really saw no different in how the jetbike handled. Do you have to be moving for the bike to turn after the Hover code is added? If you find time please take a look at my Jetbike.cs and let me know if I have done somthing wrong. Thank you for your help.

// Collision with other objects, including items

//must be displaced, but not directly animated
//                   as it will be rotated in code.
// Other Sequences
//    steering       Wheel steering: time 0 = full right, 0.5 = center
//    breakLight     Break light, time 0 = off, 1 = breaking
//
// Wheel Nodes
//    hub#           Wheel hub, the hub must be in it's upper position
//                   from which the springs are mounted.
//
// The steering and animation sequences are optional.
// The center of the shape acts as the center of mass for the car.

//----------------------------------------------------------------------------

datablock HoverVehicleData(JetBike)
{
   
   spawnOffset = \\"0 5 1\\";
   category = \\"Vehicles\\";
   shapeFile = \\"~/data/shapes/jetbike/rjetbike01.dts\\";
   mountPose[0] = scoutroot;
   emap = true;

   // Rigid Body 
   mass = 5; 
   bodyFriction = 0; 
   bodyRestitution = 0.5; 
   drag = 0.6;

   // Hovervehicle
   floatingGravMag = 5; 
   minRollSpeed	= 2000;     
   integration = 6;          
   collisionTol = 0.2; 
   contactTol = 0.1;
   dragForce = 1.9; 
   vertFactor = 0.5; 
   floatingThrustFactor = 0.35; 
   mainThrustForce = 100; 
   reverseThrustForce = 70; 
   strafeThrustForce = 70; 
   turboFactor = 1.5; 
   brakingForce = 30; 
   brakingActivationSpeed = 30; 
   stabLenMin = 6; 
   stabLenMax = 7.25; 
   stabSpringConstant = 15; 
   stabDampingConstant = 10; 
   gyroDrag = 36; // 16 
   normalForce = 10; 
   restorativeForce = 100; 
   steeringForce = 90; 
   rollForce = 7; 
   pitchForce = 10;  
   
  // 3rd person camera settings
   cameraRoll = false;         
   cameraMaxDist = 4.8;
   cameraOffset = 0.3;        
   cameraLag = 0.1;          
   cameraDecay = 0.75;
   
   maxDamage = 120; 
   destroyedLevel = 120; 
   minImpactSpeed = 29; 
   speedDamageScale = 0.010; 
   minMountDist = 4; 
    
}; 

//-----------------------------------------------------------------------------

function JetBikeData::create(%block)
{
   %obj = new HoverVehicle() {
      dataBlock = %block;
   };
   return(%obj);
}

//-----------------------------------------------------------------------------


function JetBikeData::onCollision(%this,%obj,%col,%vec,%speed)
{
   // Collision with other objects, including items
}

function HoverVehicleData::onAdd(%data, %obj)
{

  if(%obj.mountable || %obj.mountable $= "")
     %obj.mountable = "1";
  else
     %obj.mountable = "0";

  if(%obj.mountable || %obj.mountable $= "")
     %data.isMountable(%obj, true);
  else
     %data.isMountable(%obj, false);
}
//--------------------------------------------------------------
function JetBikeData::onAdd(%this,%obj)
{
   // Setup the jetbike with some defaults tires & springs
   for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
      %obj.setWheelTire(%i,%this.tireDB);
      %obj.setWheelSpring(%i,%this.springDB);
      %obj.nextWeaponFire = 1;
   }
}

//------------------------------------------------------------------
function serverCmdAddJetbike(%client)
{
    if(%client.player$="")
      return;
    if(%client.player)
      if(%client.player.isMounted())
         return;
    %vehicle = new HoverVehicle()
    {
       dataBlock = Jetbike;
    };
    %vehicle.mountable = true;
    %vehicle.setEnergyLevel(60);
    %vehicle.setTransform( %client.player.getEyeTransform() );
    //%vehicle.setGravity(0);// Optional recommended :)
    //%vehicle.schedule(5500, "playThread", $ActivateThread, "activate");
    MissionCleanup.add(%vehicle);
}

moveMap.bindCmd(keyboard, "ctrl j", "commandToServer(\'addJetbike\');", "");
#15
04/30/2007 (1:08 pm)
function JetBikeData::onAdd(%this,%obj)
{
}

Empty out your onAdd function as shown above. A hovercraft obviously doesn't need wheels or springs! And no, you should be able to spin the hovercraft about when it's not moving.
#16
05/01/2007 (7:32 am)
Jacobin- Thank you for taking time to help me with this task. I made changes as recommended with no change to how the jet bike handles. Do I need to make changes to the Jetbike.cs.dso file?

This is the new coding for the Jetbike.cs file after I made the changes.

// Collision with other objects, including items

//must be displaced, but not directly animated
//                   as it will be rotated in code.
// Other Sequences
//    steering       Wheel steering: time 0 = full right, 0.5 = center
//    breakLight     Break light, time 0 = off, 1 = breaking
//
// Wheel Nodes
//    hub#           Wheel hub, the hub must be in it's upper position
//                   from which the springs are mounted.
//
// The steering and animation sequences are optional.
// The center of the shape acts as the center of mass for the car.

//----------------------------------------------------------------------------

datablock HoverVehicleData(JetBike)
{
   
   spawnOffset = \\"0 5 1\\";
   category = \\"Vehicles\\";
   shapeFile = \\"~/data/shapes/jetbike/rjetbike01.dts\\";
   mountPose[0] = scoutroot;
   emap = true;

   // Rigid Body 
   mass = 5; 
   bodyFriction = 0; 
   bodyRestitution = 0.5; 
   drag = 0.6;

   // Hovervehicle
   floatingGravMag = 5; 
   minRollSpeed	= 2000;     
   integration = 6;          
   collisionTol = 0.2; 
   contactTol = 0.1;
   dragForce = 1.9; 
   vertFactor = 0.5; 
   floatingThrustFactor = 0.35; 
   mainThrustForce = 100; 
   reverseThrustForce = 70; 
   strafeThrustForce = 70; 
   turboFactor = 1.5; 
   brakingForce = 30; 
   brakingActivationSpeed = 30; 
   stabLenMin = 6; 
   stabLenMax = 7.25; 
   stabSpringConstant = 15; 
   stabDampingConstant = 10; 
   gyroDrag = 36; // 16 
   normalForce = 10; 
   restorativeForce = 100; 
   steeringForce = 90; 
   rollForce = 7; 
   pitchForce = 10;  
   
  // 3rd person camera settings
   cameraRoll = false;         
   cameraMaxDist = 4.8;
   cameraOffset = 0.3;        
   cameraLag = 0.1;          
   cameraDecay = 0.75;
   
   maxDamage = 120; 
   destroyedLevel = 120; 
   minImpactSpeed = 29; 
   speedDamageScale = 0.010; 
   minMountDist = 4; 
    
}; 

//-----------------------------------------------------------------------------

function JetBikeData::create(%block)
{
   %obj = new HoverVehicle() {
      dataBlock = %block;
   };
   return(%obj);
}

//-----------------------------------------------------------------------------


function JetBikeData::onCollision(%this,%obj,%col,%vec,%speed)
{
   // Collision with other objects, including items
}

function HoverVehicleData::onAdd(%data, %obj)
{

  if(%obj.mountable || %obj.mountable $= "")
     %obj.mountable = "1";
  else
     %obj.mountable = "0";

  if(%obj.mountable || %obj.mountable $= "")
     %data.isMountable(%obj, true);
  else
     %data.isMountable(%obj, false);
}
//--------------------------------------------------------------
function JetBikeData::onAdd(%this,%obj)
{
}

//------------------------------------------------------------------
function serverCmdAddJetbike(%client)
{
    if(%client.player$="")
      return;
    if(%client.player)
      if(%client.player.isMounted())
         return;
    %vehicle = new HoverVehicle()
    {
       dataBlock = Jetbike;
    };
    %vehicle.mountable = true;
    %vehicle.setEnergyLevel(60);
    %vehicle.setTransform( %client.player.getEyeTransform() );
    //%vehicle.setGravity(0);// Optional recommended :)
    //%vehicle.schedule(5500, "playThread", $ActivateThread, "activate");
    MissionCleanup.add(%vehicle);
}

moveMap.bindCmd(keyboard, "ctrl j", "commandToServer(\'addJetbike\');", "");
#17
05/01/2007 (8:55 am)
William - delete the Jetbike.cs.dso and it should work fine.

Jacobin - thanks for the code dude :)
#18
05/01/2007 (10:00 am)
James - When I remove the DSO the jetbike will not deploy. Thank you for the help with this task. I wonder what I could be doing wrong?
#19
05/01/2007 (10:55 am)
Hey William - the dso is the "compiled" version of the *.cs file. By deleting it you force the engine to "recompile" it and therefore ensure that you are loading your corrections.

here is my code from the relevant section:
datablock HoverVehicleData(JetBike)
{
   
   spawnOffset = "0 5 1";
   category = "Vehicles";
   shapeFile = "~/data/shapes/jetbike/rjetbike01.dts";
   mountPose[0] = scoutroot;
   emap = true;

   // Rigid Body 
   mass = 5; 
   bodyFriction = 0; 
   bodyRestitution = 0.5; 
   drag = 0.6;

   // Hovervehicle
   floatingGravMag = 5; 
   minRollSpeed	= 2000;     
   integration = 6;          
   collisionTol = 0.2; 
   contactTol = 0.1;
   dragForce = 1.9; 
   vertFactor = 0.5; 
   floatingThrustFactor = 0.35; 
   mainThrustForce = 100; 
   reverseThrustForce = 70; 
   strafeThrustForce = 70; 
   turboFactor = 1.5; 
   brakingForce = 30; 
   brakingActivationSpeed = 30; 
   stabLenMin = 6; 
   stabLenMax = 7.25; 
   stabSpringConstant = 15; 
   stabDampingConstant = 10; 
   gyroDrag = 36; // 16 
   normalForce = 10; 
   restorativeForce = 100; 
   steeringForce = 90; 
   rollForce = 7; 
   pitchForce = 10;  
   
  // 3rd person camera settings
   cameraRoll = false;         
   cameraMaxDist = 4.8;
   cameraOffset = 0.3;        
   cameraLag = 0.1;          
   cameraDecay = 0.75;
   
   maxDamage = 120; 
   destroyedLevel = 120; 
   minImpactSpeed = 29; 
   speedDamageScale = 0.010; 
   minMountDist = 4;
   
   // Splash
   splashFreqMod = 300.0;
   splashVelEpsilon = 0.60;
   splashEmitter[1] = CarSplashMistEmitter;
   mediumSplashSoundVelocity = 10.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 5.0;
   
   //dustTrailFreqMod = 300;
   //dustTrailOffset = 0.0 5.0 0.0;
   //dustTrailEmitter = BikeDustTrailEmitter;

   // Sounds
   jetSound = bikeThrustSound;
   engineSound = bikeEngineSound;
 //  squealSound = bikeSquealSound;
   softImpactSound = bikeSoftImpactSound;
   hardImpactSound = bikeHardImpactSound;
//   wheelImpactSound = WheelImpactSound;

//   explosion = VehicleExplosion;dustTrailEmitter
    
}; 

//-----------------------------------------------------------------------------

function JetBikeData::create(%block)
{
   %obj = new HoverVehicle() {
      dataBlock = %block;
   };

   return(%obj);
}

//-----------------------------------------------------------------------------

function JetBikeData::onAdd(%this,%obj)
{
   // Setup the jetbike with some defaults tires & springs
 //  for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
 //     %obj.setWheelTire(%i,%this.tireDB);
 //     %obj.setWheelSpring(%i,%this.springDB);
 //     %obj.nextWeaponFire = 1;
  // }

   %obj.mountable = true;
}

function JetBikeData::onCollision(%this,%obj,%col,%vec,%speed)
{
   // Collision with other objects, including items
   echo("something hit the jetbike");
}

//--------------------------------------------------------------

// Drop a new bike in the mission
function serverCmdAddJetbike(%client)
{
    if(%client.player$="")
      return;
    if(%client.player)
      if(%client.player.isMounted())
         return;
    %vehicle = new HoverVehicle()
    {
       dataBlock = Jetbike;
    };
    %vehicle.mountable = true;
    %vehicle.setEnergyLevel(60);
    %vehicle.setTransform( %client.player.getEyeTransform() );
    //%vehicle.setGravity(0);// Optional recommended :)
    //%vehicle.schedule(5500, "playThread", $ActivateThread, "activate");
    MissionCleanup.add(%vehicle);
}

moveMap.bindCmd(keyboard, "ctrl j", "commandToServer(\'addJetbike\');", "");
It looks very much like yours but there must be something different here...

I did take out the this part:
//function WheeledVehicleData::onAdd(%data, %obj)
//{

//  if(%obj.mountable || %obj.mountable $= "")
//     %obj.mountable = "1";
//  else
//     %obj.mountable = "0";

//  if(%obj.mountable || %obj.mountable $= "")
//     %data.isMountable(%obj, true);
//  else
//     %data.isMountable(%obj, false);
//}

maybe that's it.

I'm also trying to get the dust emitter to work but am having no luck - any thoughts?
#20
05/01/2007 (11:39 am)
James, it does look like the hovercraft datablock supports dusttrail emitters. I'd see if they're named the same as on other vehicles (I assume they are) then look in the code to make sure they're actually being used. The following TDN link was essential in getting things to work properly.

tdn.garagegames.com/wiki/TorqueScript/Datablocks/HoverVehicleData

As I said previously, the only problem I had with hovercraft was trying to scale the forces to get them to 'feel' right without resorting to incredibly low mass values. Not happy that shooting the vehicle with a crossbow launches it to the moon.