Hi
I've set up a gun which fire bullets in Newton
The bullets have their own Newton Body and Material
Here the function i writed to check collision involving those missiles :
`Checking collision involving bullets
function BulletCheck(Obj)
` grab Newton body of the object
nObj=NDB_GetBody(Obj)
`check if there is collision with nMatBullet
Shot=NDB_GetCollisionBodytoMaterial(nObj,nMatBullet)
if Shot<>0
`checking if nMat is a life being or not
nMat=NDB_NewtonBodyGetMaterialGroupID(nObj)
if nMat=nMatNPC
`if it is a life being, check if its still alive and kill it
if NDB_BodyExist(nObj)=1 then NDB_NewtonDestroyBody nObj
`grab the Bullet ID and destroy it
nBullet=NDB_GetCollisionBody(Shot,nObj)
if NDB_BodyExist(nBullet)=1 then NDB_NewtonDestroyBody nBullet
else
`if not a life being, grab the bullet ID and destroy it
nBullet=NDB_GetCollisionBody(Shot,nObj)
if NDB_BodyExist(nBullet)=1 then NDB_NewtonDestroyBody nBullet
endif
endif
`reinitiallize collision data to 0
Shot=0
endfunction
this function is called each loop for every interactive DBPro object
As you can see, if the object touched by a bullet is in nMatNPC i want it to be destroyed
And if not, only the bullet is destroyed.
It works with npc, but often with other stuff too which are not in the nMatNPC Group...
any idea ?