Jump to content

  • Log In with Google      Sign In   
  • Create Account


Platform physics in a platformer


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Sik_the_hedgehog   Crossbones+   -  Reputation: 1495

Like
0Likes
Like

Posted 04 December 2012 - 02:25 AM

For those who are making platformers: how do you handle physics for platforms? I mean those that are objects rather than being part of the map itself so they have to be handled differently. The same question also applies to any object that has solid collision. I currently have some platform code up running but I want to know what other approaches are there because I'm having issues with anything that isn't a standard platform, and maybe I could get some idea that way.

In case somebody wonders, I'm asking about what kind of algorithms you use (no need for posting code, just an idea about how they work). Feel free to assume all such objects are axis-aligned rectangles if needed.
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

Sponsor:

#2 DarkRonin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 04 December 2012 - 03:16 AM

I am currently writing a platformer as well. But, I haven't had any issues so far.

Out of interest, what sort of problems are you having? And how have you handled the actual platforms (ie. are they boxes, slopes, etc?)?

#3 Sik_the_hedgehog   Crossbones+   -  Reputation: 1495

Like
0Likes
Like

Posted 04 December 2012 - 04:04 AM

The code works fine for normal platforms, but I have solid objects like pushable rocks and such that do not work correctly (e.g. they can't push each other, or carried objects move at the wrong speed, etc.), not to mention code for walls and such still isn't implemented (only collision from the top).

As for platforms, they're just axis-aligned rectangles =P (the hitbox of the object - with one caveat, if the height of the hitbox is less than 1 then the platform is considered tangible only from the top, but that's just a matter of ignoring collision from the other sides)

PS: in case you wonder how moving platforms can carry objects at the proper speed and pushables can't... probably it's because the way speed is handled is different between them (since platforms are synchronized with the global timer and move using the sin() function so speed is faked by just calculating the current and previous values completely ignoring subpixel precision, while pushables have actual physics with proper speed and gravity).
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

#4 NoAdmiral   Members   -  Reputation: 503

Like
1Likes
Like

Posted 04 December 2012 - 09:29 AM

I'm not entirely certain what part you're having trouble with, but have you considered using a pre-existing physics library? It sounds like you're writing a lot of case-specific code, and I think using a physics library might help to reduce that and probably speed up your coding process.

Inspiration from my tea:

"Never wish life were easier. Wish that you were better" -Jim Rohn

 

herwrathmustbedragons.tumblr.com


#5 Sik_the_hedgehog   Crossbones+   -  Reputation: 1495

Like
0Likes
Like

Posted 04 December 2012 - 09:44 AM

And then I have to rewrite the entire object code from scratch, not to mention having to figure out how to get the physics library behave exactly the way I want (specially things like slopes and such). Physics should be more like old-school games rather than being realistically accurate.

Also for the record, it isn't very case-specific code, since all such solid objects end up would going through the same physics (this is object-against-platform physics I'm talking about). The difference in behavior between platforms and pushables is because platforms move on their own and are required to be synchronized so the way they move doesn't really respect physics for starters (that part is done in the object logic, not the physics code!).

I just asked for ideas to see if there's something I'm overlooking or if there's some better approach than the stuff I'm thinking I could do (still not decided on that).
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS