groupIndex not working?

I’m trying to create a surface in 2D, with several hitboxes, and want to you use groupIndex as collision filter. No matter what values I insert, the ball will always bounce on all the hitboxes.

–The Ball
local f = { groupIndex = -2 }
physics.addBody( ball, ‘dynamic’, {bounce=0.8, filter=f} )

–Surface

local z_index = 1

local surfaceHeight = tableSurfacePrct * tableObject.height
local hitBoxSize = surfaceHeight /contestants.z_indexes_table
local start_y = -tableObject.height/2 + hitBoxSize/2

local hitBoxes = {}

for i=1, contestants.z_indexes_table do
local temp = {friction=table_friction, filter={groupIndex = z_index}, box={halfWidth=tableObject.width/2, halfHeight=hitBoxSize/2, x=0, y=start_y}}
start_y = start_y + hitBoxSize
z_cat = z_cat + 1

table.insert(hitBoxes, temp)

end

physics.addBody(tableObject, ‘static’, unpack(hitBoxes))

You need to setup the collision filters in a different way. Read: https://docs.coronalabs.com/plugin/collisionFilters/index.html

I think there’s a Solar2D plugin for how to manage the collision filters another way. I also have one such plugin that I need to upload (but been too busy to do so far).

1 Like