예제 #1
0
	// Update is called once per frame
	void FixedUpdate () {

        float xInput = Input.GetAxis("Horizontal");
        float xMove = 0f;

        myX = transform.position[0];
        myY = transform.position[1];


        Vector3 camEdgePos = Camera.main.ScreenToWorldPoint(Vector3.zero);

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            if(myDirection == direction.LEFT)
            {
                anim.SetTrigger("right");
            }
            
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            if (myDirection == direction.RIGHT)
            {
                anim.SetTrigger("left");
            }
        }

        if (xInput > 0)
        {
            xMove = speed;
            myDirection = direction.RIGHT;
            stationary = false;

            
        }
        else if ((LevelRenderer.getTile( camEdgePos[0] ) >= LevelRenderer.getTile(transform.position[0]) )  )
        {
            xMove = 0;
        }
        else if(xInput < 0)
        {

        

            xMove = -speed;
            myDirection = direction.LEFT;
            stationary = false;


        }
        

        myBody.velocity = new Vector2(xMove, myBody.velocity[1]);






    }