Collision Boxes sinking into each other

Hi there,

I have a character and a box, i can move my character against the box and it pushes it.
I am trying to add an animation to it.

local function pushing(e)  
 box01.Col = "box"  
  
 if(e.other.Col == "box" and e.phase == "began" and RobotPlayer.y \> e.other.y and RobotPlayer.x \< e.other.x) then  
 ...--play animation  
 end  
end  
  
Player:addEvenetListener("collision" pushing);  
-- This basically checks it's colliding with a "box" and whether the characters on the left side pushing right.  

My problem is the initial time collides the animation works.
But if i stop moving and start pushing right again it doesn’t.

The reason is because when the character pushing against the box their collision boxes sink together a bit, then when i stop moving the character gets pushed out, but not all the way, so he never reached a e.phase = “ended”.
(if i walk left to cause “ended” phase and then right it works again.)

Is there a way to stop this sinking effect or to push the character out more?
I’ve tried fiddling with density.

I’ve also tried changing the e.phase = “moved” but then it just stops working.

So i’m trying to either trigger the ended phase on their collision or recheck if they’re colliding without began phase and continue animation.

Thanks!

[import]uid: 91798 topic_id: 19760 reply_id: 319760[/import]

A sample to run would be useful here.

It may be worth checking out this post; http://blog.anscamobile.com/2011/08/solutions-to-common-physics-challenges/

You could also consider pushing the character back ever so slightly on collision, maybe?

Peach :slight_smile: [import]uid: 52491 topic_id: 19760 reply_id: 76563[/import]

thehivetyrant,

Have you solved this yet? I’m not sure if you’re having the same problem I had but try setting the frame rate to 60fps and see if it goes away, this worked for me:

application = { content = { fps = 60, }, } [import]uid: 56623 topic_id: 19760 reply_id: 83053[/import]