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); } }
void Update() { if (transform.position.x > rightBound.position.x) { movingSide = -1; } if (transform.position.x < leftBound.position.x) { movingSide = 1; } objectController.SetHorizontalVelocity(speed * movingSide); }