Can a physics object collide with all objects in a group using local collisions?

Hey.

I have anout 40 objects which are all static and interact with a dynamic player character.

The static objects are all added to the same group.

I need a boolean to set to true whenever the player is in contact with,(event.phase=began will suffice) any of the objects in the group.

Is there a simple, (lazy) way to get the player character to listen for collisions with any object inside a group, or will I have to manually code 40 or so individual local collisions?

Thanks

Dan [import]uid: 67933 topic_id: 14365 reply_id: 314365[/import]

Don’t mix physics and groups it won’t work.

Basically you set a .myName tag to every object then add a collision event listener to your player, you can check what objects it collides with using the .myName tag. [import]uid: 68741 topic_id: 14365 reply_id: 53063[/import]

Hi Notts.

I’m aware it’s generally bad practice, but I really don’t want to have a collision function 40 x as long as this:

function onLocalCollision( self, event )  
 if ( event.phase == "began" ) then  
 ----------------------------------player hits ground---------------------------------------------------------------------------  
 if (self.myName == "player1" and event.other.myName == "object1") then  
 myBool = true  
 print(canpush)  
 end  
 end  
 end  

Is there any other way than individually coding? For instance, would it be a good idea to run a function every frame which checks for collisions on each object in a table?

Or as in my original post, whilst generally poor practice, could I theoretically check player1 for collisions with any object added to a group? Could each of my Objects have the same Obj:myName=whatever?

Not trying to be lazy, just looking for suggestions on a simpler, less coding heavy method to achieve this.

Thanks [import]uid: 67933 topic_id: 14365 reply_id: 53070[/import]

All 40 objects, do something like this;

[lua]obj.status = “canCollide”[/lua]

Then your collision function could just have;

[lua]if event.other.status = “canCollide” then[/lua]

Does that do what you’re after?

Peach :slight_smile: [import]uid: 52491 topic_id: 14365 reply_id: 53187[/import]