using UnityEngine; using System.Collections; public class PlayerControler : MonoBehaviour { // Use this for initialization void Start () { } public float speed; public Vector2 jumpVector; public GameObject bullet; bool canJump = true; void Update() { Vector2 velo = rigidbody2D.velocity; velo.x = Input.GetAxis ("Horizontal_P1") * speed; rigidbody2D.velocity = velo; if (Input.GetKey (KeyCode.UpArrow)){ if (canJump == true){ rigidbody2D.velocity = jumpVector; canJump = false; } } //if (Input.GetKey (KeyCode.Space)){ //shoot //GameObject bulletGO = Instantiate (bullet) as GameObject; //bulletGO.transform.position = transform.position; //} } void OnCollisionEnter2D(Collision2D col){ if (col.collider.tag == "ground") canJump = true; else if(col.collider.tag == "Player") canJump = true; } }