How do you make a vehicle?

Topics regarding Scripting with Reality Factory
Wolf Lord
Posts: 11
Joined: Mon Sep 21, 2009 7:47 am

How do you make a vehicle?

Post by Wolf Lord » Mon Sep 21, 2009 8:07 am

Can someone tell me how to make a vehicle, or if its even possible?

I've tried everything, but I can't get it to work.

User avatar
jamieo01
Posts: 81
Joined: Fri Jan 16, 2009 2:14 pm
Location: England
Contact:

Re: How do you make a vehicle?

Post by jamieo01 » Mon Sep 21, 2009 11:11 am

Hi wolf lord welcome to the forums. I've never done it before but I think that you first need to add a pawn entity then in the actor bit type the name of your vehicle model and in the scripts section type the gen1car.s and in the spawn order type spawn but thats how I think you do it I might be wrong you could try it and if it doesn't work wait for some one more experinced

Wolf Lord
Posts: 11
Joined: Mon Sep 21, 2009 7:47 am

Re: How do you make a vehicle?

Post by Wolf Lord » Mon Sep 21, 2009 1:11 pm

Thanks, I'll give it a go. :D

Wolf Lord
Posts: 11
Joined: Mon Sep 21, 2009 7:47 am

Re: How do you make a vehicle?

Post by Wolf Lord » Sun Oct 04, 2009 12:41 pm

No, it's not working. It's appearing, but it won't let me enter it. I've tried with several other models and I've tried my own script but it's not working. Anyone know why?

User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA
Contact:

Re: How do you make a vehicle?

Post by darksmaster923 » Sun Oct 04, 2009 5:38 pm

Pretty sure the gen1car.s script isn't for an actual rideable vehicle. You're probably going to have to script it yourself. Have an order that attaches the camera to the pawn, then have another order for movement
Herp derp.

Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Re: How do you make a vehicle?

Post by Jay » Sun Oct 04, 2009 6:47 pm

Would you post your script? Maybe we can help you where it's wrong. (Moved to Scripting forum)
Everyone can see the difficult, but only the wise can see the simple.
-----

Wolf Lord
Posts: 11
Joined: Mon Sep 21, 2009 7:47 am

Re: How do you make a vehicle?

Post by Wolf Lord » Mon Oct 05, 2009 12:29 am

Ok, here it is.

Code: Select all

{

	REVERSESPEED 	[32] 				// Reverse Speed
	BOXSIZE 		[72] 				// Bounding Box Size
	HSCALE 			[1] 				// Scale Multiplier
	tOFF 			[0] 				// Do Not Change
	YAWSPEED 		[128] 				// Do Not Change
	SPEED 			[0] 				// Do Not Change
	MAXSPEED 		[250] 				// Maximum Speed
	ACCELRATE 		[5] 				// Acceleration Rate - Framerate dependant
	BRAKERATE 		[50] 				// Brake Rate - Framerate dependant
	TURNRATE 		[5] 				// Turn Rate - Framerate dependant
	CARWEAPONSLOT 	[0] 				// See Docs
	DEFAULTWEAPON 	[0] 				// See Docs
	HEALTHAMOUNT 	[250] 				// Vehice health Attribute Amount
	PJOINT 			[joint1] 			// Explosion Root Joint
	CRASHSPARKS 	[CrashSparks]	 	// See Docs
	CRASHSOUND 		[crash.wav] 		// See Docs
	SPEEDATTRIB 	[CarSpeed]			// Attribute Used For HUD Speedometer and pawn communication
	DRIFTSPEED 		[10] 				// Speed car slows when not inside
	EXPLODESPEED 	[80] 				// Speed that Car Will Explode at if Crashed
	POFFSET 		[0]					// See Docs
	DRIVINGTRIG 	[DrivingTrigger]	// See Docs

	Spawn[()
	{
		Console(true);
		// Add health attribute to car
		AttributeOrder("health", HEALTHAMOUNT, "DestroyCar");
		// Scale by multiplier
		Scale(HSCALE);
		// Set Boxwidth
		BoxWidth(BOXSIZE*HSCALE);
		Delay("", 0.1, "");
		NewOrder("IdleState");
	}]

	IdleState[()
	{
		// Wait until the player is close enough to contact vehicle
		// WHen close enough start checking for entry key.
		Delay("", 0.1, "");
		PlayerDistOrder(BOXSIZE, "GoLowCheck");
	}]

	GoLowCheck[()
	{
		// Switch to low level
		LowLevel("CheckIn");
	}]

	CheckIn[()
	{
		// Check if keynumber 22 is pressed. Key 22 is, O
		if(self.key_pressed=22)
		{
			// OK, key is pressed. get in
			self.think="GetIn";
			return 0;
		}
		if(self.player_range>BOXSIZE)
		{
			// Player no longer contacting car. Go to High Level Idle.
			HighLevel("IdleState");
			return 0;
		}
	}]

	GetIn[()
	{
		// Set Think Time to run every frame.
		self.ThinkTime=0;
		// Set Up Base Values and Go to Main Routine;
		self.ideal_yaw=self.current_yaw;
		self.yaw_speed=YAWSPEED;
		//SetEventState(DRIVINGTRIG, true);
		self.think="RunCar";
	}]

	GetOut[()
	{
		SPEED=0;
		tOFF=0;
		//SetEventState(DRIVINGTRIG, false);
		//SetPlayerWeapon(DEFAULTWEAPON);
		// Position the player to the left side of the vehicle and use offset.
		PlayerToPosition(BOXSIZE+POFFSET,0,0);
		HighLevel("IdleState");
	}]

	RunCar[()
	{
		// Main Routine.

		// Acceleration
		// Check if key 27 is being pressed. Key 27 is, S
		if(IsKeyDown(27))
		{
			// Key is Pressed. Increase the vehicle speed.
			SPEED=SPEED+ACCELRATE;
			if(tOFF > 90)
			{
				SPEED=0;
				tOFF=0;
			}
			// Limit Speed to Max Speed
			if(SPEED > MAXSPEED)
			{
				SPEED=MAXSPEED;
			}
		}

		// Brakeing
		// Check if key 38 is being pressed. Key 38 is, X
		if(IsKeyDown(38))
		{
			// Vehicle is braking, slow down.
			SPEED=SPEED-BRAKERATE;
			if(SPEED < 0)
			{
				SPEED=0;
			}
		}

		// Turn Left
		// Check if key 37 is being pressed. Key 37 is, Z
		if(IsKeyDown(37))
		{
			if(SPEED > 1)
			{
				// This line sets the vehicles ideal yaw to be the current yaw + the turn rate converted to radians.
				self.ideal_yaw=self.current_yaw+TURNRATE*0.0174532925199433;
			}
		}

		// Turn Right
		if(IsKeyDown(39))
		{
			if(SPEED > 1)
			{
				// This line sets the vehicles ideal yaw to be the current yaw - the turn rate converted to radians.
				self.ideal_yaw=self.current_yaw-TURNRATE*0.0174532925199433;
			}
		}

		// Get Out
		// Check if key 23 is being pressed. Key 23 is, P
		if(IsKeyDown(23))
		{
			if(SPEED < 1)
			{
				// Speed is less then 1 so just get out and stop car.
				self.think="GetOut";
				return 0;
			}
			else
			{
				// Speed is greater then 1 so get out and keep car rolling.
				self.think="JumpOut";
				return 0;
			}
		}

		// Reverse
		// Check if key 46 is being pressed. Key 46 is, SPACE BAR
		if(IsKeyDown(46))
		{
			// Only drive backword if speed is zero
			if(SPEED < 1)
			{
				// Set reverse angle offset
				tOFF=180;
				// Set reverse driving speed
				SPEED=Integer(REVERSESPEED);
			}
		}

		// Check to see if the vehicles health is 0
		if(self.health < 1)
		{
			// Car is dead - stop everything
			self.think="CarDead";
			return 0;
		}

		// OK, move the car
		if(walkmove(self.current_yaw+(tOFF*0.0174532925199433),SPEED))
		{
			// The car moves without trouble. Position the player to the car
			PlayerToPosition(0, 0, 0);
		}
		else
		{
			// Car can't move - Crashed
			// Check to see if it is going fast enough to explode
			if(SPEED > Integer(EXPLODESPEED))
			{
				self.think="CarExplode";
				return 0;
			}
			//PlaySound(CRASHSOUND);
			// Position the player to the car
			PlayerToPosition(0, 0, 0);
			// Crash routine - Bounce car left or right
			if(walkmove(self.current_yaw+(90*0.0174532925199433), SPEED)=false)
			{
				//AddExplosion(CRASHSPARKS, PJOINT, BOXSIZE*(1), 0, 0);
				ForceRight(SPEED/(5*HSCALE));
			}
			else
			{
				//AddExplosion(CRASHSPARKS, PJOINT, BOXSIZE*(-1), 0, 0);
				ForceLeft(SPEED/(5*HSCALE));
			}
			SPEED=SPEED-(BRAKERATE*2);
			if(SPEED<0)
			{
				SPEED=0;
			}
			// Position Player to car
			PlayerToPosition(0, 0, 0);
		}

		// Turn the Car
		ChangeYaw();

		//SetAttribute(SPEEDATTRIB,SPEED);

		debug(self.key_pressed);
	}]

	CarDead[()
	{
		// The car has been shot to death
		SPEED=0;
		tOFF=0;
		//SetPlayerWeapon(DEFAULTWEAPON);
		PlayerToPosition(BOXSIZE, 0, 0, true);
		HighLevel("DestroyCar");
	}]

	DestroyCar[()
	{
		// End the script and just do nothing
		Delay("", 1, "");
	}]

	JumpOut[()
	{
		// Car is still moving when player got out
		//SetAttribute(SPEEDATTRIB, 0);
		//SetPlayerWeapon(DEFAULTWEAPON);
		PlayerToPosition(BOXSIZE, 0, 0, true);
		self.think="KeepGoing";
	}]

	KeepGoing[()
	{
		// Set the think time to make decceleration not frame rate dependant.
		self.ThinkTime=0.05;
		// Slow the car down
		SPEED=SPEED-DRIFTSPEED;
		// if speed is 0 go back to idle
		if(SPEED < 1)
		{
			HighLevel("IdleState");
			return 0;
		}

		// Move the car - If it can't then crash
		if(walkmove(self.current_yaw+(tOFF*0.0174532925199433), SPEED)=false)
		{
			//Crash routine
			if(SPEED > Integer(EXPLODESPEED))
			{
			self.think="CarExplode";
			return 0;
			} 
			//PlaySound(CRASHSOUND);
			if(walkmove(self.current_yaw+(90*0.0174532925199433), SPEED)=false)
			{
				//AddExplosion(CRASHSPARKS, PJOINT, BOXSIZE, 0, 0);
				ForceRight(SPEED/(5*HSCALE));
			}
			else
			{
				//AddExplosion(CRASHSPARKS, PJOINT, BOXSIZE*(-1), 0, 0);
				ForceLeft(SPEED/(5*HSCALE));
			}
			SPEED=SPEED-(BRAKERATE*2);
			if(SPEED<0)
			{
				SPEED=0;
			}
		}
	}]


	CarExplode[()
	{
		// The car explodes
		SPEED=0;
		// Set the explosion trigger to true and then go to dead idle
		SetEventState(self.EntityName # "Explode", true);
		HighLevel("DestroyCar");
	}]
}
(MOD EDIT: I put the script into a Code-Box for better readability)

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: How do you make a vehicle?

Post by metal_head » Mon Oct 05, 2009 8:24 am

A nice scripted vehicle is pretty possible! You can script a vehicle yourself, but you won't be able to make the physics stuff like to make it roll over if you jump with only one wheel...you won't be able to do the suspension with a script too :( Maybe it would be possible, but you'll need 5 pawns - 4 for the wheels and 1 for the vehicle body, but that's gonna be pretty hard :/
anyway, my advice is to wait for the next RF release, where physics will be available, maybe it will be easier to make a nice vehicle. :)
Last edited by metal_head on Wed Oct 21, 2009 1:33 pm, edited 1 time in total.

Wolf Lord
Posts: 11
Joined: Mon Sep 21, 2009 7:47 am

Re: How do you make a vehicle?

Post by Wolf Lord » Mon Oct 05, 2009 8:55 am

Ok, thanks.

User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA
Contact:

Re: How do you make a vehicle?

Post by darksmaster923 » Tue Oct 06, 2009 3:22 am

I don't like using the sample scripts cause it references stuff you probably don't have. You're going to have to change the variables to suit the resources you have
Herp derp.

tgrech
Posts: 18
Joined: Wed Nov 18, 2009 8:32 pm

Re: How do you make a vehicle?

Post by tgrech » Fri Nov 20, 2009 9:35 pm

I have some script but i cant turn and accelerate at the same time and its just set to stay at the speed when i let go of accelerate and when i press the slow down button it reduces the speed and then stays at that speed, its as if it has a throttle lever instead of a pedal and again i cant turn while pressing the accelerate button.

Here is the code-

Code: Select all

{

CAMTRIGGER [CamON]

YAWSPEED [180]
BRAKESPEED [10]
MAXSPEED [0]
ACCELRATE [0]
REVSPEED [0]
TURNSPEED [0]

tSPEED [0]
tYAW [0]
tOFF [180]
KP [0]
LP [0]

GP [0]
TM [0]

Spawn[()
{
Console(false);
SetGroup("PlayerCar");
AttributeOrder("SPD",10,"Die");
BoxWidth(16);
SetEventState(CAMTRIGGER,true);
Delay("",0.5,"");
LowLevel("Setup");
}]

Setup[()
{
MAXSPEED=GetAttribute("MaximumSpeed");
ACCELRATE=GetAttribute("Acceleration");
REVSPEED=GetAttribute("ReverseSpeed");
TURNSPEED=GetAttribute("TurningSpeed");
PlayerRender(false);
self.ideal_yaw=self.current_yaw;
self.yaw_speed=YAWSPEED;
TM=self.time;
PlaySound("tone1.wav");
self.think="Three";
}]

RunCar[()
{
self.ThinkTime=0.04;
KP=self.key_pressed;
	switch(KP)
	{


		// Up Arrow - Accelerate
		case 55
		{
		tOFF=0;
		tSPEED=tSPEED+ACCELRATE;
		AddExplosion("TakeOff","joint8",0,0,0);
		AddExplosion("TakeOff","joint6",0,0,0);
			if(KP != Integer(LP))
			{
			PlaySound("takeoff.wav");
			}
			if(tSPEED > Integer(MAXSPEED))
			{
			tSPEED=Integer(MAXSPEED);
			}

		}

		case 1
		{
		SetEventState("musicon",false);
		}

		case 2
		{
		SetEventState("musicon",true);
		}

		// Down Arrow - Brake
		case 56
		{
		tSPEED=tSPEED-BRAKESPEED;
			if(tSPEED<0)
			{
			tOFF=180;
			tSPEED=0;
			}
		}

		// Left Arrow - Steer Left
		case 57
		{
			if(tSPEED>0)
			{
			self.ideal_yaw=self.current_yaw+(TURNSPEED*0.0174532925199433);
			}
		}

		// Right Arrow - Steer Right
		case 58
		{

			if(tSPEED>0)
			{
			self.ideal_yaw=self.current_yaw-(TURNSPEED*0.0174532925199433);
			}
		}

		// END Key - Reverse
		case 53
		{
			if(tOFF=180)
			{
			tSPEED = Integer(REVSPEED);
			}
			else
			{
			tSPEED=tSPEED-(BRAKESPEED*2);
				if(tSPEED<0)
				{
				tOFF=180;
				tSPEED=0;
				}
			}
		}

	}
LP=Integer(KP);
self.yaw_speed=tSPEED;
if(walkmove(self.current_yaw+(tOFF*0.0174532925199433),tSPEED)=true)
{
ChangeYaw();
//GP=PortIn(513);
//debug(KP);
}
else
{
PlaySound("crash.wav");
//Crashed
	if(walkmove(self.current_yaw+(90*0.0174532925199433),tSPEED)=false)
	{
	AddExplosion("CrashSparks","joint9",0,0,0);
	ForceRight(tSPEED/5);
	}
	else
	{
	AddExplosion("CrashSparks","joint7",0,0,0);
	ForceLeft(tSPEED/5);
	}
	tSPEED=tSPEED-(BRAKESPEED*2);
	if(tSPEED<0)
	{
	tOFF=180;
	tSPEED=0;
	}
}

SetAttribute("SPEED",Integer(tSPEED));
SetAttribute("RPM",Integer(tSPEED));

if(tSPEED>20)
{
AddExplosion("TakeOff","joint8",0,0,0);
AddExplosion("TakeOff","joint6",0,0,0);
}

}]

Three[()
{
SetEventState("threego",true);
if(self.time>TM+1)
{
SetEventState("threego",false);
TM=self.time;
PlaySound("tone1.wav");
self.think="Two";
}
}]

Two[()
{
SetEventState("twogo",true);
if(self.time>TM+1)
{
SetEventState("twogo",false);
TM=self.time;
PlaySound("tone1.wav");
self.think="One";
}
}]

One[()
{
SetEventState("onego",true);
if(self.time>TM+1)
{
SetEventState("onego",false);
TM=self.time;
PlaySound("tone2.wav");
self.think="Go";
}
}]

Go[()
{
SetEventState("finalgo",true);
SetEventState("musicon",true);
if(self.time>TM+0.2)
{
SetEventState("finalgo",false);
self.think="RunCar";
}
}]


}


I was wondering if i could convert this code to work with RF as well-

Code: Select all

car
{
  name= 
  year= 
  comments= 
  id=fw24
  version=050b6
  credits= 
  wheels=4
  skid
  {
    sample=skid.wav
  }
  shadow
  {
    texture=shadow.tga
    width=2.2
    length=4.55
  }
  cg
  {
    x=0
    y=-0.2
    z=-0.3
  }
}
body
{
  mass=548
  restitution_coeff=0.3
  inertia
  {
    x=1800
    y=1900
    z=450
  }
  model
  {
    file=body.dof
  }
  width=1.943
  height=0.6
  length=4.323
  manual_box=0
 }
 steer
 {
  x=0
  y=-0.07
  z=0.46
  radius=11
  xa=5
  lock=85
  model
  {
    file=s_wheel.dof
  }
}
engine
{
  mass=120
  max_rpm=18400
  idle_rpm=1600
  stall_rpm=1500
  start_rpm=1570
  autoclutch_rpm=8000
  starter=1
  starter_torque=90
  curve_torque=torque.crv
  max_torque=290
  start_stalled=1
  reaction=1
  shifting
  {
    automatic=1
    shift_up_rpm=15800
    shift_down_rpm=8200
    time_to_declutch=75
    time_to_clutch=125
  }
  inertia
  {
    engine=0.12
    final_drive=0.12
  }
  braking_coeff=3.0
  rolling_friction_coeff=2.0
  sample=engine.wav
  sample_rpm=20400
}
gearbox
{
  gears=8
  gear0
  {
    ratio=-5.479
    inertia=1.2
  }
  gear1
  {
    ratio=5.132
    inertia=0.7
  }
  gear2
  {
    ratio=4.244
    inertia=0.6
  }
  gear3
  {
    ratio=3.518
    inertia=0.5
  }
  gear4
  {
    ratio=2.927
    inertia=0.4
  }
  gear5
  {
    ratio=2.444
    inertia=0.3
  }
  gear6
  {
    ratio=2.050
    inertia=0.2
  }
  gear7
  {
    ratio=1.680
    inertia=0.1
  }
  end_ratio=3.5
}
clutch
{
  max_torque=1200
}
differential
{
  type=1
  locking_coefficient=75
  power_angle=60
  coast_angle=40
  clutches=3
  clutch_factor=1.0
  ratio=3.5
}
aero
{
  body
  {
    center=0 0 0
    cx=0.22
    area=1.6
  }
  wings=2
  wing0
  {
    name=FrontDam
    span=1.3
    cord=0.15
    coeff_drag=1.2
    coeff_down=18
    center=0 -0.2 1.33
    angle=32
    angle_offset=1.8
  }
  wing1
  {
    name=RearWing
    span=1.2
    cord=0.15
    coeff_drag=1.6
    coeff_down=24
    center=0 -0.2 -1.43
    angle=35
    angle_offset=2
  }
}
antirollbar
{
  count=2
  arb0
  {
    susp_left=0
    susp_right=1
    k=28000
  }
  arb1
  {
    susp_left=2
    susp_right=3
    k=19000
  }
}
; Suspension
susp0
{
  x=.77
  y=0.14
  z=1.68
  restlen=.48
  minlen=.4
  maxlen=.9
  k=80000
  anti_pitch=0.9
  bump_rate=9400
  rebound_rate=9500
  roll_center
  {
    x=0
    y=-0.5
    z=0
  }
}
susp1
{
  x=-.77
  y=0.14
  z=1.68
  restlen=.48
  minlen=.4
  maxlen=.9
  k=80000
  anti_pitch=0.9
  bump_rate=9400
  rebound_rate=9500
  roll_center
  {
    x=0
    y=-0.5
    z=0
  }
}
susp2
{
  x=.735
  y=0.16
  z=-2.14
  restlen=.5
  minlen=.42
  maxlen=.9
  k=82000
  anti_pitch=0.6
  bump_rate=9200
  rebound_rate=9500
  roll_center
  {
    x=0
    y=-0.5
    z=0
  }
}
susp3
{
  x=-.735
  y=0.16
  z=-2.14
  restlen=.5
  minlen=.42
  maxlen=.9
  k=82000
  anti_pitch=0.6
  bump_rate=9200
  rebound_rate=9500
  roll_center
  {
    x=0
    y=-0.5
    z=0
  }
}

tire_model
{
  relaxation_length_lat=0.91
  relaxation_length_long=.091
  damping_speed=0.3
  damping_coefficient_lat=0.7
  damping_coefficient_long=0.7
}
pacejka
{
    a0=1.7
    a1=0
    a2=1400
    a3=4140
    a4=15
    a5=0
    a6=-0.3589
    a7=1
    a8=0
    a9=0.006111
    a10=.03224
    a111=0
    a112=0
    a12=0
    a13=0
    b0=1.3
    b1=0
    b2=1400
    b3=0
    b4=229
    b5=0
    b6=-0.00386
    b7=0
    b8=-10
    b9=0
    b10=0
    c0=2.068
    c1=-6.49
    c2=-21.85
    c3=0.416
    c4=-21.31
    c5=.02942
    c6=0
    c7=-1.1970
    c8=5.228
    c9=-14.84
    c10=0
    c11=0
    c12=-0.003736
    c13=.03891
    c14=0
    c15=0
    c16=0.639
    c17=1.693
}
pacejkarear
{
    a0=1.7
    a1=0
    a2=1500
    a3=4140
    a4=15
    a5=0
    a6=-0.3589
    a7=1
    a8=0
    a9=0.006111
    a10=.03224
    a111=0
    a112=0
    a12=0
    a13=0
    b0=1.3
    b1=0
    b2=1500
    b3=0
    b4=229
    b5=0
    b6=-0.00386
    b7=0
    b8=-10
    b9=0
    b10=0
    c0=2.068
    c1=-6.49
    c2=-21.85
    c3=0.416
    c4=-21.31
    c5=.02942
    c6=0
    c7=-1.1970
    c8=5.228
    c9=-14.84
    c10=0
    c11=0
    c12=-0.003736
    c13=.03891
    c14=0
    c15=0
    c16=0.639
    c17=1.693
}
wheel0
{
  x=0
  y=0
  z=0
  steering=1
  powered=0
  camber=-2.55
  lock=28
  mass=5
  inertia=1
  radius=.35
  rolling_coeff=0.015
  tire_rate=160000
  max_braking=2140
  braking_factor=1
  model
  {
    file=tire_lf.dof
  }
  model_brake
  {
    file=caliper_lf.dof
  }
  pacejka~pacejka
  {
  }
}
wheel1
{
  x=0
  y=0
  z=0
  steering=1
  powered=0
  camber=-2.55
  lock=28
  mass=5
  inertia=1
  radius=.35
  rolling_coeff=0.015
  tire_rate=160000
  max_braking=2140
  braking_factor=1
  model
  {
    file=tire_rf.dof
  }
  model_brake
  {
    file=caliper_rf.dof
  }
  pacejka~pacejka
  {
  }
}
wheel2
{
  x=0
  y=0
  z=0
  steering=0
  camber=-2.0
  toe=0
  powered=1
  mass=5
  inertia=1
  radius=.35
  rolling_coeff=0.015
  tire_rate=160000
  max_braking=980
  braking_factor=1
  model
  {
    file=tire_lr.dof
  }
  model_brake
  {
    file=caliper_lr.dof
  }
  pacejka~pacejkarear
  {
  }
}
wheel3
{
  x=0
  y=0
  z=0
  steering=0
  camber=-2.0
  toe=0
  powered=1
  mass=5
  inertia=1
  radius=.35
  rolling_coeff=0.015
  tire_rate=160000
  max_braking=980
  braking_factor=1
  model
  {
    file=tire_rr.dof
  }
  model_brake
  {
    file=caliper_rr.dof
  }
  pacejka~pacejkarear
  {
  }
}
camera0
{
  offset
  {
    x=0.009376
    y=-0.112499
    z=-0.204999
  }
  angle
  {
    x=10.277766
    y=178.090164
    z=0.607639
  }
  name=Cockpit
  follow
  {
    pitch=0
    yaw=1
    roll=0
  }
  fov=60
}
camera7
{
  offset
  {
    x=0.517187
    y=0.706250
    z=-3.165002
  }
  angle
  {
    x=5.000007
    y=-37.499973
    z=0.000000
  }
  name=Front Corner
  follow
  {
    pitch=0
    yaw=1
    roll=0
  }
  fov=70
}
camera8
{
  offset
  {
    x=-0.510938
    y=0.227083
    z=-4.085004
  }
  angle
  {
    x=15.416676
    y=219.236130
    z=0.000000
  }
  follow
  {
    pitch=0
    yaw=1
    roll=0
  }
  name=Rear Corner
  fov=50
}
camera9
{
  follow
  {
    pitch=1
    yaw=1
    roll=1
  }
  offset
  {
    x=0.003127
    y=-0.712501
    z=0.454998
  }
  angle
  {
    x=14.444450
    y=360.416504
    z=-0.173617
  }
  name=Back Cam
  fov=50
}
camera4
{
  offset
  {
    x=-0.381250
    y=-1.025002
    z=-5.324995
  }
  angle
  {
    x=1.250012
    y=142.673538
    z=0.000000
  }
  follow
  {
    pitch=1
    yaw=1
    roll=1
  }
  fov=50
  name=Right Rear
}
camera6
{
  follow
  {
    pitch=0
    yaw=1
    roll=0
  }
  offset
  {
    x=-0.018750
    y=-0.145834
    z=-1.010008
  }
  angle
  {
    x=0.833327
    y=0.694444
    z=-0.520836
  }
  name=Front
  fov=50
}
camera1
{
  offset
  {
    x=0.200000
    y=-0.827082
    z=-6.510006
  }
  angle
  {
    x=7.499997
    y=178.437576
    z=0.000000
  }
  fov=50
  name=Chase
  follow
  {
    pitch=1
    yaw=1
    roll=1
  }
}
camera3
{
  follow
  {
    pitch=1
    yaw=1
    roll=1
  }
  offset
  {
    x=1.070316
    y=0.260424
    z=-2.349991
  }
  angle
  {
    x=11.805562
    y=-191.111221
    z=0.000000
  }
  fov=50
  model=0
  wheels=0
  view=1
  name=Hood Left
}
camera2
{
  offset
  {
    x=0.006250
    y=-0.368750
    z=-0.595000
  }
  angle
  {
    x=19.805578
    y=179.479156
    z=0.347222
  }
  follow
  {
    pitch=1
    yaw=1
    roll=1
  }
  fov=45
  name=TV Cockpit
}
camera5
{
  follow
  {
    pitch=0
    yaw=0
    roll=0
  }
  offset
  {
    x=0.098437
    y=-0.193748
    z=-6.124995
  }
  angle
  {
    x=17.916677
    y=180.000000
    z=0.000000
  }
  name=Fixed
  fov=50
}
Also ||||This is my First Post!!!!||||

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: How do you make a vehicle?

Post by Juutis » Sat Nov 21, 2009 11:32 am

Code: Select all

KP=self.key_pressed;
   switch(KP)
   {
     ...
   }
You should use IsKeyDown() with many if-statements instead of key_pressed with a switch-structure. Right now the script registers only the key press for a single key. And obviously that's not very good. :)

As I see it, the other code you posted is just a bunch of values, like a car definition. It doesn't have any actual functionality. You could of course write a script that uses these values, but I don't think it would be worth it. RF doesn't have proper physics yet, so you can't create cars that are even close to being realistic.

And last but not least: Welcome to the forums. :)
Pain is only psychological.

tgrech
Posts: 18
Joined: Wed Nov 18, 2009 8:32 pm

Re: How do you make a vehicle?

Post by tgrech » Sat Nov 21, 2009 12:49 pm

Thank you, i will try it soon. Someone said a few posts up that you can make a car more realistic if you create a different pawn for each wheel, has anyone tried this?
metal_head wrote:A nice scripted vehicle is pretty possible! You can script a vehicle yourself, but you won't be able to make the physics stuff like to make it roll over if you jump with only one wheel...you won't be able to do the suspension with a script too Maybe it would be possible, but you'll need 5 pawns - 4 for the wheels and 1 for the vehicle body, but that's gonna be pretty hard :/
anyway, my advice is to wait for the next RF release, where physics will be available, maybe it will be easier to make a nice vehicle.

tgrech
Posts: 18
Joined: Wed Nov 18, 2009 8:32 pm

Re: How do you make a vehicle?

Post by tgrech » Sun Dec 20, 2009 11:48 am

Juutis wrote:

Code: Select all

KP=self.key_pressed;
   switch(KP)
   {
     ...
   }
You should use IsKeyDown() with many if-statements instead of key_pressed with a switch-structure. Right now the script registers only the key press for a single key. And obviously that's not very good. :)

As I see it, the other code you posted is just a bunch of values, like a car definition. It doesn't have any actual functionality. You could of course write a script that uses these values, but I don't think it would be worth it. RF doesn't have proper physics yet, so you can't create cars that are even close to being realistic.

And last but not least: Welcome to the forums. :)
When i try that code it just dosnt work(the vehicle), is there something i might be doing wrong?

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: How do you make a vehicle?

Post by metal_head » Sun Dec 20, 2009 12:17 pm

Post the code here (only the part we're talking about)

Post Reply