I am relatively new to scripting and have been having a little trouble with creating submarine movement in water. I am confused on how to create a zero gravity type area where the player can go on all the axis not just x and z. So far I have this code so please bear with me
public class PlayerController : MonoBehaviour
{
public float speed;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
if (Input.GetKey("17"))
transform.Rotate(0, -5, 0);
if (Input.GetKey("16"))
transform.Rotate(0, 5, 0);
}
I was wondering if there was anything that I needed to do since at the moment it kinda just falls to the ground and if I turn off gravity nothing happen.