Exemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (!ready)
        {
            return;
        }

        //DontGoThroughThings(player_collider, player_rb);
        //DontGoThroughThings(left_toe_collider, player_rb, delegate { right_foot_caught = true;});
        //DontGoThroughThings(right_toe_collider, player_rb, delegate { left_foot_caught = true; });

        InputTransform inp = new InputTransform();

        move_state.Move(inp, transform);
        anim.SetFloat(animation_speed_id, (float)move_state.anim_speed);
        anim.SetFloat(animation_direction_id, (float)move_state.anim_direction);
        anim.speed = (float)move_state.anim_speed;

        player_rb.useGravity = true;

        if (Input.GetButtonDown(jump_button) && move_state.is_grounded)
        {
            move_state = new JumpingMovementState(this);
            //GetComponent<Rigidbody>().AddForce(Vector3.up * 1.0f);
            right_foot_caught = false;
            left_foot_caught  = false;
        }
        else if (right_foot_caught || left_foot_caught)
        {
            move_state.FootGrounded();
        }
        else
        {
            move_state.FootUngrounded();
        }

        move_state.FixedUpdate();
        velocity = transform.TransformDirection(velocity);
        //Debug.Log($"velocity: {velocity}");
        player_rb.velocity = new Vector3(velocity.x, player_rb.velocity.y, velocity.z);
        //Debug.Log($"pos: {transform.localPosition}");
        Debug.Log(move_state.GetType().ToString());
    }