Hey guys... I haven't been on here for like, ever. I'm back though, maybe... lol.
I've been attempting to make 3rd person movement using Newton but it's just not working. Has anyone ever got this to work decently?
Code

Sorry if this has a small bug or two. I took the basics out of my main project to show, but being I'm not on Windows ATM, I have no way of testing.)
set display mode 1024,768,32
sync on : sync rate 60
autocam off
hide mouse
global px as float
global py as float
global pz as float
global pay as float
`Initialize Newton, and create the Newton World
NDB_NewtonCreate
`We need to set the World limits, this is very important to do otherwise there
`could be some unpredictable results
NDB_SetVector 1, -1000.0, -500.0, -1000.0
NDB_SetVector 2, 1000.0, 500.0, 1000.0
NDB_NewtonSetWorldSize
`Set the temp vector to our gravity constant (acceleration due to gravity)
`then set as our standard gravity force.
NDB_SetVector 0.0, -50.0, 0.0
NDB_SetStandardGravity
`make the ground for objects to fall on.
` GROUND OBJECT
` this makes a simple box with mass=0. this makes the object immobile, like a solid ground.
col = NDB_NewtonCreateBox( 1000.0, 10.0, 1000.0 )
FloorBody = NDB_NewtonCreateBody( col )
NDB_BuildMatrix 0.0, 0.0, 0.0, 0.0, -20.0, 0.0
NDB_NewtonBodySetMAtrix FloorBody
`now make a visual object to represent the floor onscreen... same size and position as
`the rigid body above.
FloorObj = FreeObject()
make object cube FloorObj,1
position object FloorObj, 0.0, -20.0, 0.0
scale object FloorObj, (1000.0*100.0), (10.0*100.0), (1000.0*100.0)
scale object texture FloorObj, 10.0, 10.0
texture object FloorObj, 1
`this tells the wrapper that if I destroy the Floor rigid body,
`I also want the wrapper to delete the visual object as well.
NDB_NewtonBodySetDestructorCallback FloorBody
`this command connects a visual object with a rigid body, making them a "pair"
NDB_BodySetDBProData FloorBody, FloorObj
`MAKE PLAYER
playerObject = FreeObject()
make object cube playerObject,60
playerNObject=MakeBox(playerObject,100,100,0,60,60,60,0,0,0,30)
Default = NDB_NewtonMaterialGetDefaultGroupID()
PlayerM = NDB_NewtonMaterialCreateGroupID()
NDB_NewtonMaterialSetDefaultFriction Default, PlayerM, 0.98, 0.90
NDB_NewtonMaterialSetDefaultElasticity Default, PlayerM, 0.01
NDB_NewtonBodySetMaterialGroupID playerNObject, PlayerM
NDB_SetVector 0,100,0
playerJoint = NDB_NewtonConstraintCreateUpVector(playerNObject)
NDB_NewtonBodySetAutoFreeze playerNObject,0
position object playerObject,100,100,0
` the first time you call this command, you may get a very large time#,
` so I call it twice at the start, to make sure we're getting a nice small time# value.
time# = NDB_GetElapsedTimeInSec()
time# = NDB_GetElapsedTimeInSec()
`So you can tell if you're moving
make object cube 1000,100
position object 1000,-20,50,200
` -----------------------------------
` MAIN LOOP
` -----------------------------------
do
mmx=mousemovex()
mmy=mousemovey()
if shiftkey()=1 then NDB_DebugDrawNewtonLines
`get the elapsed time since last frame and save into time# variable.
time# = NDB_GetElapsedTimeInSec()
` Here's the big command that updates the Physics system.
` Objects are moved and positioned automatically.
` the if GO=1 part is just a variable check so we can pause and unpause the system.
NDB_NewtonUpdate time#
if keystate(17)=1
NDB_SetVector 1, 0.0, 0.0, -.3
NDB_SetVector 2, 0.0, 0.0, 20.0
NDB_BodyAddForceLocal playerNObject
endif
if keystate(31)=1
NDB_SetVector 1, 0.0, 0.0, .3
NDB_SetVector 2, 0.0, 0.0, -20.0
NDB_BodyAddForceLocal playerNObject
endif
if keystate(30)=1
NDB_SetVector 1, -30.0, 0.0, 0.0
NDB_SetVector 2, -20.0, 0.0, 0.0
NDB_BodyAddForceLocal playerNObject
endif
if keystate(32)=1
NDB_SetVector 1, 30.0, 0.0, 0.0
NDB_SetVector 2, 20.0, 0.0, 0.0
NDB_BodyAddForceLocal playerNObject
endif
px=object position x(playerObject)
py=object position y(playerObject)
pz=object position z(playerObject)
pay=object angle y(playerObject)
position camera Object Position x (NDB_GetDBPro(playerNObject)),Object Position y (NDB_GetDBPro(playerNObject))+80,Object Position z (NDB_GetDBPro(playerNObject))
y(playerObject),object angle z (playerNObject)
rotate camera object angle x (NDB_GetDBPro(playerNObject)),object angle y (NDB_GetDBPro(playerNObject)),object angle z (NDB_GetDBPro(playerNObject))
move camera -150
sync
loop
` -----------------------------------
` -----------------------------------
` Destory the Newton world, clearing up any memory that was allocated.
NDB_NewtonDestroy
end
function MakeBox(obj,x#,y#,z#,sx#,sy#,sz#,rx#,ry#,rz#,mass#)
Col = NDB_NewtonCreateBox(sx#, sy#, sz#)
Body = NDB_NewtonCreateBody(Col)
NDB_BuildMatrix rx#, ry#, rz#, x#, y#, z#
NDB_NewtonBodySetMatrix Body
NDB_CalculateMIBoxSolid mass#, sx#, sy#, sz#
NDB_NewtonBodySetMassMatrix Body, mass#
NDB_NewtonReleaseCollision Col
position object obj, x#, y#, z#
rotate object obj, rx#, ry#, rz#
set object ambience obj, 50
NDB_BodySetDBProData Body, obj
NDB_NewtonBodySetDestructorCallback Body
NDB_BodySetGravity Body, 1
endfunction Body
function FreeObject()
repeat
inc i
if object exist(i)=0 then found=1
until found
endfunction i
function NeverCalled()
if memblock exist(1) then delete memblock 1
endfunction
The basic theory behind my control is to use an upjoint for the player object, apply forces to the sides/front/back to move it, and so far I haven't even got a half decent way of turning it.
My problem is that everything is working horridly. I can't get the player to move, either without it being to slippery, or not working half the time; even then, staffing causes my player to spin/turn when I don't want it to. Turning I could probably get, but if the movement isn't going to work it's not even worth the effort to me.
So, has anyone gotten 3rd person movement working decently with Newton? If so can I get an example or maybe get some help with my code?
Thanks a lot for reading!