Hello, Im trying to make a simple jump feature with my cube, except it starts to fly. Any help? here’s the code:
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public Rigidbody rb;
public float ForwardForce = 2000f;
public float SidewaysForce = 500f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
rb.AddForce(0, 0, ForwardForce * Time.deltaTime);
if (Input.GetKey("right"))
{
rb.AddForce(SidewaysForce * Time.deltaTime, 0, 0);
}
if (Input.GetKey("left"))
{
rb.AddForce(-SidewaysForce * Time.deltaTime, 0, 0);
}
if (Input.GetKey("up"))
{
rb.AddForce(0, 1000 * Time.deltaTime, 0);
}
}
}