You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

45 lines
836 B

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;
}
}