Ejemplo n.º 1
0
    private void PlayerMovment()
    {
        //Debug.Log(InputController.HorizontalMovement);
        //Debug.Log(InputController.Jump);
        //if (transform.parent != null)
        //{
        //    Debug.Log("mam parenta");
        //    float velocity = GetComponentInParent<Rigidbody2D>().velocity.x + InputController.HorizontalMovement * speedOnPlatform;
        //    //float maxSpeed = speed;
        //    //float minSpeed = speed;
        //    //if(GetComponent<Rigidbody2D>().velocity.x >= 0)
        //    //{
        //    //    maxSpeed = GetComponentInParent<Rigidbody2D>().velocity.x + speed;
        //    //}
        //    //else
        //    //{

        //    //}
        //    //float velocity = GetComponent<Rigidbody2D>().velocity.x + InputController.HorizontalMovement * speed;
        //    objectController.SetHorizontalVelocity(velocity);
        //}
        //else
        //{
        //    Debug.Log("NIE mam parenta");
        //    objectController.SetHorizontalVelocity(InputController.HorizontalMovement * speed);
        //}
        objectController.SetHorizontalVelocity(InputController.HorizontalMovement * speed);
        if (InputController.Jump)
        {
            objectController.SetVerticalVelocity(speed);
        }
    }
Ejemplo n.º 2
0
 void Update()
 {
     if (transform.position.x > rightBound.position.x)
     {
         movingSide = -1;
     }
     if (transform.position.x < leftBound.position.x)
     {
         movingSide = 1;
     }
     objectController.SetHorizontalVelocity(speed * movingSide);
 }