Yo!
So I am making a FPS game where player can control its gravity. The Physics.gravity is set to 0 as I want other objects in the scene floating. I am simulating gravity on player by AddForce function. Gravity can be changed in any direction, I am stuck on, when player changes the gravity to be in negative x-axis the player rotates so that its bottom is facing in the direction of gravity(done using animation), the movement of the player gets messy and in-controllable.
I am using the Rigidbody First person Controller prefab of Standard Assets with some minor modifications.
I found these lines in the RBFPController script:
Vector3 desiredMove = cam.transform.forward*input.y + cam.transform.right*input.x;
desiredMove = Vector3.ProjectOnPlane(desiredMove, m_GroundContactNormal).normalized;
desiredMove.x = desiredMove.x*movementSettings.CurrentTargetSpeed;
desiredMove.z = desiredMove.z*movementSettings.CurrentTargetSpeed;
desiredMove.y = desiredMove.y*movementSettings.CurrentTargetSpeed;
if (m_RigidBody.velocity.sqrMagnitude <
(movementSettings.CurrentTargetSpeed*movementSettings.CurrentTargetSpeed))
{
m_RigidBody.AddForce(desiredMove*SlopeMultiplier(), ForceMode.Impulse);
}
Watch the video!
When I change the gravity to be in -x axis the “Player” rotates and falls, controls go wrong