Пример #1
0
    private void move(float direction, bool jump)
    {
        Vector2 movement = new Vector2(direction, jump?powerJump:(myBody.position.y <= margins.getMarginYBottom()?0.0f:-powerJump));

        myBody.velocity = movement * speed;
        GetComponent <Transform>().position = new Vector3
                                              (
            Mathf.Clamp(myBody.position.x, margins.getMarginXBottom(), margins.getMarginXTop()),
            Mathf.Clamp(myBody.position.y, margins.getMarginYBottom(), margins.getMarginYTop()),
            0
                                              );
    }