Hey, tiresius. I messed with the values like you said, and my car is pretty stable now. The only thing I can't figure out how to do is make the vehicle faster. It seems like none of the parameters in NDB_NewtonVehicleAddTire affect the speed of the car. And no matter how much torque I put on the tire, there is a certain max speed for the car. Is there some kind of NDB_NewtonSetVehicleMaxSpeed command or something, or am I just doing something wrong. I have to keep it at 30 fps, by the way. Here's my code (the terrain function doesn't do anything in this code)
sync on
sync rate 30
NDB_NewtonCreate
NDB_SetVector 1, -10000.0, -5000.0, -10000.0
NDB_SetVector 2, 10000.0, 5000.0, 10000.0
NDB_NewtonSetWorldSize
NDB_SetVector 1,0,-98.0,0
NDB_SetStandardGravity
dim objid(100)
dim vehid(100)
makebox(1,0,0,0,10000,30,10000,0,1)
makebox(2,0,250,0,125,25,100,50,1)
makesphere(3,30,250,55,25,2,0)
makesphere(4,30,250,-55,25,2,0)
makesphere(5,-30,250,55,25,2,0)
makesphere(6,-30,250,-55,25,2,0)
makevehicle(2,3,4,5,6,3,17.5,20,400,400,10,45,-40,50)
do
if controlkey() then NDB_DebugDrawNewtonLines
ocax#=cax#
ocay#=cay#
cax#=wrapvalue(cax#+mousemovey()*0.2)
cay#=wrapvalue(cay#+mousemovex()*0.2)
yrotate camera Curveangle(cay#,ocay#,24)
xrotate camera Curveangle(cax#,ocax#,24)
if upkey()=1 then move camera 10
if downkey()=1 then move camera -10
if leftkey()=1 then move camera left 10
if rightkey()=1 then move camera right 10
Accel=0
turnangle#=0
torque#=0
Sec#=NDB_GetElapsedTimeInSec()
NDB_NewtonUpdate Sec#
NDB_NewtonUpdateTires vehid(2)
if keystate(17)=1 then torque#=15000:Accel=1
if keystate(31)=1 then torque#=-15000:Accel=1
if keystate(30)=1 then turnangle#=turnangle#-15
if keystate(32)=1 then turnangle#=turnangle#+15
if keystate(32)=0 and keystate(30)=0 then turnangle#=turnangle#*.25
if turnangle#>75 then turnangle#=75
for x=3 to 6
if Accel=1 then NDB_VehicleTireSetTorque vehid(2),objid(x),torque#
next x
for x=5 to 6
NDB_VehicleTireSetSteeringAngle vehid(2),objid(x),turnangle#
next x
sync
loop
function makebox(obj,px#,py#,pz#,sx#,sy#,sz#,mass#,flag)
make object box obj,sx#,sy#,sz#
if flag>0
position object obj,px#,py#,pz#
Col1=NDB_NewtonCreateBox(sx#,sy#,sz#)
Cube1=NDB_NewtonCreateBody(Col1)
NDB_NewtonReleaseCollision Col1
NDB_BuildMatrix 0,0,0,px#,py#,pz#
NDB_NewtonBodySetMatrix Cube1
NDB_CalculateMIBoxSolid mass#,sx#,sy#,sz#
NDB_NewtonBodySetMassMatrix Cube1,mass#
NDB_BodySetDBProData Cube1,obj
NDB_BodySetGravity Cube1,1
objid(obj)=Cube1
endif
endfunction
function makesphere(obj,px#,py#,pz#,s#,mass#,flag)
make object sphere obj,s#*2
if flag>0
position object obj,px#,py#,pz#
Col1=NDB_NewtonCreateSphere(s#)
Cube1=NDB_NewtonCreateBody(Col1)
NDB_NewtonReleaseCollision Col1
NDB_BuildMatrix 0,0,0,px#,py#,pz#
NDB_NewtonBodySetMatrix Cube1
NDB_CalculateMISphereSolid mass#,s#
NDB_NewtonBodySetMassMatrix Cube1,mass#
NDB_BodySetDBProData Cube1,obj
NDB_BodySetGravity Cube1,1
objid(obj)=Cube1
endif
endfunction
function makevehicle(chassis,w1,w2,w3,w4,mass#,width#,radius#,sho#,spr#,length#,x#,y#,z#)
NDB_SetVector 0,1,0
vehid(chassis)=NDB_NewtonConstraintCreateVehicle(objid(chassis))
NDB_BuildMatrix 0,0,0,x#,y#,z#
NDB_SetVector 0,0,1
objid(w1)=NDB_NewtonVehicleAddTire(vehid(chassis),mass#,width#,radius#,sho#,spr#,length#)
NDB_VehicleTireSetDBProData vehid(chassis),objid(w1),w1
NDB_BuildMatrix 0,0,0,x#,y#,-z#
NDB_SetVector 0,0,1
objid(w2)=NDB_NewtonVehicleAddTire(vehid(chassis),mass#,width#,radius#,sho#,spr#,length#)
NDB_VehicleTireSetDBProData vehid(chassis),objid(w2),w2
NDB_BuildMatrix 0,0,0,-x#,y#,z#
NDB_SetVector 0,0,1
objid(w3)=NDB_NewtonVehicleAddTire(vehid(chassis),mass#,width#,radius#,sho#,spr#,length#)
NDB_VehicleTireSetDBProData vehid(chassis),objid(w3),w3
NDB_BuildMatrix 0,0,0,-x#,y#,-z#
NDB_SetVector 0,0,1
objid(w4)=NDB_NewtonVehicleAddTire(vehid(chassis),mass#,width#,radius#,sho#,spr#,length#)
NDB_VehicleTireSetDBProData vehid(chassis),objid(w4),w4
NDB_NewtonBodySetAutoFreeze objid(chassis),0
endfunction
function maketerrain(file$,file2$,obj,img,xpos#,ypos#,zpos#,scale#)
load object file$,obj
load image file2$,img
texture object obj,img
position object obj,xpos#,ypos#,zpos#
scale object obj,scale#,scale#,scale#
Col=NDB_NewtonCreateTreeCollision(obj)
objid(obj)=NDB_NewtonCreateBody(Col)
NDB_NewtonReleaseCollision Col1
NDB_BuildMatrix 0,0,0,xpos#,ypos#,zpos#
NDB_NewtonBodySetMatrix objid(obj)
NDB_NewtonBodySetMassMatrix objid(obj),0
NDB_BodySetDBProData objid(obj),obj
endfunction
function NEVAR()
make memblock 1,1
endfunction
Can you point me in the right direction? Thanks
Codesurge is so awesome, thanks Hyrichter.