Hey, I’m working on this little game mechanic where the player character gravitates towards surfaces that are set to attract them. I already have the detection working, I can find the direction toward an object’s surface and the normal that is needed to align the character to the surface correctly.
However, I can’t wrap my head around the rotations and I just can’t get it working.
fallingDirection = closestPlanet.GetComponent<Collider>().ClosestPointOnBounds(transform.position) - transform.position;
fallingDirection.Normalize();
transform.rotation = Quaternion.LookRotation(-fallingDirection);
Currently it does rotate the character towards the ground, but the axis are messed up. If anyone knows how to fix this I’d love to hear it.