2D Toolkit Forum
2D Toolkit => Support => Topic started by: oayhan on August 31, 2013, 09:24:47 am
-
I'm trying to implement a very typical functionality in platform games. I want my character to jump from below a thin platform and get on top of it without colliding, but it should collide with the platform when falling from above. On a 3D world I would use a mesh collider on a mesh with only upward looking normals but I'm not sure how to do it in 2dtk system.
-
If you're using the polygon collider editor, you can create open shapes. That will let you create surfaces with just upward looking normals.
Check the little help box in the polygon collider editor - theres a shortcut to toggle if the shape is closed or not.
-
Thanks for the quick reply. I had some progress, but still not sure what's wrong. The collision with the open collider is wrong and the the object with the box collider and rigidbody collides half way on its collider. I'm attaching an image of my problem, left one is with an open collider, right one is normal box collider.
(http://s23.postimg.org/z5vhkswy3/collision.png)
edit: left one has a downward normal btw, so it should be passing through.
-
Hmm... I've always had issues with single sided physx colliders in Unity - its always been really flakey for me. Can you create a simple repro case for this and email to support? Not sure if anything can be done, but I'll take a look to see if anything is set up incorrectly...
-
I have such platforms in my game and the way I do it is like this:
(https://dl.dropboxusercontent.com/u/27681596/jumpthrough.png)
I have two Colliders. One to stand on and another (the big one) as a trigger. The latter has the script attached to it. I use it as a prefab in my tilemap, but it doesn't have a Sprite attached. The image that you see in the game is from another layer. That way I can use the same prefab for different images.
This is probably not the most elegant way to do it, but it works well.
-
@unikronsoftware I've attached a repro project and included a readme file with it. I don't know if it was a coincidence, but modifying the side normals slightly solves the problem (you can see it in the project).
@Pfaeff I really appreciate your solution. I would be happier if I could solve this with modifying the collider only but your solution seems simple enough too, thanks.
-
Hi,
Your repro case didn't have meta files and pretty much broke straight away - could you please enable meta files, zip up and send by email to support at unikronsoftware.com please? You don't need to include the library folder and the project size should be considerably smaller.
-
I sent the project to your email. I hope it works this time :)
-
1 - the collider depth is too low compared to the size of the collider. Increase it to 20 in the sprite collection editor and it behaves a LOT better.
2 - the red object has a mesh collider - mesh-mesh collisions in Unity don't work unless one is marked as convex. The red one is convex, so you'll need to tick convex on it.
Once those have been resolved, its doing exactly what I'd expect it to, which isn't great. Once it penetrates the surface by a certain amount, Unity thinks its on the "other side" of it and pushes it out. Try it out to see what I mean. I think you will have to solve this by other means, eg. Pfaeff's solution.
-
Yeah, I see your point. I guess I'll go with Pfaeff's solution. On a side note, is there any part of manual that explains editor properties? I'm confused by terms like collider cap, diced rendering etc... I mostly try to see what it is by changing values but couldn't understand in the case of collider cap.
-
http://unikronsoftware.com/2dtoolkit/doc/2.20/reference/sprite_collection.html
Don't think it tells you what collider caps are - the caps are just the fronts and backs of polygon colliders. The default was to leave them out as it wasn't necessary, but now it is enabled by default.
-
Just what I was looking for, thanks.