- Home /
Slope polygon collider 2D causing box collider 2D to 'bump' while sliding on it.
I'm doing procedural terrain generation. So far I've created the mesh, and attached a 2D polygon collider to it. The terrain is made up of hills going up and down.
After doing so, I put a 2D rigid body, along with a 2D box collider to represent the player. When I put the player on top and let him slide all the way down, sometimes he doesn't slide properly, and instead bumps on the hill, jumping all of a sudden on his own as if he tripped on something (even though there's nothing there). What's weird is that it doesn't happen all the time, just sometimes. Even when I make him slide on the same spot he bumped before again, he wouldn't do it again except on rare occasions.
What could be causing this?
it would appear that your slide physics code is not adapted to the 2d collider, essentially it's a unity error in the slide code, perhaps it is due to the front of your square being square and going over corners in physics even though they are very gradual. perhaps look at 2-D codes where they have wheels, or see if you can figure out the slide code on the guyden and skip any possible jumping. What is the name of the slide code?
There is no slide code per say. This is just normal gravity of a rigid body with a box collider sliding on a slope shaped polygon collider. I want to note that this isn't happening when I use a circle collider.
Have you tried placing a 2d Physics $$anonymous$$aterial with 0 friction and 0 bounciness on the collider? You also may want to add circle colliders to the feet of the character along with the box for other collision on the body.
Answer by Plystire · Jun 20, 2014 at 05:58 AM
Old question, I know. Figured I'd try to answer this in case someone else stumbled in here.
You should try using a circle collider for the feet of your player, as this will keep the sharp corners of the box from catching on uneven terrain and "tripping" your player.
You can add multiple colliders to your player, so just use a circle near the base of the player, and then a box collider for the upper portion of their body. (Though, looking at your player sprite, a circle may well suit the entire thing lol)
Your answer
Follow this Question
Related Questions
What is the best way to generate water bodies in a procedurally generated world? 1 Answer
How to instantiate prefabs in an unloaded (or just loaded) scene? 1 Answer
How can I generate procedural 3D geometry faster? 2 Answers
Having trouble getting NavMeshBuilder.CollectSources to work. 0 Answers
2D topdown generating stairs (access) to generated hill 0 Answers