Monday, April 11, 2016

2d - Box2D Platform body not moving player body along with it


I am creating a game using Box2D (Javascript implementation) - and I added the ability to have a static platform, that is moved along an axis as a function of a sine.


My problem is when the player lands on the platform, as the platform moves along the X axis - the player is not moved along with it, as you visually would expect.



The player can land on the object, and if it hits the side of the object, it does colide with it and is pushed.


This image might explain better than I did:
After jumping on to the red platform the player character will fall off as the platform moves to the right


example


UPDATE:
Here is a live demo showing the problem:
http://onedayitwillmake.com/ChuClone/slideexample.php



Answer




I move the platform by calling SetPosition on the body




I think this is the problem. Box2D is not designed to be used this way. Is there any way you can simulate sine function movement by applying impulses/forces?


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...