Wow, thanks, it's finally staying on ground! I messed around settings so that it's wheels are touching ground and spinning same direction. But car feels way too light, is there way increase its weight or increase gravity? It's like driving on moon.
But there is more problems, one is that when turning only left side wheels turn.(I have set wheel locations correctly) And another problem is that car is moving very slowly, maybe car body is touching ground? Could you check that if your debug is working and maybe send a screenshot?
Here is one question I really need answer when I'm building another vehicle:
So when im modelling vehicle should I move all wheels to center of modelling program to get their pivot points correct, and then move them in place inside DBP by using offset limb?
I think you have to download modified model to test my code because now I put all wheels to center of 3ds max and moved wheels to their place with code in DB:
http://www.megaupload.com/fi/?d=6N1M4IPD
Here is code with my settings(I added mouse controlled camera for better testing):
Rem Created: 02/02/2009 17:09:29
Rem ***** Main Source File *****
phy enable debug
phy start
autocam off
sync on
sync rate 60
set display mode 1280, 1024, 32
color backdrop 0
make light 1
set directional light 1, -5, -5, 5
position camera -20, 20, -25
point camera 0, 10, 0
hide mouse
load image "fur.bmp", 1
make object box 1, 1000, 1, 1000
position object 1, 0, -17, 0
texture object 1, 1
phy make rigid body static box 1
load object "auto.x", 2
texture object 2, 1
rotate limb 2,0, 0, -90,0
scale object texture 2, 0.1, 0.1
position object 2, 15, 40, -25
rem Create vehicle physics body
wheelX# = object size x(2)
wheelY# = -8.0
wheelZ# = object size z(2)
radius# = 2
wheelHeight# = 2
offset limb 2, 1, 0, 0, -15
offset limb 2, 2, 0, 0, 15
offset limb 2, 4, 0, 0, -15
offset limb 2, 3, 0, 0, 15
rem Be aware the vehicle width and length orientation
phy create vehicle 2
`phy add vehicle body 2, length#, height#, width#, 0.0, height#, 0.0
phy add vehicle body 2, object size z(2),3,object size x(2), 0.0, 5, 0.0
`phy add vehicle body 2, width#, height#, width#, 0.0, height#*2, 0.0
phy add vehicle wheel 2, 1, -wheelZ#, wheelY#, wheelX#, radius#, wheelHeight#, 1, 1
phy add vehicle wheel 2, 2, -wheelZ#, wheelY#, -wheelX#, radius#, wheelHeight#, 0, 1
phy add vehicle wheel 2, 3, wheelZ#, wheelY#, -wheelX#, radius#, wheelHeight#, 0, 1
phy add vehicle wheel 2, 4, wheelZ#, wheelY#, wheelX#, radius#, wheelHeight#, 1, 1
`phy create vehicle 2
`phy add vehicle wheel 2,1,limb position z(2,1)-10,limb position y(2,1),limb position x(2,1), 16, 0.2, 1, 1
`phy add vehicle wheel 2,2,limb position z(2,2),limb position y(2,2),limb position x(2,2), 16, 0.2, 0, 1
`phy add vehicle wheel 2,3,limb position z(2,3),limb position y(2,3),limb position x(2,3), 16, 0.2, 0, 1
`phy add vehicle wheel 2,4,limb position z(2,4),limb position y(2,4),limb position x(2,4), 16, 0.2, 1, 1
phy set vehicle max motor 2, 200.0
`phy set vehicle steering delta 2, 0.1
`phy set vehicle max steering angle 2, 0.4
phy set vehicle auto 2, 1
phy set vehicle suspension spring 2,100
phy set static friction 0
phy set dynamic friction 0
phy build vehicle 2
make object box 3, 10, 10, 10
hide object 3
LimitLow#=-5
LimitHigh#=60
CameraFollowObject#=2
mouse_Xsens# = 0.4
mouse_Ysens# = 0.4
do
``set camera to follow object position x ( 2 ), object position y ( 2 ), object position z ( 2 ), 0, 140, 60, 1, 0
if upkey() = 1
phy set vehicle motor force 2, phy get vehicle motor force ( 2 )
else
if downkey() = 1
phy set vehicle motor force 2, 0.0
else
if phy get vehicle motor force (2) <> 0.0
phy set vehicle motor force 2, 0.0
endif
endif
endif
``steeringAngle# = phy get vehicle steering angle ( 2 )
``steeringDelta# = phy get vehicle steering delta ( 2 )
if leftkey()
rotate object 2, object angle x (2) + 5, 0, 0
endif
if rightkey()
rotate object 2, object angle x (2) - 5, 0, 0
endif
remstart
if leftkey ( ) = 1
if steeringAngle# > ( -1.0 + steeringDelta# )
steeringAngle# = steeringDelta# - steeringDelta# / 2
endif
else
if rightkey ( ) = 1
if steeringAngle# < (1.0+ steeringDelta# )
steeringAngle = steeringDelta# + 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
endif
endif remend
`Get player position
PlayerX#=object position x(3)
PlayerY#=object position y(3)
PlayerZ#=object position z(3)
CFOX#=object position x(CameraFollowObject#)
CFOY#=object position y(CameraFollowObject#)
CFOZ#=object position z(CameraFollowObject#)
Rem player rotate
yrotate object 3,object angle y(3)+(mousemovex() * mouse_Xsens# )
ay# = object angle y(3)
ax#=ax#+(mousemovey()* mouse_Ysens# )
if ax#>LimitLow# and ax#<LimitHigh# then look#=ax#
ax#=look#
sx#=camera position x()
sy#=camera position y()
sz#=camera position z()
cx# = CFOX#+150*cos(ax#)*sin(ay#)*-1
cy# = CFOY#+150*sin(ax#)
cz# = CFOZ#+150*cos(ax#)*cos(ay#)*-1
position camera curvevalue(cx#,sx#,10),curvevalue(cy#,sy#,10),curvevalue(cz#,sz#,5)
point camera CFOX#,CFOY#,CFOZ#
`Limit view X axis
if wrapvalue(camera angle x(0))>40 and wrapvalue(camera angle x(0))<180
xrotate camera 0,40
CameraAngleX#=40
endif
if wrapvalue(camera angle x(0))>180 and wrapvalue(camera angle x(0))<180
xrotate camera 0,180
CameraAngleX#=180
endif
``phy set vehicle steering angle 2, steeringAngle#
phy update
sync
loop