using UnityEngine;
using System.Collections;
public class Player_movement : MonoBehaviour {
void OnCollisionEnter2D(Collision2D coll){
if (coll.gameObject.tag == “level” ) {
isjumping = false;
hasdashed = false;
}
}
void dash (){
rgb.AddForce (transform.forward * dashspeed);
Debug.Log (“dashing”);
}
public float speed = 3f;
public float jumpspeed = 90f;
public void jump () {
rgb.AddForce (transform.up * jumpspeed);
isjumping = true;
}
private Rigidbody2D rgb;
private bool isjumping;
private bool hasdashed;
public float dashspeed = 90f;
// Use this for initialization
void Start () {
rgb = gameObject.GetComponent<Rigidbody2D>();
isjumping = false;
hasdashed = false;
}
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.A)) {
transform.position += Vector3.left * speed * Time.deltaTime;
}
if (Input.GetKey (KeyCode.D)) {
transform.position += Vector3.right * speed * Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.Space) && !isjumping && !hasdashed ) {
jump ();
}
if (Input.GetKeyDown (KeyCode.Space) && isjumping == true && !hasdashed) {
dash ();
}
}
}
i have this code that is made to make the character move and such, the problem i am having is with the dash and the if statement surrounding it. not only does the debug.log tell me that its activating when it shouldnt be even with my if statement perameters but also when i do activate it it doesnt do anything. can someone help?