Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Awake()
    {
        controller2D    = GetComponent <LagueController2D>();
        onHitObject     = GetComponent <SpawnOnHit>();
        animator        = GetComponent <Animator>();
        spriteRenderer  = GetComponent <SpriteRenderer>();
        health          = GetComponent <Health>();
        hitbox          = GetComponent <RectHitbox>();
        defaultMaterial = spriteRenderer.material;

        health.OnDiedEvent += this.OnDied;
    }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Awake()
    {
        controller           = GetComponent <LagueController2D>();
        playerInput          = GetComponent <PlayerInput>();
        cameraFollowCollider = GetComponent <BoxCollider2D>();
        animator             = GetComponent <Animator>();

        // See Sebastian Lague videos for explanations here.
        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
        maxJumpVelocity = -gravity * timeToJumpApex;

        state = new StateAirborne();
        state.OnStateEnter(this);
    }