Strange glitches I need help solving
Posted:
Mon Aug 20, 2012 2:27 am
by supatails
I'm trying to get the view to follow the player with a delay, and so far it's working, but whenever I drop off a cliff, rather than landing I fall through the tiles. Also it's kinda buggy when I try walking into a platform. I included a demo.
Re: Strange glitches I need help solving
Posted:
Mon Aug 20, 2012 7:37 am
by skydereign
That problem just has to do with collisions. Your code for view movement seems fine. It doesn't at all impact the movement of the player. Now the major problem in this is that your basic tile is only 10 pixels tall. Your player animation is 14 pixels tall. This means if the player is falling at a yvelocity of 25, the player if aligned properly could pass straight through the tile in a single frame without ever colliding with it. This would only be the case if it was aligned perfectly, but yvelocity can easily exceed 25. In one second of falling, your player begins to fall at a yvelocity of 30, which easily can pass through the ground.
To fix this you can do several things. Increase the height of your tiles, set a max fall speed, or similar. One thing to note though is that the player should never be able to fall past half way within the tile, in your case its around a yvelocity of 12 (player's height/2 + tile's height/2).
For collisions in general though it is usually handy to use a rectangular collision actor to handle movement and the like. That way you won't run into odd collisions due to irregular player animations.
Re: Strange glitches I need help solving
Posted:
Mon Aug 20, 2012 2:52 pm
by supatails
Thank you! I set up an if statement to limit the players gravity speed so he doesn't skip past the tile:
- Code: Select all
if(yvelocity<10){yvelocity++;}
and I'll try to add a box parented to floober to collide with stuff.