Hi Brent,
I post the whole precollision and collision code :
Platform Height = 70px
local function PlayerPreCo(self,event) local Type = event.other.Type local KangaPhysicsY = self.y+1 local PlatY = event.other.y-35 -- LET PLAYER GO THROUGH if Type == "Bar" then if KangaPhysicsY \> PlatY+30 then event.contact.isEnabled = false ; self.isSensor = true ; self.setAsSensor = true; print("PRECO") end end end local function PlayerCollision(self,event) local class = event.other.class local Type = event.other.Type -- COLLISION PLATFORM -------------------------------------- -- PLATFORM HAVE ONE TYPE ("Bar") AND ONE CLASS ("Sol") ------------------------------- if Type == "Bar" then if ( event.phase == "began" ) then local KangaPhysicsY = self.y+1 local PlatY = event.other.y-35 if KangaPhysicsY \> PlatY+30 then event.contact.isEnabled = false ; self.isSensor = true ; self.setAsSensor = true; print("Boogie") end elseif (event.phase == "ended") then self.isSensor = false ; self.setAsSensor = false; end end if class == "Sol" then if ( event.phase == "began" ) then local KangaPhysicsY = KangaPhysics.y local BarY = event.other.y if Idle == false and ( KangaPhysicsY \< BarY - 7 ) and KangaPhysics.States \> 0 then audio.play(LandSnd) stateK:setAnimationByName(0, "WalkGround", true,0) timer.performWithDelay(30, StateManager) timer.performWithDelay(27, StateManagerII) elseif Idle == true then physics.pause()end elseif (event.phase == "ended") then end -- OTHER STUFF COLLISION ----------------------------------------------------- elseif class == "Trampo" then if ( event.phase == "began" ) then KangaPhysics:setLinearVelocity (0,-3000) audio.play(JumpSnd) stateK:setAnimationByName(0, "JumpDown", false,0) timer.performWithDelay(0, StateManagerII) elseif (event.phase == "ended") then end KangaPhysics.States = KangaPhysics.States + 1 elseif class == "Bois" then if ( event.phase == "began" ) then local KangaPhysicsY = KangaPhysics.y local BarY = event.other.y if ( KangaPhysicsY \< BarY+25 )and KangaPhysics.States \> 0 then KangaPhysics:setLinearVelocity (0,-1000) audio.play(LandSnd) stateK:setAnimationByName(0, "WalkGround", true,0) end elseif (event.phase == "ended") then end elseif class == "Next" and Next == false then if ( event.phase == "began" ) then Choice = Choice + 1 if Choice \> 4 then Choice = 1 end elseif (event.phase == "ended") then end timer.performWithDelay(100,Step) Next = true print("Next") end end
So that’s all what I use to make my player go through the platform but with this code my player hits sometimes the top left side while the function is called, at least the print(“PRECO”) which one I can see in the output, but the rest of the function is not called. Weird …
All my platform are display with a loop, I can publish it if you need
I post here just my physicsShape :
local rad = (Sol.width\*0.5)+10; local height = (Sol.height\*0.5)- 30 local physicsShape = { -rad, -height, rad, -height, rad, Sol.height\*0.5, -rad, Sol.height\*0.5 } physics.addBody(Sol,"kinematic", {friction = 0, density=1, bounce = 0, shape=physicsShape})
and here the screenshot :
all my platform have differents width but the same height (70)
What Do you think ?
Thanks in advance