I am trying to simulate a ship / space station with internal gravity.
To achieve this, I make the player and the entire contents of the ship the children of the ship. The ship itself has colliders, but does not contain solid components of the body. The idea is that as the ship moves, so does its entire contents. Still pretty simple.
To simulate gravity on a ship, the player’s controller and all rigid bodies turned gravity off by default. Instead of the standard, each frame applies force along the negative vector of the original parent ship.
Similar works, but there is one serious problem that I must solve before this thing is solid. All rigid bodies glide very slowly along the inside of the ship.
I know that this is probably due to the updated position of the floor in combination with gravity, leading to some kind of shear force. Objects always glide against the rotation of the ship.
I tried dropping all physical properties from physical materials to drag them to mass, etc. None of them worked, and I am sure that this is due to the fundamental fact that the floor moves, even though RBs are children of the object of which the floor is a part.
Does anyone have a solution for this, is this not some kind of cell tape? I could try to do everything kinematic and only “wake up” when some external collisions or something else happen, but it can become very cumbersome. I need this to work as general as possible.
Some codes:
On the ship
void Update () { transform.Rotate(new Vector3(Time.deltaTime * 0.125f,Time.deltaTime*0.5f,0)); } void FixedUpdate() { Vector3 tempVec; foreach(Rigidbody rb in rigidBodies) {
I also worked on a version where the ship followed the movements of a rigid body. I could not do direct education, so I just had to configure the conversion manually for each frame in accordance with the physical proxy. This still had the same effect as above, although it is likely in the long run how I want to move the ship, as it will be more correctly attached to the mechanics of flight.