need help, jumping onto a moving platform

hi,

In my game the main character jumps onto a platform that moves sideways across the screen.

What happens is, once he lands onto the moving platform, the platform moves and he doesn’t move with it and falls.

What i’m trying to achieve is, once he lands on the platform, he should stay on it while it moves until he jumps to another platform.

any help would be appreciated

Rayyan

thnx [import]uid: 10542 topic_id: 6683 reply_id: 306683[/import]

I have the exact same question.

What would be the easiest solution to this?

I’m guessing there is a simple way to do this instead of making collision event and then trying to force the game character keep up with the x-position of the platform.

edit:
I’m now trying to call a function in postCollision to make a pivot joint between the character and the moving platform. This ends up crashing the game.

I have tried to do this with performWithDelay and the result is same. [import]uid: 10416 topic_id: 6683 reply_id: 47030[/import]

Do you use Physics for movement?

If not, then you have to use the old school method of games, if the player has landed on the platform, set a flag and when you move the platform, move the player with the platform.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 6683 reply_id: 47047[/import]

Yep, I do use physics for movement (ie. use applyForce to jump etc)

I just cannot get the joint created automatically between the player character and a platform.

If I try to make the pivot joint outside a function, it works. If I just place the function around it and call it from another (enterFrame) function it crashes:

local function anchor()  
 pivot = physics.newJoint(  
 "pivot",  
 gamecharacter, platform,  
 platform.x, platform.y  
 )  
end  

I have tried changing the function and the pivot from local to global but it doesn’t change anything.
EDIT: Solved
I changed the joint stuff to this. (found from http://developer.anscamobile.com/forum/2011/06/10/cannot-translate-object-collision-resolved )

local function anchor(platform) transition.to(gamecharacter, {x = platform.x, time=0}) end [import]uid: 10416 topic_id: 6683 reply_id: 47057[/import]