|
Title: Clever way of handling moving platforms in a platform game Post by: ThemsAllTook on June 15, 2012, 10:27:27 AM Something I saw on Twitter (thanks @NoelFB (https://twitter.com/NoelFB/status/213548155378212864)!) that I thought was good enough to repost here. I've struggled with this problem before, and this solution is so clean and simple that I'm kicking myself for not having thought of it: http://gamedev.stackexchange.com/questions/3964/how-do-i-handle-moving-platforms-in-a-platform-game/3967#3967
Title: Re: Clever way of handling moving platforms in a platform game Post by: Raptor85 on June 16, 2012, 04:00:36 AM that's one way to do it, seems somewhat of a variation of how engines like the unreal engine handle it, though not storing position relative to the parent node, just attaching to it as a base for your velocity.
I do a somewhat similar method, create a collision list when objects collide with each other, then anything that adds velocity (simple movement, jumping, etc) is tested against the list to see how it should be modified, this lets you do things like have elevators that lift you up and a piston that pushes you off up top, i've used a variation of this "simple" physics engine for any platfomer type test i've done since I first came up with it as a solution while making my entry for QJ.net's 2008 "PSP Summer Homebrew" contest as it's simple but effective, far simpler than using a full physics engine or just doing simple "bump" collision like I used to (which makes stuff like elevators and moving platforms jittery) can toy with it here to see how it works if you have a homebrew enabled psp https://www.midnightfragfest.com/psp-engine-test/ Title: Re: Clever way of handling moving platforms in a platform game Post by: Aloshi on June 16, 2012, 07:16:34 AM A while back I tried adding moving platforms into Torque 3D, and did a variation of this - all objects kept a list of children, and when a player stood on an object it added itself to the object's children list. Then, whenever the object's position changed, I calculated how much it moved from where it was and added that difference to the children's positions. It wasn't physically correct, but it worked well for what I was making (since not all objects have velocity, but they do have position).
Title: Re: Clever way of handling moving platforms in a platform game Post by: InfiniteStateMachine on June 16, 2012, 03:50:44 PM hmm that's pretty interesting. Actually seems so simple too. I was kind of bracing myself for dealing that issue if i ever work on a platformer.
I kind of have something like that in one of my frameworks now. The difference is it's just a parent/child system built into the object itself. The child gets whatever motion its parent has. I use it for a shmup with no complex collisions though (mostly for smaller items that follow the player). |