Hello Community,
My player (using CharacterController, no rigidbody) is walking on a large somewhat spherical object (no Terrain, its in “space”) which is slowly rotating on the its three axis. As I walk across this object, I want my Player’s…normal?..to stay basically perpendicular to the asteroid surface so that I don’t walk/fall off. I’ve done some Internet searches and have this so far:
if (mmo.AsteroidWalking = true) {
desiredUp = Vector3.zero;
for (int i=0; i <8; i++) {
Vector3 rayStart =
transform.position
+ transform.up
+ Quaternion.AngleAxis(360 * i / 8.0f, transform.up)
* (transform.right * 0.5f)
+ desiredVelocity*0.2f;
Debug.DrawRay(rayStart, transform.up * -5, Color.red);
// Debug.Log(Physics.Raycast(rayStart, transform.up*-48, out hit, 3.0f, groundLayers));
if ( Physics.Raycast(rayStart, transform.up*-5, out hit, 10.0f, groundLayers) ) {
desiredUp += hit.normal;
}
}
Debug.Log (desiredUp);
Debug.DrawRay(Vector3.zero,hit.normal,Color.blue);
}
This shoots out 8 rays in a circle around my character to the “ground” and gets me desiredUp but I don’t know what to do with desiredUp or how to apply this to set my Player upright compared to the surface.
I might have bungled the question title as I’m really learning the terms as I work through this, let me know addtional details are needed. Thank you!