well I’ve finally found how to do something but now comes in calculus the heaviness of the code.
I’m orientating my self to planet with raycasting and 1 ray is no problems at all.
but IF I’m going to have bunch of stuff under my feet it’s going to ray through them without any purpose.
RaycastHit hit;
if (Physics.Raycast(transform.position, - transform.up, out hit) ){
if (hit.collider.transform == Planet.transform){
Vector3 MyForward = Vector3.Cross(transform.right, hit.normal);
transform.rotation = Quaternion.LookRotation(MyForward, hit.normal);
}
}
as with Physics.RaycastAll it’ll have to go through all and check all. and I want only for 1 (planet)