Moving Objects in Tokamak
Blitz3D Forums/Blitz3D Beginners Area/Moving Objects in Tokamak
| ||
Hi, i tried to programm a little game where you can move a cube like a car with the tokamak physic-engin. But if I turn the cube, he always slides the same way. So i cant steer the cube. Does anyone know how to do that better? |
| ||
Hard to help without code (and I haven't looked at any of the physics libs in a while) but are you turning the Tokamak object then matching the Blitz entity's orientation to it? |
| ||
Here is my code: Const Rigid_Bodies=1,Animated_Bodies=1 TOKSIM_CreateSimulator(0,-1,0) Graphics3D 640,480 ;Setup the scene ColBank=CreateBank(208) TOKSIM_SetCInfoBank ColBank l=CreateLight() cam=CreateCamera() PositionEntity cam,0,1,-10 Type TokData Field Name$ End Type t.tokdata=New tokdata t\name$="Ground" TOKSIM_SetCollisionResponse 2,1,3 TOKSIM_SetCollisionResponse 2,2,3 ground=TOKAB_Create() TOKAB_AddBox ground,100,10,100 TOKAB_SetPosition ground,0,-5,0 TOKAB_SetUserData ground,Handle(t.tokdata) groundr=CreateCube() ScaleEntity groundr,50,5,50 PositionEntity groundr,0,-5,0 TOKRB_SetCollisionID ground,1 t.tokdata=New tokdata t\name$="Box" obj2=TOKRB_Create() TOKRB_AddBox obj2,2,2,2 TOKRB_SetPosition obj2,2,8,0 TOKRB_SetUserData obj2,Handle(t) obj2r=CreateCube() TOKRB_SetCollisionID obj2,2 While Not KeyHit(1) If KeyDown(16) TOKRB_ApplyImpulse obj2,-.1,0,0 EndIf If KeyDown(17) TOKRB_ApplyImpulse obj2,.1,0,0 EndIf If KeyDown(31) TOKRB_ApplyTwist obj2,0,1,0 EndIf If KeyDown(30) TOKRB_ApplyTwist obj2,0,-1,0 EndIf TOKSIM_Advance .1,1 PositionEntity obj2r,TOKRB_GetX(obj2),TOKRB_GetY(obj2),TOKRB_GetZ(obj2) RotateEntity obj2r,TOKRB_GetPitch(obj2),TOKRB_GetYaw(obj2),TOKRB_GetRoll(obj2) RenderWorld Flip Wend TOKSIM_DestroySimulator |