Right,after a bit of coding, I am back to this:
As in the last link with the code getting called upon pressing t to test the level,
function test_level()
addvirtualjoystick(1,150,800,100)
hide_stuff()
oldcam#=CameraDistance#
CameraDistance#=2
SetCameraRotation(1,0,0,0)
setobjectscale(player,0.7,0.7,0.7)
setobjectposition(cursorobject,-1000000,-1000000,-1000000)
for n=1 to maxobjects
if object[n].objID>0
//setobjectshapesphere(object[n].objID)
set_physics(object[n].objID,object[n].physicsbody,object[n].physicsshape)
SetObjectLightMode( object[n].objID,1)
//SetObject3DPhysicsRestitution(object[n].objID,1.0)
endif
next n
SetObject3DPhysicsCanSleep(player,0)
repeat
Step3DPhysicsWorld()
w#= GetRawMouseWheelDelta()
if w#<0
inc CameraDistance#
endif
if w#>0
dec CameraDistance#
endif
//camcontrol()
if getrawkeypressed(KEY_E)
quit=1
endif
sx2#=GetObject3DPhysicslinearVelocityX(player)
sy2#=GetObject3DPhysicslinearVelocityY(player)
sz2#=GetObject3DPhysicslinearVelocityZ(player)
//print (""+str(sz2#))
jy#=GetVirtualJoystickY(1)
jx#=GetVirtualJoystickx(1)
if jy#<0
mvz#=-0.01
endif
if jy#>0
mvz#=0.01
endif
if jx#<0
mvx#=0.01
endif
if jx#>0
mvx#=-0.01
endif
if jy#=0
remstart
if spd#<0 and spd#<>0
mvz#=-0.001
endif
if spd#>0 and spd#<>0
mvz#=0.001
endif
remend
endif
//mvx#=getrawkeystate(39)-getrawkeystate(37)
inc sx2#,mvx#*10
inc sz2#,mvz#*10
//if mb=1
// inc sy#,10.0
//endif
spd#=sqrt((sx2#*sx2#)+(sy2#*sy2#)+(sz2#*sz2#))
if spd#>100.0 then spd#=100.0
SetObject3DPhysicslinearVelocity(player,sx2#,sy2#,sz2#,spd#)
setcameraposition(1,getobjectx(player),getobjecty(player)+2,getobjectz(player)+CameraDistance#)
SetCameraLookAt(1,getobjectx(player),getobjecty(player),getobjectz(player),0)
sync()
Until quit=1
if jy#=0 and jx#=0
spd#=0
SetObject3DPhysicsLinearVelocity(player,sx2#,sy2#,0,spd#)
endif
CameraDistance#=oldcam#
quit=0
show_stuff()
clear_physics()
endfunction
I did have the part:
if jy#=0 and jx#=0
spd#=0
SetObject3DPhysicsLinearVelocity(player,sx2#,sy2#,0,spd#)
endif
In the main loop before the sync() but it makes nothing visible onscreen and actually crashes agk2
the problem I have is stopping the ball when needed, as in when you are not pressing joystick up/down/left/right!
On the plus side I got pretty darned good at writing level editors!
This last one just standing at 770 lines of code,considering my first attempt at a 3d editor ended up being 2008 lines without physics,coz it never existed....this is some leap!
Hail to the king, baby!