Game Development Community

Vehicle selction datablocks

by Jim \"Night\" Lee · in Torque Game Engine · 08/29/2006 (10:26 pm) · 5 replies

Well i have a vehicle selection code that selects the datablock of the car to be used. So my question is that when the car is selected only the body changes not the wheel and spring data meaning all the vehicles will have the same wheels and spring data. So is there a way to make the wheel and spring force datablock to also load and change. Or more like load seperate cs files instead of just datablocks for vehicles. I tried many things though but i new to programming so this is kind of hard but i feel i may be overlooking something. If you can help please do.

About the author

Recent Threads

  • Vehicle Selection

  • #1
    08/30/2006 (2:53 am)
    Isn't the wheels and springs assigned in the onAdd function? I think it is if I remember correctly. So In the datablock of each vehicle, you can specify what wheels you want to use. eg.

    springs = "soft";
    wheels = "big";

    Make sure you have this defined and setup somewhere:
    Datablock WheeledVehicleTire(big)
    ..
    ..
    ..

    And also :

    Datablock WheeledVehicleSpring(soft)
    ..
    ..
    ..

    Then in your onAdd function look and change the variables passed to setWheelTire and setWheelSpring:
    %obj.setWheelTire(%i,DefaultCarTire);
    %obj.setWheelSpring(%i,DefaultCarSpring);

    to something like this

    %obj.setWheelTire(%i,%obj.getDataBlock().wheels);
    %obj.setWheelSpring(%i,%obj.getDataBlock().springs);

    I'm doing this blindly, so this probably won't be 100% correct, but it gives you an idea.
    #2
    08/30/2006 (9:44 pm)
    I did something very simular to this but I'll try it anyway tomorrow cause it to late here.
    #3
    09/05/2006 (6:52 pm)
    Hmm it doesnt work as i thought maybe i am doing it wrong?

    I tried putting it in if functions:

    if(%auto == "DefaultCar")
       {
    
          for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
             %obj.setWheelTire(%i,DefaultCarTire);
             %obj.setWheelSpring(%i,DefaultCarSpring);
             %obj.setWheelPowered(%i,false);
          }
    
       } else if(%auto == "humvee") {
    
          for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
             %obj.setWheelTire(%i,humveeTire);
             %obj.setWheelSpring(%i,humveeSpring);
             %obj.setWheelPowered(%i,false);
          }
    
       }

    it now only uses the default car wheels instead of using the humvee wheels before
    #4
    09/06/2006 (3:52 am)
    Can you post the whole function? Wanna see where you getting %auto from.
    #5
    09/06/2006 (6:30 pm)
    Here its is in clientConnection:
    but there is more but that is in GUIs that call it


    function GameConnection::onConnect( %client, %name, %auto )
    {
    	if(%auto !$= "")
    	{
    	   %client.auto = %auto;
    	}
    	else
    	{
    	   %client.auto = "DefaultCar";
    	}

    and in game.cs:

    // Create the player object
       %car = new WheeledVehicle() {
          dataBlock = %this.auto;
          client = %this;
       };