I've been trying really hard to get my head around platformer mechanics. I stopped working on my main project today to try building a really basic platformer from scratch just to get a better understanding of the logic.
The problem I'm trying to solve right now is collision detection. I have a binary map that looks like map[y][x] full of 1's for walls and 0's for air. Then I have a testTile(x,y) function that tries to determine what 32x32 pixel tile x,y is in, and then returns true if it's a wall or false if otherwise. I feel like this is the right way to go about it but I can't get it to work. I've attached my .love to this post if anyone has a second to have a look.
Thanks!
yet another collision question thread.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
yet another collision question thread.
Last edited by tehryanx on Sun Apr 20, 2014 2:13 am, edited 1 time in total.
Re: yet another collision question thread.
Wait, nevermind. I solved most of my collision problems, but I have a new one. The problem is that if I don't don't land far enough onto a block i'll fall through it.
- Attachments
-
- ronnyjompsalot.love
- (1.78 KiB) Downloaded 147 times
-
- Citizen
- Posts: 56
- Joined: Wed Feb 27, 2013 7:53 pm
Re: yet another collision question thread.
I suggest you to watch a tutorial of Goature platformer! He made a really cool tutorial
Re: yet another collision question thread.
I just watched it, but he doesn't actually go into any explanation on the collision detection. He just codes the whole thing without really explaining the logic.
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: yet another collision question thread.
The problem your are having is one of the known bugs that come up while coding collision, your collision detection is probably well coded the bug is in the collision response, what happens after the code detects the collision, that's where the problem is.
Re: yet another collision question thread.
So is it insufficient to just kill the velocity on collision? I'm doing it differently now and I still have problems.
I now have 8 separate collision points as in this picture:
The problem is as illustrated on the right. If I hit a platform directly on the corner, i'm allowed to slide onto the platform and I get stuck. Do I just need 4 more collision events for when I hit the corners?
i've attached the new code below.
I now have 8 separate collision points as in this picture:
The problem is as illustrated on the right. If I hit a platform directly on the corner, i'm allowed to slide onto the platform and I get stuck. Do I just need 4 more collision events for when I hit the corners?
i've attached the new code below.
- Attachments
-
- ronnyjumpsalot.love
- (1.97 KiB) Downloaded 149 times
Re: yet another collision question thread.
what about this :
Re: yet another collision question thread.
I'm confused as to how that would work. If I only collide with the top left corner, how do I know which velocity to zero? I might be hitting it from below, but I might be hitting it from the left.
Re: yet another collision question thread.
I imagine there must be a standard way to accomplish this. It's a fundamental part of every platformer so I'm sure I'm reinventing the wheel or tripping myself up in some way that other people have before. I also realize that there are libraries like hardon and bump.lua that could probably handle this for me but I really just want to have a proper understanding of how this stuff works. I've refined everything again and it seems to work except for a minor problem. If I jump into a wall, and then slide down the wall while still holding down the key to accelerate in it's direction it will wrap around the bottom corner of the wall and slide along it as in the diagram below:
Any advice would be greatly appreciated.
Any advice would be greatly appreciated.
- Attachments
-
- ronnyjumpsalot.love
- (2.53 KiB) Downloaded 309 times
Re: yet another collision question thread.
It's because for a short while, you set the y-vel to 0 when colliding with the ceiling. When this happens, you stay colliding to the ceiling until you get out from under it.
By the way, not sure if this was intentional or not: in the .love you put ronnyjumpsalot, but the loading screen has Rony Jompsalot
By the way, not sure if this was intentional or not: in the .love you put ronnyjumpsalot, but the loading screen has Rony Jompsalot
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot] and 2 guests