Advertisement
albertoaguilar8

Untitled

Oct 31st, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Player : MonoBehaviour
  4. {
  5.     // The force which is added when the player jumps
  6.     // This can be changed in the Inspector window
  7.     public Vector2 jumpForce = new Vector2(0, 300);
  8.    
  9.     // Update is called once per frame
  10.     void Update ()
  11.     {
  12.         // Jump
  13.         if (Input.GetKeyUp("space"))
  14.         {
  15.             GetComponent<Rigidbody2D>().velocity = Vector2.zero;
  16.             GetComponent<Rigidbody2D>().AddForce(jumpForce);
  17.         }
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement