Sign in to follow this  

2D Platformers - Rotating Platforms / Player Position

This topic is 2636 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently working on a 2D platform game, much in the style of Super Mario.

I have a problem in implementing rotating platforms in my game, specifically when updating the position of my player when on a rotating platform.

I can get my character to stand on a rotating platform, and update his position so that he stays fixed on the platform as it rotates around a point of origin. However, when I try to move my player left or right on the platform, I encounter problems. Often, when moving in one direction, my player character will actually move backwards instead of forwards.

Every frame, I check to see if my player is standing on a rotating platform. If so, I fix his X Position to that of when he first made contact with the platform. This allows me to keep the player at the same position on the platform regardless of it's rotation around a point of origin.

In order to move my player, I update his velocity every frame.

I do not currently add the velocity of the platform itself to the player, as I have found that doing this does not work. When standing still, he will start moving around because of the platform's velocity, which is not what I want.

Does anyone have any suggestions on how I could rectify the problem?

Share this post


Link to post
Share on other sites
U have to calculate the position of your player in a hierarchical way. U can see the platform as the parent element of the player. Update your player's position in relative coordinates to the platform and not in global coordinates.

Share this post


Link to post
Share on other sites
^ That's actually what I do. When he first makes contact with the platform, I calculate his position relative to the platform and then alter the player's position by that value as the platform rotates. Thus, when standing still, he stays in the correct position relative to that platform as it rotates.

I want to keep my system of moving my player via a velocity model, as he needs to accelerate in a way that is consistent with his movement on the ground. However, it's the combination of fixing his position and applying velocity that does not seem to work.

Share this post


Link to post
Share on other sites
Quote:
Original post by thebach
Hey,

I'm sure this isn't the answer you'd like to hear.. but have you considered implementing a proper physics system? It'll make it a lot easier in the long run..

Check out box2d (http://www.box2d.org)

Cheers,
Bach


I've looked at Box2D, and although it's a great physics engine, it's hard to alter it in the ways I would like. You often have to hack things and find workarounds in order to add custom behaviour.

Share this post


Link to post
Share on other sites

This topic is 2636 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this