using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using UnityEngine; public class Player : MonoBehaviour { private bool JumpKeyWasPressed; private float HorizontalInput; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { JumpKeyWasPressed = true; } HorizontalInput = Input.GetAxis("Horizontal"); } void FixedUpdate() { if (JumpKeyWasPressed) { GetComponent<Rigidbody>().AddForce(Vector3.up * 5, ForceMode.VelocityChange); JumpKeyWasPressed = false; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)