Problem with player horizontally riding platforms

oscarkim

  • Posts: 28
I can't get the player in a game am working on to move with the same speed the platform it's on is moving. Currently the platform slides beneath the player. I am using accelerometer for movement - ( I'm not sure if this is the cause :) ) . I have attached the block of code I am using).

dtrungle

  • Posts: 1938
The quickest way is to change the x/y of the player while the platform moves, so that they can be in sync. Otherwise you'll have to trial and error with the speed, friction, or anything else that applies - to get it just right.

oscarkim

  • Posts: 28
Could you explain how to do that

dtrungle

  • Posts: 1938
It's difficult to explain because I don't know how you have it set up and how you want it to be.

In the code where the platform moves, if the actor is colliding with it, and if the platform has moved, set the actor's x to the same value that was moved. This is one approach but again you'll need to trial/error it till you get it looking good or acting the way you want it.

Same idea with velocity, if the platform gets speed, the actor gets speed as well. Of course this will be more harder to control if the actor and platform has their own movement behavior.