I've created an extremely basic little program that is meant to move a simple stickman model forward until he collides with a hut 500 units away. there's just a basic box around the hut, so the open door should still repel him. Problem is, he won't move!
The strangest thing is that I compiled this once and it worked just fine. The second time, and every time since then, it's failed to move.
I'll attach a zip file with the media I'm using plus the code. Here's the snippet as well for whoever's interested.
set display mode 800,600,32
sync off
hide mouse
` starts Newton
_setupnewton:
NDB_NewtonCreate
NDB_SetVector 1, 1.0, 1.0, 1.0
_stickman:
StickmanCol = NDB_NewtonCreateBox(30,30,30)
` creates rigid body
StickmanBody = NDB_NewtonCreateBody(StickmanCol)
` sets orientation of rigid body
NDB_BuildMatrix 0,0,0,0,0,0
NDB_NewtonBodySetMatrix StickmanBody
` calculates mass of solid
NDB_CalculateMIBoxSolid 30, 30, 30, 30
NDB_NewtonBodySetMassMatrix StickmanBody, 30,1,1,1
` RELEASE
NDB_NewtonReleaseCollision StickmanCol
load object "media\player\stickman.x",2
position object 2,0,0,0
scale object 2,25,25,25
rotate object 2,0,180,0
fix object pivot 2
` This finally puts the rigid body and actual object together
NDB_BodySetDBProData StickmanBody, 2
` destroys both rigid object & 3d object whenever it gets called in the future
NDB_NewtonBodySetDestructorCallback StickmanBody
` applies gravity to the object (commented out for now)
`NDB_BodySetGravity StickmanBody, 1
_setuphouse:
HutCol = NDB_NewtonCreateBox(50,50,50)
` creates rigid body
HutBody = NDB_NewtonCreateBody(HutCol)
` sets orientation of rigid body
NDB_BuildMatrix 0,0,0,0,0,500
NDB_NewtonBodySetMatrix HutBody
` calculates mass of solid
NDB_CalculateMIBoxSolid 0, 75, 75, 75
NDB_NewtonBodySetMassMatrix HutBody, 0
` RELEASE
NDB_NewtonReleaseCollision HutCol
load object "media\player\hut1.x",3
position object 3,0,0,500
` This finally puts the rigid body and actual object together
NDB_BodySetDBProData HutBody, 3
` destroys both rigid object & 3d object whenever it gets called in the future
NDB_NewtonBodySetDestructorCallback HutBody
` applies gravity to the object (commented out for now)
`NDB_BodySetGravity HutBody, 3
time# = NDB_GetElapsedTimeInSec()
time# = NDB_GetElapsedTimeInSec()
do
`gets the amount of time elapsed since the last call to this function, in seconds.
time# = NDB_GetElapsedTimeInSec()
`then the big command that updates the physics world.
NDB_NewtonUpdate time#
x#=object position x(2)
y#=object position y(2)
z#=object position z(2)
set camera to follow x#,y#,z#,object angle y(2),5,18,35,1
if upkey()=1
NDB_SetVector 1, x#, y#, z#
NDB_SetVector 2, 0.0, 0.0, 20.0
NDB_BodyAddForceLocal StickmanBody
endif
if downkey()=1
NDB_SetVector 1, x#, y#, z#
NDB_SetVector 2, 0.0, 0.0, -20.0
NDB_BodyAddForceLocal StickmanBody
endif
sync
loop
Thanks so much!!
Weedfox