Alright, got a small demo here.
It's not flashy, I didn't care to make it look fancy. Two green boxes, a blue car, and a character controller with mouselook.
Controls while in vehicle:
w - accelerate
s - reverse
a - turn left
d - turn right
space - brake
left mouse button + right mouse button - get out of vehicle
Controls while on foot:
w - move forward
s - move backward
a - move left
d - move right
space - jump
control - crouch
left mouse button only - get in vehicle
You can push anything you want when on foot and when in the vehicle. The characters strength is only 150 or so, so if you try to push all three objects at once you won't get very far. Pushing one or two for a short amount of time will generally work I think, hah. Pushing only one will let you push it pretty much as far as you want. I think that's all.
Also, if it asks for you to allow for the program to have internet access, it is only for the visual debugger. That isn't entirely integrated. I didn't remove that from the code yet. Sorry.
Btw, if you want to see the code to this demo:
sync on
sync rate 60
xeno start
rem Create Ground
make object box 1, 300, 1, 300
xeno make rigid body static box 1
make object box 2, 4, 1, 2
color object 2, rgb(0, 40, 128)
xeno make rigid body dynamic box 2
xeno set rigid body position 2, 0, 2, 5
xeno make vehicle 2, 2
xeno make camera 2, 2
make object cube 3, 1
color object 3, rgb(0, 128, 0)
xeno make rigid body dynamic box 3
xeno set rigid body position 3, 5, 4, 0
make object cube 4, 1
color object 4, rgb(0, 128, 0)
xeno make rigid body dynamic box 4
xeno set rigid body position 4, 10, 2, 0
xeno make character controller 1, 1, 1, 0.5, 10, 2, 150
xeno set character controller position 1, 0, 4, 0
xeno disable character controller 1
cameraX as float
cameraY as float
cameraZ as float
yAngle as float
xAngle as float
lookSpeed as float = 0.2
inVehicle as integer = 1
hide mouse
do
position mouse screen height() / 2, screen width() / 2
xeno update
if inVehicle = 0 and mouseclick() = 1
inVehicle = 1
xeno disable character controller 1
endif
if inVehicle = 1 and mouseclick() = 3
inVehicle = 0
xeno enable character controller 1
x# = object position x(2)
y# = object position y(2) + 2
z# = object position z(2)
yAngle = 0
xAngle = 0
xeno set character controller position 1, x#, y#, z#
endif
if (inVehicle = 1)
if keystate(17)
xeno vehicle accelerate 2, -1
endif
if keystate(31)
xeno vehicle accelerate 2, 1
endif
if keystate(30)
xeno vehicle turn 2, 2
endif
if keystate(32)
xeno vehicle turn 2, -2
endif
if spacekey()
xeno vehicle hand brake 2
endif
cameraX = xeno get camera position x(2)
cameraY = xeno get camera position y(2)
cameraZ = xeno get camera position z(2)
px# = xeno get camera point x(2)
py# = xeno get camera point y(2)
pz# = xeno get camera point z(2)
point camera px#, py#, pz#
else
if keystate(17)
xeno move character controller forward 1
endif
if keystate(31)
xeno move character controller backward 1
endif
if keystate(30)
xeno move character controller left 1
endif
if keystate(32)
xeno move character controller right 1
endif
if spacekey()
xeno character controller jump 1
endif
if controlkey()
xeno character controller crouch 1
endif
cameraX = xeno get character controller position x(1)
cameraY = xeno get character controller head position(1)
cameraZ = xeno get character controller position z(1)
yAngle = wrapvalue(yAngle + mousemovex() * lookSpeed)
xAngle = wrapvalue(xAngle + mousemovey() * lookSpeed)
xeno set character controller rotation 1, yAngle
rotate camera xAngle, yAngle, 0
endif
position camera cameraX, cameraY, cameraZ
sync
loop
Next I'm going to implement more presets and change this preset to an actual preset instead of the only vehicle...
XenoPhysics - A Havok Wrapper for DarkBasic Pro. In progress.