I have been using this command as suggested,putting it in before the sync(), but I noted jerkiness in the physics, out of curiosity I ended up putting the command after the sync(), and the jerkiness dissappeared! So it has left me puzzled as to why this is, here is the function I am using to test a saved level from my editor:
Function Test_level()
CreatePointLight( 1, 0, 200, 0, 1000, 255, 255, 255 )
SetAmbientColor( 160, 160, 160 )
//Set camera
for n=1 to 5000
if Tobject[n].objID>0
//if Tobject[n].group<>1
set_physics(n,Tobject[n].phybody,Tobject[n].physhape)
//endif
//SetObject3DPhysicsFriction(n,100)
//SetObject3DPhysicsRestitution(n,0.7)
if Tobject[n].group=1
playerobject=Tobject[n].objID
Setobject3dphysicsmass(playerobject,10)
SetObject3DPhysicsCanSleep(playerobject,0)
//create_character_controller(playerobject)
endif
endif
next n
Repeat
CamSpeed# = 6
//Move3DPhysicsCharacterController( PlayerObject, Direction_Stop, CamSpeed# )
//SetObject3DPhysicslinearVelocity( playerobject, 0, 0, 0, 0 )
posx#=getobjectx(playerobject)
posy#=getobjecty(playerobject)
posz#=getobjectz(playerobject)
if GetPointerPressed()
//To move dynamic physics bodies we need to apply velocity to the physics body.
//ThrowBall( 800.0, 2.0 )
//Jump3DPhysicsCharacterController( playerobject )
SetObject3DPhysicslinearVelocity( playerobject, 0, 1, 0,10)
endif
if getrawkeypressed(KEY_Z)
movleft=1
endif
if getrawkeyreleased(KEY_Z)
movleft=0
endif
if movleft>0
//Move3DPhysicsCharacterController( PlayerObject, Direction_Left, CamSpeed# )
SetObject3DPhysicslinearVelocity( playerobject, -1, 0, 0, 5 )
endif
if getrawkeypressed(KEY_X)
movright=1
endif
if GetRawKeyReleased(KEY_X)
movright=0
endif
if movright>0
//Move3DPhysicsCharacterController( PlayerObject, Direction_Right, CamSpeed# )
SetObject3DPhysicslinearVelocity( playerobject, 1, 0, 0, 5 )
endif
if getrawkeypressed(KEY_E)
quit=1
endif
//caster(posx#,posy#,posz#)
if obj>0 and obj<>playerobject
if Tobject[obj12].group=3
//Jump3DPhysicsCharacterController( playerobject )
endif
endif
setcameraposition(1,getobjectx(playerobject),getobjecty(playerobject)+13,getobjectz(playerobject)+CameraDistance#/2)
setcameralookat(1,getobjectx(playerobject),getobjecty(playerobject),getobjectz(playerobject),0)
sync()
Step3DPhysicsWorld()
until quit=1
quit=0
clear_physics()
reset_object_positions()
endfunction
as you can see I have indeed put the command last in the loop, as soon as I move it before sync() the jerkiness starts!
Hail to the king, baby!