T
T
Tanyel2019-12-11 23:45:52
Unity
Tanyel, 2019-12-11 23:45:52

How to change the angle of an object to match the surface?

I have an object with a circle collider 2d, and an uneven surface with a polygon collider 2d.
5df1552eb1955549313227.png
Now the corner is up. And it is necessary that the angle of the object be depending on what angle the given section of the surface has.
5df1556e97788563337235.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2019-12-12
@Tanyel

You need to get the shortest distance from the center of the collider to a point on the surface along the entire path of the curve and immediately create an array of object rotation angles depending on the location relative to the surface path.
PS: It's better not to take the point of contact, because. if the object jumps, falls off the slope - it will sway randomly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question