PolygonShape/PhysicsBodies

I got for few days so many trouble with spine and creating physicsBodies with Box2D, I follow this Topic on Spine and so many other: 

http://esotericsoftware.com/forum/viewtopic.php?f=7&t=1855&p=9125&hilit=+bounding+corona#p9125

I’ve succeeded to integrate my animation into spine and make the physics bodies from a polygon but everything goes through my character.

Here’s my code : 

local physics = require("physics") physics.start() physics.setGravity( 0, 9.8 ) physics.setDrawMode("hybrid") display.setDefault( "anchorX", 0.5 ) display.setDefault( "anchorY", 0.5 ) local spine = require "spine-corona.spine" local json = spine.SkeletonJson.new() local Data = json:readSkeletonDataFile("spine-animation/Kana/skeleton.json") local Player = spine.Skeleton.new(Data) function Player:createImage (attachment) return display.newImage("spine-animation/Kana/images/" .. attachment.name .. ".png") end local bounds = spine.SkeletonBounds.new() Player.group.x = 500; Player.group.y = 800; Player.flipX = false Player.flipY = false Player.debug = true -- Omit or set to false to not draw debug lines on top of the images. Player.debugAabb = true Player:setToSetupPose() --BOUNDING BOX------------------------------------------------------------------------------------------------------------------------ local Tete = Player:findBone("Tete") local TeteBox = Player:getAttachment ("TeteBox", "TeteBox").vertices local polygon = display.newPolygon(Player.group, 0, 0, TeteBox) physics.addBody(polygon, "kinematic",{density = 2, friction = 0.3, bounce = 0,shape=TeteBox}) --ANIMATION STATE local WalkAnim = Data:findAnimation( "Walk" ) --LOOP ANIMATION ENTERFRAME local lastTime = 0 local function GetAnim(event) local currentTime = event.time/1000 lastTime = currentTime --WalkAnim:apply(Player, lastTime, currentTime, true, 0, 0.8) polygon.x = -Player.x + Tete.worldX+4 polygon.y = -Player.y - Tete.worldY-9 polygon.rotation = -Tete.worldRotation +190 bounds:update(Player, true); Player:updateWorldTransform() end

Runtime:addEventListener("enterFrame", GetAnim)  

I use the enterFrame to make my shape following my bodies

It seems my anchor point are not in center of my polygon shape and not event on the screen, At the begining I could see the anchorsPoint on LeftToP of the screen but not anymore, so the physics can’t happen, that weird, I’ve checked everywhere to find an issue but no way … I tried to use group.anchorChildren = true but seems not working

I point out, my shape is convex. If someone have Idea ?

I remember having similar issues when I was trying these things out. Unfortunately I didn’t get very far with testing, but I think I reasoned that the problem was related to this: http://docs.coronalabs.com/guide/physics/limitations/index.html

Basically physicsbodies need to be in the same displaygroup or be translated in some way.

I hope that sheds some light on the issue. :slight_smile:

thanks reaver

I think I’m going to ungroup everything,  and put the whole character into tables, I’m going to check It  out :slight_smile:

I remember having similar issues when I was trying these things out. Unfortunately I didn’t get very far with testing, but I think I reasoned that the problem was related to this: http://docs.coronalabs.com/guide/physics/limitations/index.html

Basically physicsbodies need to be in the same displaygroup or be translated in some way.

I hope that sheds some light on the issue. :slight_smile:

thanks reaver

I think I’m going to ungroup everything,  and put the whole character into tables, I’m going to check It  out :slight_smile: