using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class player2_controls : MonoBehaviour {
|
|
|
|
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_P2") * speed;
|
|
rigidbody2D.velocity = velo;
|
|
|
|
if (Input.GetKey (KeyCode.W)){
|
|
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;
|
|
}
|
|
|
|
|
|
}
|