swissnetizen Posted April 16, 2016 Share Posted April 16, 2016 Hi! 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 More sharing options...
Cudabear Posted April 20, 2016 Share Posted April 20, 2016 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 More sharing options...
Recommended Posts