i have some troube obout trigger at BoxCollider2d, i create simple jump use trigger for check groud this my code
using UnityEngine;
using System.Collections;
public class kontroler : MonoBehaviour {
public float mspeed;
public float jump;
public Rigidbody2D rb;
private bool cek ;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
float q = Input.GetAxis ("Horizontal") * mspeed;
transform.Translate (new Vector3 (q, 0));
float e = Input.GetAxis ("Vertical") * jump;
// i use false couse default value bool false i mean
if (cek == false) {
rb.AddForce (new Vector2 (0, e));
}
}
void OnTriggerEnter2D(Collider2D col){
//when touch ground value cek = false
if (gameObject.tag == "ground") {
cek = false;
}
}
void OnTriggerExit2D(Collider2D cd){
// when jump , just 1 jump
if(gameObject.tag == "ground"){
cek = true;
}
}
}
im new in unity , :*