Hi all,
I'm having a little problem with detecting collision bewtween 2 materials and maybe you can help me?
I'm trying to build a kind of force field behavior that will let the player pass as long as he doesn't trigger some event. Once he triggers the event the force fields will be 'activated' not allowing the player to pass anymore. What I don't want is to create 2 different objects for the force field 'state' since I might want to use some more complex objects in the end. (Imagine a whole level where you can 'walk' through walls being a kind of ghost...)
Here's the code with comments:
NDB_NewtonMaterialSetCollisionCallback PlayerID,GrenadeID
Wall = NDB_NewtonMaterialCreateGroupID()
Andere = NDB_NewtonMaterialCreateGroupID()
Ball = NDB_NewtonMaterialCreateGroupID()
`setting up the force fields and assign material
TopWall = MakeBox( 20, -12, 18, 100.0, 4.0, -10, 0.0, 0.0, 0.0, 0.0 )
NDB_NewtonBodySetMaterialGroupID TopWall, Wall
BotWall = MakeBox( 20, -12, 0, 100.0, 4.0, -10, 0.0, 0.0, 0.0, 0.0 )
NDB_NewtonBodySetMaterialGroupID BotWall, Wall
`here comes the player dummy for testing
Player = MakeSphere(30,5,-100,3,15)
NDB_NewtonBodySetMaterialGroupID Player, Ball
`Player will not collide with force fields since he hasn't 'triggered' collision yet
NDB_NewtonMaterialSetDefaultCollidable Ball, Wall, 0
NDB_NewtonMaterialSetCollisionCallback Ball,Wall
[...]
`checking if Player collided with trigger object to activate collision with force field
hit = NDB_GetCollisionBodyToMaterial(Player, Andere )
if hit <> 0
wait key
NDB_NewtonMaterialSetDefaultCollidable Ball, Wall, 1
NDB_NewtonMaterialSetCollisionCallback Ball,Wall
endif
[...]
`this will set up the `trigger`objects that will activate player collision with force field
tunekugel:
for sphere=2 to 10
TempBall = MakeSphere(5*sphere,5,10,3,5)
NDB_NewtonBodySetMaterialGroupID TempBall, Andere
next sphere
return
Many thanks for your help in advance!
Cel.