-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collision issues when character collides with corner of platform #6
Comments
@prime31 Tagging you in case you aren't watching the repo. Have any good solutions to this one? Kinda makes it a no go for me in the game I'm working on. |
If you up your horizontal and vertical ray count it should remedy that. Mike On Fri, Dec 20, 2013 at 8:18 PM, Ryan Nielson notifications@github.comwrote:
|
Ya, I upped it to 20 horizontal and 20 vertical rays and I can still produce it consistently. Bummer. |
One other quicky solution you can do is add a diagonal ray check in the Mike On Fri, Dec 20, 2013 at 8:32 PM, Ryan Nielson notifications@github.comwrote:
|
Ya, I'll have to give that a go and see how it works. Thanks. |
Do you happen to have a simple repro project you can send my way? If so, send it over to mike (at) prime31.com |
I can try to set something up this evening and send it your way. — On Mon, Dec 23, 2013 at 2:02 PM, Mike notifications@github.com wrote:
|
@prime31 Sent, hopefully you can repro it and find a decent solution. |
So, a quick and dirty fix for the issue until we get some more Physics2D methods exposed by Unity is to just add the following method to the CharacterController2D class:
Then add the 2 lines in the screenshot below to the move method. |
Awesome, thanks! Seems to get rid of the clipping issue. Only problem that exists because of this code, is when my character jumps while moving left or right into a wall he doesn't jump the normal height. You can repro this by holding the left key when you're touching a wall, and jumping. |
Aha. Good point. An extra check will be needed in there to account for when moving left/right while already having a collision on the left/right. In those cases the diagonal check should be skipped. Mike On Tue, Dec 24, 2013 at 9:45 AM, Ryan Nielson notifications@github.com
|
Just for anyone else, I was having trouble getting prime31's last fix comment to work. I think I have it working so here is the code that I modified if it helps anyone...
|
Just in case you havent seen it yet, I believe the latest commit should avoid any and all issues with corner penetration: b6fc72f |
@prime31 Oh neat, thanks for the update. I'll have to take a look at it again. |
I dug into this more since I was still getting this issue... If you're using Tk2dTilemaps, the way Tk2d creates the physics colliders is by creating a bunch of edge colliders. Unfortunately if the CharacterController falls in between the edge colliders there is no "volume" to speak of and the ray casts will treat the inside of the edge as the ground. I would say this is actually a flaw with tk2d and not with the CharacterController. Another way would be for tk2d to use polygon or box colliders instead. But looking on the tk2d forums it seems like the author is against that for performance reasons. Any thoughts on a way to prevent this with our ray casts? |
Perhaps doing a diagonal raycast from the forward corner's position before movement to its position after movement would do the trick. Mike On Jan 29, 2015, at 10:53 PM, Kyle Reczek notifications@github.com wrote: I dug into this more since I was still getting this issue... If you're using Tk2dTilemaps the way Tk2d creates the physics colliders is by creating a bunch of edge colliders. Unfortunately if the CharacterController falls in between the edge colliders there is no "volume" to speak of and the ray casts will treat the inside of the edge as the ground. I would say this is actually a flaw with tk2d and not with the CharacterController. Any thoughts on a way to prevent this with our ray casts? Another way would be for tk2d to use polygon or box colliders instead... — |
I have the CharacterController2D script on a character. In my test level I have some 2d colliders that are set as the ground. If I jump diagonally into a corner of the collider with my character, my character clips through the platform like in the picture attached. I'm assuming this is because rays are sent out vertically and horizontally, and I'm hitting right on my character's corner.
Blue block on the right jumped and corner hit the platformer, causing him to clip through and get stuck within the platform.
The text was updated successfully, but these errors were encountered: