Collision bug?

Why ragdoll from the examples, colliding into physical objects are not where they are located the actual location?

Initially, everything worked well as it should. But after I added the button Back to another group, all broke through the entire code can `t find the cause.

Sorry for bad English. :wacko:

21d02def94ea.jpg

I think must be good, if i past my code:

-- Physics ------------------------------------------------------------------------------- local physics = require('physics') physics.start() --physics.setGravity(0, 0) physics.setDrawMode('hybrid') local ragdoll = require "ragdoll" -- We need this to make the object draggable. local draggameUI = require("gameUI") -- Graphics ------------------------------------------------------------------------------- -- [Title View] local title -- Заголовок local playBtn local creditsBtn local titleView -- Группа главного меню -- [Game UI] local backBtn -- Кнопка бэк local gameUI -- группа интерфейса -- [Game Play] local sky -- небо local box -- ящик local ground -- земля local player local game -- группа геймплея -- [Credits] local creditsView -- Variables ------------------------------------------------------------------------------- local lastY -- Functions ------------------------------------------------------------------------------- local Main = {} local startButtonListeners = {} local showCredits = {} local hideCredits = {} local showGameView = {} -- Main Function ---------------------------------------------------------------------------- --Функция главного меню function Main() --Если имееться кнопка бэк, то удалить прослушиватели и саму кнопку if(game) then transition.to(game, {alpha=0.0, time = 300, --[[x = -game.height,]] onComplete = function() gameListeners(remove) display.remove(game) display.remove(gameUI) game = nil gameUI = nil end}) --if game.isBodyActive ~= true then --physics.removeBody(game) --end end title = display.newImage('title.png', 64, 130) playBtn = display.newImage('playBtn.png', 134, 245) creditsBtn = display.newImage('creditsBtn.png', 114, 305) titleView = display.newGroup( title, playBtn, creditsBtn) startButtonListeners('add') end --Функция прослушивает нажатие на картинки и запускает соотвествующие функции function startButtonListeners(action) if(action == 'add') then playBtn:addEventListener('tap', showGameView) creditsBtn:addEventListener('tap', showCredits) else playBtn:removeEventListener('tap', showGameView) creditsBtn:removeEventListener('tap', showCredits) end end --Функция открывает кредиты function showCredits:tap(e) playBtn.isVisible = false creditsBtn.isVisible = false creditsView = display.newImage('credits.png', 0, display.contentHeight) lastY = title.y transition.to(title, {alpha=1,time = 900, y = 50}) transition.to(creditsView, {alpha=0.5, time = 300, y = 265, onComplete = function() creditsView:addEventListener('tap', hideCredits) end}) end --Функция прячет кредиты function hideCredits:tap(e) --Спрятать кредиты за экран, выключить прослушиватели, и удалить кредиты transition.to(creditsView, {alpha=0.0, time = 300, y = display.contentHeight + 25, onComplete = function() creditsBtn.isVisible = true playBtn.isVisible = true creditsView:removeEventListener('tap', hideCredits) display.remove(creditsView) creditsView = nil end}) --Вертнуть заголовок на старое место transition.to(title, {alpha=0.5,time = 900, y = lastY}); end --Функция показывает игру function showGameView:tap(e) --Спрятать и затем удалить главное меню transition.to(titleView, {time = 300, x = -titleView.height, onComplete = function() startButtonListeners('rmv') display.remove(titleView) titleView = nil end}) --ГЕЙМПЛЭЙ-------------------------------------------------------------------------------------------------------------- --Небо sky = display.newImage('clouds.png') --Земля ground = display.newImage('ground.png') ground.y = 500 physics.addBody(ground, 'static',{friction = 0.1}) --Ящик box = display.newImage('crate.png') box.x,box.y = 200,100 box.rotation = 20 physics.addBody(box, {bounce = 0.5}) player = ragdoll.newRagDoll(50, 100, {0, 33, 255, 128}) --Обьеденить всё в одну группу game = display.newGroup(sky, ground, box, player) --ИНТЕРФЕЙС----------------------------------------------------------------------------------- --Вывести кнопку бэк backBtn = display.newImage('back.png', 5, -display.contentHeight) backBtn.y = -10 --Обьеденить интерфейс в одну группу gameUI = display.newGroup( backBtn) --gameUI:insert(5, backBtn ) -- Вывести кнопку сверху всех обьектов по пороядку --Включить прослушиватели gameListeners('add') end function gameListeners(action) if(action == 'add') then --Прослушка геймплея --Runtime:addEventListener('enterFrame', moveCamera) box:addEventListener( "touch", draggameUI.dragBody ) -- Make the object draggable. --Прослушиватели кнопок backBtn:addEventListener('tap', Main) else --Прослушка геймплея --Runtime:removeEventListener('enterFrame', moveCamera) box:removeEventListener( "touch", draggameUI.dragBody ) --Прослушка кнопок backBtn:removeEventListener('tap', Main) end end

Hello,

If your physics objects are in different (display) groups, do you move one of these groups from it’s normal 0,0 coordinate space? This is not allowed for physics… all groups containing physics objects must remain in the same coordinate space for collisions to function properly.

Hope this helps,

Brent

The problem was the fact that if the group does not add the first Ragdoll, then the collision of other objects are located not in the right place.
If I add ragdoll to the top of the group, that’s all right then.

game = display.newGroup(player,box,sky,ground)

I can also add ragdoll separately, using the command insert, and then all will be well.

game:insert(1, player)

Hello,

If your physics objects are in different (display) groups, do you move one of these groups from it’s normal 0,0 coordinate space? This is not allowed for physics… all groups containing physics objects must remain in the same coordinate space for collisions to function properly.

Hope this helps,

Brent

The problem was the fact that if the group does not add the first Ragdoll, then the collision of other objects are located not in the right place.
If I add ragdoll to the top of the group, that’s all right then.

game = display.newGroup(player,box,sky,ground)

I can also add ragdoll separately, using the command insert, and then all will be well.

game:insert(1, player)