Hey all,
I've been working on the beginnings of a platform game in XNA using Box2D, and I can't work out what's happening here. I'll give a summary of my setup, and also let you see this video. The video's been cropped down from a 1280x720 game area.
The video is a SWF because I used Flash to quickly crop it - exporting as a video would make it worse quality again, so:
http://www.swfcabin.com/open/1277231066
For moving platforms/objects, I'm making them static bodies and moving at linear unchanging speeds with body.SetTransform. I do this because I searched around for ages on the best way to have moving platforms (which will probably only ever interact with the player, but it'd be nice to be able to have falling boxes etc. in future).
All of my moving platforms work off a Vehicle system - all platforms decide when mobile actors become 'passengers' on them. Then, they update all passengers accordingly - these moving platforms just move their passenger along at the same speed as them. How I'm doing that isn't the issue at the moment.
To move the player character I use body.ApplyForce. This same issue occurs when I use ApplyImpulse too. I don't think I can use SetLinearVelocity, it just wasn't as useful or as natural in several ways.
My issue occurs when two of these moving platforms are 'stacked up' vertically. Note that they're not interacting with each other, and one isn't resting on the other, they just happen to be close to each other. I've checked, and they're always at the same horizontal position.
When the player character jumps up as the platforms are moving towards and into the player, the player comes down to land on the lower platform, until it starts to move back in the other direction. So it's like the static (but moving) platforms' positions are being updated first, then the player is being told it's sitting on an object. But if that's the case, shouldn't it also be affected by the platform above, which would push the player far enough outside it so that it's no longer 'on top of' the lower platform?
I've tried updating the Box2D world both before and after my loop that updates all my game actors (it's in these custom actor update loops that I move moving platforms).
Does anyone have any idea why this might happen?
I've been working on the beginnings of a platform game in XNA using Box2D, and I can't work out what's happening here. I'll give a summary of my setup, and also let you see this video. The video's been cropped down from a 1280x720 game area.
The video is a SWF because I used Flash to quickly crop it - exporting as a video would make it worse quality again, so:
http://www.swfcabin.com/open/1277231066
For moving platforms/objects, I'm making them static bodies and moving at linear unchanging speeds with body.SetTransform. I do this because I searched around for ages on the best way to have moving platforms (which will probably only ever interact with the player, but it'd be nice to be able to have falling boxes etc. in future).
All of my moving platforms work off a Vehicle system - all platforms decide when mobile actors become 'passengers' on them. Then, they update all passengers accordingly - these moving platforms just move their passenger along at the same speed as them. How I'm doing that isn't the issue at the moment.
To move the player character I use body.ApplyForce. This same issue occurs when I use ApplyImpulse too. I don't think I can use SetLinearVelocity, it just wasn't as useful or as natural in several ways.
My issue occurs when two of these moving platforms are 'stacked up' vertically. Note that they're not interacting with each other, and one isn't resting on the other, they just happen to be close to each other. I've checked, and they're always at the same horizontal position.
When the player character jumps up as the platforms are moving towards and into the player, the player comes down to land on the lower platform, until it starts to move back in the other direction. So it's like the static (but moving) platforms' positions are being updated first, then the player is being told it's sitting on an object. But if that's the case, shouldn't it also be affected by the platform above, which would push the player far enough outside it so that it's no longer 'on top of' the lower platform?
I've tried updating the Box2D world both before and after my loop that updates all my game actors (it's in these custom actor update loops that I move moving platforms).
Does anyone have any idea why this might happen?