Hi,I am realy new to c# and i need help.I make a very basic script that allows the player to jump.But the problem is it is flying not jumping.I want the player to jump a single time.If you can help i will be very happy
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public Rigidbody rb;
public float forwardForce = 2000f;
public float jumpForce = 1000f;
public float backForce = -2000f;
void FixedUpdate()
{
if (Input.GetKey("w"))
{
rb.AddForce(0, jumpForce * Time.deltaTime, 0);
}else if (Input.GetKey("d"))
{
rb.AddForce(0, 0, forwardForce * Time.deltaTime , ForceMode.VelocityChange);
}else if (Input.GetKey("a"))
{
rb.AddForce(0, 0, backForce * Time.deltaTime , ForceMode.VelocityChange);
}
}
}