Esempio n. 1
0
 // Start is called before the first frame update
 void Start()
 {
     input     = GetComponent <PlayerInput_custom>();
     anim      = GetComponent <Animator>();
     movClass  = GetComponent <PlayerMovement_custom>();
     rigidBody = GetComponent <Rigidbody2D>();
 }
    private Animator anim;                  //Animator component

    void Start()
    {
        //assuming player can move
        canMove = true;

        //Get a reference to the required components
        input           = GetComponent <PlayerInput_custom>();
        rigidBody       = GetComponent <Rigidbody2D>();
        bodyCollider    = GetComponent <BoxCollider2D>();
        hitbox_Collider = GetComponentInChildren <WeaponCollider>();
        anim            = GetComponent <Animator>();

        //Record the original x scale of the player
        originalXScale = transform.localScale.x;

        //Record the player's height from the collider
        playerHeight = bodyCollider.size.y;

        //Record initial collider size and offset
        colliderStandSize   = bodyCollider.size;
        colliderStandOffset = bodyCollider.offset;

        //Calculate crouching collider size and offset
        colliderCrouchSize   = new Vector2(bodyCollider.size.x, bodyCollider.size.y / 2f);
        colliderCrouchOffset = new Vector2(bodyCollider.offset.x, bodyCollider.offset.y / 2f);
    }