Well then.
I'm sure there are about fifty thousand of these topics but none of them seem to directly answer my questions.
So, here's hoping. The questions I have are:
[*] How would one go about making collision detection for a platform? Currently, I'd like a freeform detection and not a map-based one. Now while I am sure that my game will turn into this, I'd like to know the other methods as well.
[*] Then, how would one make gravity realistic enough to be called a platformer? I'm afraid this is the one thing that has evaded my logical mind.
[*] How would a player know which side of a platform it hit? You can understand. I need to kill the X velocity on the sides, reverse the Y velocity on the bottom and halt the Y velocity on the top? (re: platforms and such)
Thank you.
Collision Detection, gravity, and platforms? Oh my!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Collision Detection, gravity, and platforms? Oh my!
You could use love.physics, but the downside of using that is that it's rather complicated and won't give you "realistic" physics (not realistic for platformers, anyway).Raylin wrote:How would one go about making collision detection for a platform? Currently, I'd like a freeform detection and not a map-based one. Now while I am sure that my game will turn into this, I'd like to know the other methods as well.
So, writing your own collision detection might be the best option. You can look on the forums around here for inspiration.
I'm not sure what you mean, but usually, platformers aren't at all realistic in terms of gravity and related subjects, because that would kill the playing experience. But you can usually find the right properties by tweaking the parameters.Raylin wrote:Then, how would one make gravity realistic enough to be called a platformer? I'm afraid this is the one thing that has evaded my logical mind.
Compare the x/y of the player and the platform in question.Raylin wrote:How would a player know which side of a platform it hit? You can understand. I need to kill the X velocity on the sides, reverse the Y velocity on the bottom and halt the Y velocity on the top? (re: platforms and such)
Also, depending on your previous experience with Lua and LÖVE, you might want to fool around a bit first, to get the feeling for it.
Help us help you: attach a .love.
Re: Collision Detection, gravity, and platforms? Oh my!
Seems simple enough. I'll probably botch up the gravity though.
I'll work on it some more and then post some code.
I'll work on it some more and then post some code.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Collision Detection, gravity, and platforms? Oh my!
If you want, Kurosuke ( http://love2d.org/forums/viewtopic.php?f=5&t=2197 ) is open source, I've tried to make it kinda flexible and easy to read. If nothing else, it can give you some ideas for how to pull stuff off.
Kurosuke needs beta testers
Re: Collision Detection, gravity, and platforms? Oh my!
Thank you for that, sir. Very helpful.
Now, I am fiddling around with the ParticleSystem.
Are there any tutorials on that in the forum?
EDIT: Sorry about that. I didn't know that having the start() method in love.update didn't conflict. (Meaning I thought it would only emit one particle)
EDIT 2: FFFFFF- I can't have just rectangular collisions. I need a way for asymmetrical collision detection...
Now, I am fiddling around with the ParticleSystem.
Are there any tutorials on that in the forum?
EDIT: Sorry about that. I didn't know that having the start() method in love.update didn't conflict. (Meaning I thought it would only emit one particle)
EDIT 2: FFFFFF- I can't have just rectangular collisions. I need a way for asymmetrical collision detection...
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Collision Detection, gravity, and platforms? Oh my!
To the best of my knowledge, Love supports polygonal shapes of up to 8 sides (physics shapes are used for collision in Kurosuke). In the ramp object I use a three sided polygon to create a triangle. In the player avatar I use a circle.
I'm fairly sure you can lock multiple shapes to a single body: I've thought about putting a head shape on the player several times, but the benefits weren't worth the extra work.
I'm fairly sure you can lock multiple shapes to a single body: I've thought about putting a head shape on the player several times, but the benefits weren't worth the extra work.
Kurosuke needs beta testers
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Collision Detection, gravity, and platforms? Oh my!
The problem with Kurosuke is that it uses love.physics, which famously is not recommended for platformers.
Help us help you: attach a .love.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Collision Detection, gravity, and platforms? Oh my!
1) At its simplest: Check the player's coordinates against those of your platform. If they intersect, don't let the player move there.Raylin wrote:[*] How would one go about making collision detection for a platform? Currently, I'd like a freeform detection and not a map-based one. Now while I am sure that my game will turn into this, I'd like to know the other methods as well.
[*] Then, how would one make gravity realistic enough to be called a platformer? I'm afraid this is the one thing that has evaded my logical mind.
[*] How would a player know which side of a platform it hit? You can understand. I need to kill the X velocity on the sides, reverse the Y velocity on the bottom and halt the Y velocity on the top? (re: platforms and such)
2) Make the downward force increase over time. What I like doing is giving the player object momentum which changes their position, rather than changing position directly (for example, in love.update, do player.x, player.y = player.x+player.momentum.x, player.y+player.momentum.y. Also, make sure to decrease momentum every frame, with something like player.momentum.x, player.momentum.y = player.momentum.x*.9, player.momentum.y*.9). By making the controls affect momentum rather than position, you can also get "running start" and "skidding to a halt" stuff. When falling, just increment their downwards momentum every frame (say, player.momentum.y = player.momentum.y - dt). This will give you very natural logarithmic falls, ballistic curves, and so on.
3) As Robin said.
Despite what everyone will tell you, you CAN use the physics engine for a platformer if you're careful. But the only real reason to do this is if you want the player to be able to interact with physics objects in your game.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Collision Detection, gravity, and platforms? Oh my!
And if you want collisions to be with anything other than rectangles. I would dearly like to see someone write collision in Love that is not physics based AND can do non-rectangles, but I suspect that the comparative ease of using physics like I have will prevent that from ever happening.Despite what everyone will tell you, you CAN use the physics engine for a platformer if you're careful. But the only real reason to do this is if you want the player to be able to interact with physics objects in your game.
Also, playing with boxes is fun.
Kurosuke needs beta testers
Re: Collision Detection, gravity, and platforms? Oh my!
What I'm thinking about doing will involve a table that takes the bounding box of ALL the collidables and comparing the player bounding box with it...
But, how fast would that be?
But, how fast would that be?
Who is online
Users browsing this forum: Ahrefs [Bot] and 73 guests