Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how to make an object jump in unity

Rigidbody rb;
float force = 10f;

void Awake(){
  rb = GetComponent<Rigidbody>();
}

void Update(){
   if(Input.GetKeyDown(KeyCode.Space)) {
      rb.AddForce(Vector3.up * force, ForceMode.Impulse);
   }
}
 
PREVIOUS NEXT
Tagged: #object #jump #unity
ADD COMMENT
Topic
Name
6+6 =