Jump to content

Some problems with wheels


Arska134
 Share

Recommended Posts

Hello everyone!

 

I have to ask if someone knows solution to my problems with vehicle wheels.

 

First of all picture:

wheels.png

 

 

First problem is that why my vehicles wheels are going through terrain? And how it can be fixed?

 

Second one is, while vehicle is moving wheels are not keeping their location. I am not meaning springs, but wheels are also moving in x and z axis when vehicle is moving.

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

Here is some vehicle code:

Global Car:TEntity=LoadModel("abstract::"+carname$+".gmf")

Local CarBody:TBody=CreateBodyBox(2,0.5,4)
moveentity carBody, vec3(0,-0.2,0)
SetBodyMass CarBody, CarMass
EntityParent Car,CarBody
entitytype carbody, 3
Global vehicle:TVehicle=CreateVehicle(CarBody)
SetBodyFriction(carBody, 0.5, 0.5)

AddVehicleTire(vehicle, Vec3(FRightTirePosX, FRightTirePosY, FRightTirePosZ),tireradius,suspensionlength,springconstant,springdamper)
AddVehicleTire(vehicle, Vec3(BRightirePosX, BRightirePosY, BRightirePosZ),tireradius,suspensionlength,springconstant,springdamper)
AddVehicleTire(vehicle, Vec3(FLeftTirePosX, FLeftTirePosY, FLeftTirePosZ),tireradius,suspensionlength,springconstant,springdamper)
AddVehicleTire(vehicle, Vec3(BLeftTirePosX, BLeftTirePosY, BLeftTirePosZ),tireradius,suspensionlength,springconstant,springdamper)
SetBodyMass CarBody, CarMass
EntityType CarBody,2

Local tiremesh:TMesh[4]
For Local i:Int=0 To 3
tiremesh[i]=CreateCylinder()
Next

 

Later in main loop:

AddTireTorque(vehicle,torque,2)
SetSteerAngle(vehicle,steerangle,2)
AddTireTorque(vehicle,torque,0)
SetSteerAngle(vehicle,steerangle,0)

AddTireTorque(vehicle,torque,3)
SetSteerAngle(vehicle,0,3)

AddTireTorque(vehicle,torque,1)
SetSteerAngle(vehicle,0,1)

For Local ii:Int=0 To 3
 tiremesh[ii].SetMatrix(GetTireMatrix(vehicle,ii))
 Turnentity tiremesh[ii],vec3(0,0,90)
scaleentity tiremesh[ii], vec3(TireRadius,TireWidth,TireRadius)
Next

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

I think it's not problem because vehicle makes jump and when it's landed wheels are stuck in ground again.

 

Here is some new code:

 

Global Car:TEntity=LoadModel("abstract::"+carname$+".gmf")
'ScaleEntity Car,Vec3(2,0.5,4)

Local CarBody:TBody=CreateBodyBox(2,0.5,4)
moveentity carBody, vec3(0,-0.2,0)
SetBodyMass CarBody, CarMass
EntityParent Car,CarBody
entitytype carbody, 3
Global vehicle:TVehicle=CreateVehicle(CarBody)
SetBodyFriction(carBody, 0.5, 0.5)
' Asetellaan renkaat
AddVehicleTire(vehicle, Vec3(FRightTirePosX, FRightTirePosY, FRightTirePosZ),tireradius,suspensionlength,springconstant,springdamper) 'oikea etu
AddVehicleTire(vehicle, Vec3(BRightirePosX, BRightirePosY, BRightirePosZ),tireradius,suspensionlength,springconstant,springdamper) ' oikea taka
AddVehicleTire(vehicle, Vec3(FLeftTirePosX, FLeftTirePosY, FLeftTirePosZ),tireradius,suspensionlength,springconstant,springdamper) ' vasen etu
AddVehicleTire(vehicle, Vec3(BLeftTirePosX, BLeftTirePosY, BLeftTirePosZ),tireradius,suspensionlength,springconstant,springdamper) ' vasen taka
SetBodyMass CarBody, CarMass
EntityType CarBody,2
' Create visible tires on tire places
Local tiremesh:TMesh[4]
Local tirebody:TBody[4]
For Local i:Int=0 To 3
tiremesh[i]=CreateCylinder()
tirebody[i]=CreateBodyCylinder( TireRadius, TireWidth )
entitytype tirebody[i], 2
Next

 

 

And later in loop:

For Local ii:Int=0 To 3
tiremesh[ii].SetMatrix(GetTireMatrix(vehicle,ii))
tirebody[ii].SetMatrix(GetTireMatrix(vehicle,ii))
Turnentity tiremesh[ii],vec3(0,0,90)
Turnentity tirebody[ii],vec3(0,0,90)
scaleentity tiremesh[ii], vec3(TireRadius,TireWidth,TireRadius)
scaleentity tirebody[ii], vec3(TireRadius,TireWidth,TireRadius)
Next

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...