- Home /
[2D] How to Smooth out Rugged Ground
So I have very rugged terrain, but when the player runs along it, he bounces all over the place. How can I autogenerate the collider but have it be more smooth?
Example: https://gyazo.com/4435a06684f95c89d3b7a698e5c686eb
Any help would be greatly appreciated!
Answer by Klarzahs · Dec 07, 2018 at 10:41 AM
Heya,
you could use a the Douglas Peucker algorithm. It basically looks at a drawn polygon/line (your mesh topmost vertices) and removes every "unnecessary" vertice in between.
You can use this by creating a new empty gameobject container, that overlays your current ground. Then you sample the topmost vertices from your ground, apply DP-Algo and create a new Mesh with theses reduced points. Add this mesh to your container go and add a mesh collider. Remove the collider from the original mesh and you should be good to go.
Your answer
Follow this Question
Related Questions
Is there a solution to when colliders bypass? 2 Answers
Collision problem 0 Answers
Button Enabling/Disabling using Collision Triggers? 1 Answer
2D box colliders not touching but are colliding, how to fix? 0 Answers
Collision vs trigger 1 Answer