I tried to accomplish making a vehicle simulation using a evolution 8 model, but to no success.
The funny thing was the problem thing that wasn't working well was the driving code, which actually came, code for code from the reference section of dark physics.
The wheels dont rotate correctly... they seem to rotate to the right.... not like a tire would but side ways. I figured a ss would not help anyone decifer this problem, but included the code.
Under contract im not obligated to give out the program as a whole with the model and the textures, simply because it costed $1,500.
Any comments are greatly appreciated thank you.
` program set up
phy start
autocam on
sync on
sync rate 60
color backdrop rgb(130,160,220)
position camera -5, 4, -7.5
rotate camera 0,30,0
make light 1
set directional light 1, -5, -5, 5
Global VehicleId as Integer
Global WheelId as Integer
` create ground object
make object box 1, 500, 1, 500
load image "smoke2.bmp", 1
texture object 1, 1
color object 1,rgb(70,70,70)
position object 1,0,-2,0
phy make rigid body static box 1
CreateVehicle("car.X", "Wheel.X")
` main loop
do
gosub driveCar
perform checklist for object limbs VehicleId
for n = 1 to checklist quantity()
text 0,n*10,checklist string$(n)
text 150,n*10 , str$(checklist value a(n))
next n
` follow car
set camera to follow object position x ( VehicleId ), object position y ( VehicleId ), object position z ( VehicleId ), 0, 6, 4, 1, 0
` update physics and screen
phy update
sync
loop
driveCar:
if upkey ( ) = 1
phy set vehicle motor force VehicleId, phy get vehicle motor force ( VehicleId )
else if downkey ( ) = 1
phy set vehicle motor force VehicleId, 0.0
else if phy get vehicle motor force ( VehicleId ) <> 0.0
phy set vehicle motor force VehicleId, 0.0
endif
steeringAngle# = phy get vehicle steering angle ( VehicleId )
steeringDelta# = phy get vehicle steering delta ( VehicleId )
if leftkey ( ) = 1
if steeringAngle# > ( -1.0 + steeringDelta# )
steeringAngle# = steeringAngle# - (steeringDelta# / 2)
endif
else if rightkey ( ) = 1
if steeringAngle# < ( 1.0 - steeringDelta# )
steeringAngle# = steeringAngle# + (steeringDelta# / 2)
endif
else
if steeringAngle# > 0.0
steeringAngle# = steeringAngle# - steeringDelta# * 2
if steeringAngle# < 0
steeringAngle# = 0.0
endif
else if steeringAngle < 0.0
steeringAngle# = steeringAngle# + steeringDelta# * 2
if steeringAngle# > 0
steeringAngle# = 0.0
endif
endif
endif`I dont know why, but it seems the else if's
endif` are messing up the code
endif` and not actually ending... this WAS straight from the tutorials
endif` in the reference section of dark physics
endif` a lot of things were miss coded. Like trying to use -= and += as a operator.. not even available in db.. lol
`it is in C++ and VB though... its okay lee, i do the same thing. ;)
phy set vehicle steering angle VehicleId, steeringAngle#
RETURN
Function CreateVehicle(BodyFile as String,WheelFile as String)
VehicleId = FreeObj()
Load object BodyFile, VehicleId
`rotate limb VehicleId, 23, 0, 90, 0
`WheelId = FreeObj()
`Load Object WheelFile, WheelId
Link Limb VehicleId, 4, 5
Link Limb VehicleId, 7, 8
Link Limb VehicleId, 10, 11
Link Limb VehicleId, 14, 12
set blend mapping on VehicleId,1,3,2,16
`Load object WheelFile + ".x", WheelId
phy create vehicle VehicleId
phy add vehicle body VehicleId, object size x(VehicleId), object size y(VehicleId), object size z(VehicleId), 0, 0, 0
`FrontWheels
phy add vehicle wheel VehicleId, 23, -1.5, 0.3, 1.1, 0.6, 0.2, 1, 1`left front
phy add vehicle wheel VehicleId, 3, 1.5, 0.3, 1.1, 0.6, 0.2, 0, 0`left rear
`RearWheels
phy add vehicle wheel VehicleId, 15, -1.5, 0.3, -1.1, 0.6, 0.2, 1, 0`right front
phy add vehicle wheel VehicleId, 9, 1.5, 0.3, -1.1, 0.6, 0.2, 0, 1`right rear
`Motor Force
phy set vehicle max motor VehicleId, 300.0
`Steering ability
phy set vehicle steering delta VehicleId, 0.1
`Max Steer Angle
phy set vehicle max steering angle VehicleId, 0.4
`Setup Controls Automaticalling
phy set vehicle auto VehicleId, 1
`Setup Vehicle Suspension
phy set vehicle suspension spring VehicleId,100
`Finished, now build our monster! Muahaha!
phy build vehicle VehicleId
EndFunction VehicleId
function FreeObj()
repeat
inc o
until object exist(o) = 0
endfunction o