Impossible to insert joints in a display group

Hi,

The character of my game has four sensors around him that I attached with weld joints.
The problem is that I can insert all the bodies in the world group but it gives me an error when I try to insert the joints.
The result is that the joint are flying around and are not attached to the character.

If you know a workaround or a better way to attach sensors on a body (without using a group), your help is much appreciated.

Here the code I use to construct the character :

[lua]-- SPRITESET
local sheetData
local data
local heroSheet

if _DS < 1 then
sheetData = require “ss_hero@2x”
data = sheetData.getSpriteSheetData()
heroSheet = sprite.newSpriteSheetFromData( “ss_hero@2x.png”, data )
else
sheetData = require “ss_hero”
data = sheetData.getSpriteSheetData()
heroSheet = sprite.newSpriteSheetFromData( “ss_hero.png”, data )
end

local heroSet = sprite.newSpriteSet( heroSheet, 1, 123 )
sprite.add( heroSet, “idle”, 1, 18, 1500, 0 )
sprite.add( heroSet, “walk”, 20, 8, 500, 0 )
sprite.add( heroSet, “jump”, 78, 7, 300, 1 )
sprite.add( heroSet, “down”, 57, 18, 500, 0 )
sprite.add( heroSet, “land”, 53, 4, 70, 1 )
sprite.add( heroSet, “boost”, 28, 18, 1500, 1 )
sprite.add( heroSet, “useorb”, 86, 2, 100, 1 )
sprite.add( heroSet, “finishorb”, 103, 3, 300, 1 )
sprite.add( heroSet, “death”, 106, 18, 900, 1 )

– HERO CONSTRUCTOR
local hero = sprite.newSprite( heroSet )
hero:setReferencePoint( display.c )

if _DS < 1 then
hero.xScale = .5
hero.yScale = .5
end

local heroCFilter = { categoryBits = 1, maskBits = 222 }
physics.addBody( hero, “dynamic”, { density=.8, friction=.2, bounce=0, radius=24, } )
hero.isSleepingAllowed = false
hero.isBullet = true
hero.isFixedRotation = true

hero.speed = nil
hero.leftVelocity = nil
hero.rightVelocity = nil
hero.state = nil
hero.spawnPoint = {}
hero.moveState = nil
hero.orientation = nil


– SENSORS

local sensorCFilter = { categoryBits = 32, maskBits = 66 }

– FOOT
local footSensor = display.newRect(-15, 18, 30, 10)
physics.addBody( footSensor, “dynamic”, { friction = 0, filter = sensorCFilter } )
footSensor.isSensor = true
footSensor.isVisible = false

local footJoint = physics.newJoint( “weld”, footSensor, hero, 0, 15 )

– LEFT
local leftSensor = display.newRect(-28, -5, 10, 10)
physics.addBody( leftSensor, “dynamic”, { friction = 0, filter = sensorCFilter } )
leftSensor.isSensor = true
leftSensor.isVisible = false

local leftJoint = physics.newJoint( “weld”, leftSensor, hero, -25, -5 )

– RIGHT
local rightSensor = display.newRect(19, -5, 10, 10)
physics.addBody( rightSensor, “dynamic”, { friction = 0, filter = sensorCFilter } )
rightSensor.isSensor = true
rightSensor.isVisible = false

local rightJoint = physics.newJoint( “weld”, rightSensor, hero, 15, -5 )

– HEAD
local headSensor = display.newRect(-15, -29, 30, 10)
physics.addBody( headSensor, “dynamic”, { friction = 0, filter = sensorCFilter } )
headSensor.isSensor = true
headSensor.isVisible = false

local headJoint = physics.newJoint( “weld”, headSensor, hero, 0, 15 )[/lua] [import]uid: 25327 topic_id: 14587 reply_id: 314587[/import]