jeudi 24 août 2017

Update screen only works once and then stops working || UNITY

So i have a 3x3 gameBoard. The character starts in the middle. When i press right nothing happens, when i press left nothing happens but when i press up it moves to the position in the code.

void Start()
{

    transform.position = new Vector2(0.28f, -0.27f);
    print(transform.position.x);



}

void Update()
{



          if (ChrP == new Vector2(0.28f, -0.27f))
                    {
                        if (Mathf.Abs(Input.GetAxisRaw("Right")) > 0.0f)
                        {
                            transform.position = new Vector2(1.95f, -0.27f);
                        }
                        if (Mathf.Abs(Input.GetAxisRaw("Left")) > 0.0f)
                        {
                            transform.position = new Vector2(-1.36f, 
                                                            -0.27f);
                        }
                        if (Mathf.Abs(Input.GetAxisRaw("Down")) > 0.0f)
                        {
                            transform.position = new Vector3(0.28f, 
                                                           -1.923f);
                        }
                        if (Mathf.Abs(Input.GetAxisRaw("Up")) > 0.0f)
                        {
                            transform.position = new Vector3(0.28f, 1.401f);
                        }
                        else
                        {
                        }
                    }

}

So, for the new "Up" position i have the same type of code and i have checked everything but it just freezes instead of moving. My expectation is that it is going to check every frame if i have pressed the button. Maybe i have missed something. Also both after and before the if statement i have the same type of code but for other coordinates!

Aucun commentaire:

Enregistrer un commentaire