Answers for "unity 3d jumping script"

C#
0

unity 3d jumping script

public int forceConst = 50;
 
 private bool canJump;
 private RigidBody selfRigidbody;
 
 void Start(){
     selfRigidbody = GetComponent<RigidBody>();
 }
 
 void FixedUpdate(){
     if(canJump){
         canJump = false;
         selfRigidbody.addForce(0, forceConst, 0, ForceMode.Impulse);
     }
 }
 
 void Update(){
     if(Input.GetKeyUp(Keycode.SPACE)){
         canJump = true;
     }
 }
Posted by: Guest on August-07-2021

C# Answers by Framework

Browse Popular Code Answers by Language