Object 'Double Jump' Unwanted Effect

I have built a similar game to Doodle Jump in the way that it jumps through platforms and then upwards, these platforms move down the screen to give the effect fo the character progressing upwards.

It all works quite well, apart from one flaw. When the character jumps through the bottom of a platform he jumps twice as high as when he lands on a platform from above. I am using applyLinearImpulse on the object, so it seems as though this force is being applied to the force that the object already has - effectively hitting something that is already carrying momentum.

I know the way round this is to setLinearVelocity to 0 on both axis, which I have done, but it appears to have no effect.

I imagine this is one of those things which is very easy to fix, but I’m struggling. Any help is hugely appreciated. Code to follow.

 local function onPlatformCollision( event )   
 vx, vy = man:getLinearVelocity()  
 if vy \> 0 then  
 man:setLinearVelocity( 0, 0 )   
 man:applyLinearImpulse(0, -0.6, man.x, man.y)   
 end   
 end  

On a collision with a platform I check to see if the velocity is upwards (negative number) or downwards, applying the force if the object is moving down.

Another thing I have noticed, which I’m hoping is a quick fix. If any part of the object hits the platform then it will jump up, even if it’s just the top couple of pixels on his head. This is obviously a little weird from a gameplay point of view, I understand why it’s doing it, but any ideas how to fix it? Can I set some sort of explicit reference point at his feet just for the collision?

Thanks [import]uid: 61422 topic_id: 15502 reply_id: 315502[/import]

how can the force be applied to the force that the object already have ? the object is coming down right ? may be you are getting the effect of jumping double the height as you are applying impulse and at the same time moving the platform downwards. [import]uid: 71210 topic_id: 15502 reply_id: 57274[/import]