Jump to content

P2 moving platform


Recommended Posts


I've been trying to make a moving platform where the player (and other sprites) can ride upon. I tried using something similar to this example (http://jsfiddle.net/pandavigoureux29/zphsz7kp/) to no avail.

I've also tried using a contact material and messed with the various friction properties to no avail. I've seen a gravity based solution that ramps up gravity 100x, but I can't use that because of how my game works.

Thanks in advance for your help!

Link to comment
Share on other sites

Hey there,

I think the example you linked makes it pretty easy.  Basically, you have a velocity vector (in the form of a point) that represents the velocity applied on your player by moving platforms.  When the player is not contacting a moving platform (default state) this vector is [0, 0].   When you detect a collision between the moving platform and the player, you change this vector to the velocity vector of the moving platform.  So, if the platform has an X velocity of -5, your "platform velocity vector" would be the same.  When you detect this collision has ended, you put your "platform velocity vector" back to it's default state ([0, 0]). 

Then, when the user has pressed no keys, you set their velocity vector to the "platform velocity vector".  This way the platform moving does not interfere with your normal platform controls, but the player can "ride" the platform.  If you want the platform to function more like a conveyor belt (impeding the player's movement), you'd do some simple math to combine the "platform velocity vector" with your player's current velocity vector.

Hope this helps!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...