Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class KontrolerGracza : MonoBehaviour {
  6.  
  7.     public bool groundded = true;
  8.     public float jumpPower =190;
  9.     public float walkSpeed = 2;
  10.     public Rigidbody2D rbody;
  11.  
  12.     void Start () {
  13.  
  14.         rbody = GetComponent<Rigidbody2D> ();
  15.     }
  16.    
  17.     // Update is called once per frame
  18.     void Update () {
  19.  
  20.         if (!groundded && rbody.velocity.y == 0) {
  21.             groundded = true;
  22.  
  23.         }
  24.         if ((Input.GetKey (KeyCode.W) || Input.GetKey (KeyCode.UpArrow))
  25.             && groundded == true)
  26.         {
  27.             groundded = false;
  28.             rbody.AddForce (transform.up * jumpPower);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement