The jumping and the rotation works fine although the character moves at a extremely slow speed, I tried to tweak the values of my code (even with high values like 3000) and the mass but nothing happens…
Heres the code:
public class scr : MonoBehaviour
{
//Variables
public float speed = 30000;
private Rigidbody rb;
private float midJump = 1;
//Character Movement
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0f, moveVertical);
rb.transform.position += movement * Time.deltaTime * speed;
//Character Jump
if (midJump == 1 && Input.GetKeyDown(KeyCode.Space))
{
rb.velocity = new Vector3(0, 45, 0);
midJump = 2;
}
else if (rb.velocity.y == 0)
midJump = 1;
//Character Rotation
{
if (Input.GetKeyDown(KeyCode.D))
rb.MoveRotation(Quaternion.Euler(0, 90, 0));
if (Input.GetKeyDown(KeyCode.A))
rb.MoveRotation(Quaternion.Euler(0, -90, 0));
if (Input.GetKeyDown(KeyCode.W))
rb.MoveRotation(Quaternion.Euler(0, 0, 0));
if (Input.GetKeyDown(KeyCode.S))
rb.MoveRotation(Quaternion.Euler(0, 180, 0));
}
}
}