I have a cube that rotates with root motion (various tumbling animations).
When the cube is standing on a hilly surface the root of the root motion keeps standing up straight and so does my cube (unless physics takes over of course). How can I roll the cube with root motion up a curvy terrain in a realistic way?
Hi @ngerbens, the easiest way to do this is to Ray Cast from your object down along its y axis and find the hit.normal where it collides with the terrain. Then align your object with the normal.
There is a slight inaccuracy in this method because, if you look at your image, you really want to get the hit normal at the location that corresponds to the center of the cube’s contact with the ground in your 3rd image.
You can calculate where this needs to be and adjust your Ray Cast accordingly, but the method probably accurate enough without doing that in most cases - I think you can imagine varying slopes where it would not be accurate enough. It depends on how wide or deep your cube is with respect to the terrain slope variation.