using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class ballCtrl : MonoBehaviour
{
private bool doRight = false;
private bool doLeft = false;
public bool isCrashed = false;
private Rigidbody2D rb;
public float sensivity;
void Start () {
rb = GetComponent<Rigidbody2D> ();
doRight = false;
doLeft = false;
}
void Update () {
if (!doRight && !doLeft) {
Debug.Log (doRight);
Debug.Log (doLeft);
return;
} else if (doLeft) {
//Left
rb.AddForce (Vector2.left * Time.deltaTime * sensivity);
Debug.Log ("Left Go");
} else {
//Right
rb.AddForce (Vector2.right * Time.deltaTime * sensivity);
Debug.Log ("Right Go");
}
}
public void LeftDown(){
doLeft = true;
//rb.AddForce (Vector2.left * Time.deltaTime * sensivity);
Debug.Log ("Left Down");
return;
}
public void LeftUp(){
doLeft = false;
Debug.Log ("Left Up");
}
public void RightDown(){
//rb.AddForce (Vector2.right * Time.deltaTime * sensivity);
doRight = true;
Debug.Log ("Right Down");
return;
}
public void RightUp(){
doRight = false;
Debug.Log ("Right Up");
return;
}
}
These codes are not working. Actually, the code makes NO compile error, but the actor isn’t moving. and also Debug.Log() is still calling!!! Log: Right up, Right down…
So, Do the variables are error? or there is something errored?!?!??
please help. I am having this problem for 3 days… Project’s aren;t continuing if this can’t fix.