Hi so i’ve started learning unity and i made a code that should make a ball jump and move but when i give a value to salto my ball goes out of the screen flying.
This is the code:
public class move : MonoBehaviour
{
public float forceValue;
public float Salto;
private Rigidbody rigidbody;
void Start()
{
rigidbody = GetComponent ();
}
void Update()
{
if (Input.GetButtonDown(“Jump”) && Mathf.Abs(rigidbody.velocity.y) < 0.01f);
rigidbody.AddForce(Vector3.up * Salto, ForceMode.Impulse);
}
public void FixedUpdate()
{
rigidbody.AddForce(new Vector3 (Input.GetAxis (“Horizontal”),
0,
Input.GetAxis(“Vertical”)) * forceValue);
}
}