Thanks Cliff
I was thinking I could use the same method with collision blocks I used with the AI cars and have the plane fly around the track doing random rolls etc
so I have added code like this
type aircraft
chassis as integer
propellor as integer
image as integer
vectV as integer
vectU as integer
accScale as float
velocity as velocity
collisionLeft as integer
collisionRight as integer
collisionMiddle as integer
endtype
biplane as aircraft
biplane.chassis=loadobject("biplane.obj")
biplane.image=loadImage("biplane.png")
biplane.collisionLeft=loadObject("AI.obj")
biplane.collisionRight=loadObject("AI.obj")
biplane.collisionMiddle=loadObject("AI.obj")
SetObjectImage(biplane.chassis,biplane.image,0)
biplane.propellor=LoadObject("propellor.obj")
SetObjectImage(biplane.propellor,biplane.image,0)
SetObjectLightMode(biplane.propellor,1)
FixObjectToObject(biplane.propellor,biplane.chassis)
SetObjectScale(biplane.collisionLeft,5,5,5)
SetObjectScale(biplane.collisionRight,5,5,5)
SetObjectScale(biplane.collisionMiddle,5,5,5)
SetObjectPosition(biplane.collisionLeft, GetObjectX(biplane.chassis)-250, GetObjectY(biplane.chassis)-520, GetObjectZ(biplane.chassis)+900)
SetObjectPosition(biplane.collisionRight, GetObjectX(biplane.chassis)+250, GetObjectY(biplane.chassis)-520, GetObjectZ(biplane.chassis)+900)
SetObjectPosition(biplane.collisionMiddle, GetObjectX(biplane.chassis), GetObjectY(biplane.chassis)-420, GetObjectZ(biplane.chassis)+900)
FixObjectToObject(biplane.collisionLeft,biplane.chassis)
FixObjectToObject(biplane.collisionRight,biplane.chassis)
FixObjectToObject(biplane.collisionMiddle,biplane.chassis)
SetObjectPosition(biplane.chassis,0,290,0)
FixObjectPivot(biplane.chassis)
Create3DPhysicsDynamicBody(biplane.chassis) // Set out hitbox to be a convex hull
SetObjectShapeConvexHull(biplane.chassis)
SetObject3DPhysicsCanSleep(biplane.chassis, 0)
SetObject3DPhysicsDamping( biplane.chassis , 0.2, 0.9 ) // Angular dampening. Works fantastic for steering
SetObject3DPhysicsMaxLinearVelocity(biplane.chassis, 52.5 * SCALE_3D )
SetObject3DPhysicsCanSleep(biplane.chassis, 0)
biplane.velocity.max = 52.5 * SCALE_3D
biplane.velocity.current = 0
biplane.accScale=1
//biplane.delay.amount = 0.300
//biplane.steering = STEERING_LOCAL
biplane.velocity.linearUnit = 1 * SCALE_3D
biplane.velocity.angularUnit = 0.125 * SCALE_3D
//biplaneDirection=1
//the below might even be the problem code
SetObject3DPhysicsLinearVelocity(biplane.chassis, 0, 0,10, biplane.velocity.current)
with the following function
function moveBiplsne(biplane ref as aircraft, env as environment)
t as point
v as float
turn as float
climb as float
a as float
l as point
dot as float
if checkCollision(biplane.collisionLeft,env.tracks[env.selectedTrack])=0
turn=0.125 * SCALE_3D
endif
if checkCollision(biplane.collisionRight,env.tracks[env.selectedTrack])=0
turn=-0.125 * SCALE_3D
endif
if checkCollision(biplane.collisionMiddle,env.tracks[env.selectedTrack])=1
climb=0.125 * SCALE_3D
else
climb=0
endif
v=0
v = biplane.velocity.linearUnit
v=v*biplane.accScale
if abs( biplane.velocity.current + v ) < biplane.velocity.max
inc biplane.velocity.current, v
else
biplane.velocity.current = biplane.velocity.max * (biplane.velocity.current / abs(biplane.velocity.current))
endif
l = CreatePoint(GetObject3DPhysicsLinearVelocityX(biplane.chassis), GetObject3DPhysicsLinearVelocityY(biplane.chassis), GetObject3DPhysicsLinearVelocityZ(biplane.chassis))
SetObject3DPhysicsLinearVelocity(biplane.chassis, l.x, l.y, l.z, biplane.velocity.current)
if turn <> 0 and abs(biplane.velocity.current) > 50 // Apply the turning force (Dampening is set in SetupVehicle()
//SetObject3DPhysicsAngularVelocity( biplane.chassis, 0, turn, 0, ((biplane.velocity.max - biplane.velocity.current) / 40) + (biplane.velocity.current * 1.2) / 25)
endif
endfunction
I was planning on have right and left collision detection blocks like I did with the cars and a middle one that if its in contact with the road thrust upward
its kinda a mess atm and needs allot of work. Altho my test code worked when I set the linear velocity in the above code I don't see the plane when I expect it to
fly forward might have to play with the camera