示例#1
0
    }//FixedUpdate

    public virtual void Update()
    {
        Vector2 deltaMovement = MvmntCmp.Velocity;

        HandleMovingPlatform(ref deltaMovement);
        HandleMovement(ref deltaMovement);
        DropthroughCmp.Check();

        if (CollisionDetectionCmp.Left || CollisionDetectionCmp.Right)
        {
            MvmntCmp.ResetPushForce();
        }

        HandleVelocity(ref deltaMovement);
        MvmntCmp.SetVelocity(deltaMovement);

        if (this.IsGrounded && !prevGroundState && !DropthroughCmp.IsDropping)
        {
            IsLanded = true;
            this.EOnLanded?.Invoke();
        }//if landed

        if (prevGroundState != this.IsGrounded)
        {
            this.EOnGroundStateChange?.Invoke(this.prevGroundState, this.IsGrounded);
            this.prevGroundState = this.IsGrounded;
        }
    }//Update
示例#2
0
    }//Start


    /// <summary>
    ///  Cast ground rays to set IsGrounded flag.
    /// </summary>
    public override void FixedUpdate() {
        DropthroughCmp.SetCanDropthrough(!_ladderClimber.IsOnLadder);
        if (!SpriteRendererCmp.enabled)
            return;
        base.FixedUpdate();
        if (!IsCanControl) {
            return;
        }
    }//FixedUpdate