Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class KontrolerGracza : MonoBehaviour {
- public bool groundded = true;
- public float jumpPower =190;
- public float walkSpeed = 2;
- public Rigidbody2D rbody;
- void Start () {
- rbody = GetComponent<Rigidbody2D> ();
- }
- // Update is called once per frame
- void Update () {
- if (!groundded && rbody.velocity.y == 0) {
- groundded = true;
- }
- if ((Input.GetKey (KeyCode.W) || Input.GetKey (KeyCode.UpArrow))
- && groundded == true)
- {
- groundded = false;
- rbody.AddForce (transform.up * jumpPower);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement