Hi Guys,
Imagine a helicopter 'type' of game. Now, i want to control the copter with the keys and i want it to respond to the physics i.e: bounce, sliding off surfaces, gravity etc.
I have the basic controls covered, see code:
sync on : sync rate 150
set display mode 1280,1024,32
autocam off
position camera 0,0,-200
phy start
phy make material 1, "slidy"
phy set material restitution 1, 0.2
phy set material dynamic friction 1, 0.1
phy set material static friction 1, 0.1
phy build material 1
make object cube 1,20
phy make rigid body dynamic box 1,1
phy set rigid body mass 1, 20000
phy set rigid body mass offset local 1, 0, -15, 0
make object box 2,200,5,200
position object 2,0,-50,0
phy make rigid body static box 2
make object box 3,200,5,200
position object 3,120,0,0
rotate object 3,0,0,45
phy make rigid body static box 3
make light 1
position light 1,-50,80,-150
set shadow shading on 1
x# =0.0
y# =0.0
do
key = 0
if upkey()
y# = y# + 0.05
phy add rigid body force 1,0.0,20.0,0.0,5
key = 1
endif
if rightkey()
phy add rigid body force 1,20.0,0.0,0.0,5
endif
if leftkey()
phy add rigid body force 1,-20.0,0.0,0.0,5
endif
if downkey()
phy add rigid body force 1,0.0,-20.0,0.0,5
endif
phy update
sync
loop
I am trying to keep the object upright in the air. Try the code, it works fine but it can spin out of control in the air, no good for a helicopter.
I have set it so its mass is positioned very low in the object which works great when you land as it always rights itself.
How do i keep it upright in the air. Any ideas.
Cheers