コード例 #1
0
        /// <summary>
        /// Do Euler physics each tick
        /// </summary>
        void Update()
        {
            if (Time.deltaTime > 0.25f)
            {
                return;                             // quit early, do nothing, if lag spike
            }
            anim.SetBool("isGrounded", isGrounded); // communicates to animation controller whether or not the payer isGrounded
            anim.SetBool("isIdle", isIdle);         // communicates to animation controller whether or not the payer isIdle

            CalcHorizontalMovement();               // Runs HorizontalMovement method
            CalcVerticalMovement();                 // Runs VerticalMovement method

            // Applies velocity to position
            transform.position += velocity * Time.deltaTime;

            aabb.RecalcAABB();
            isGrounded = false;                                  // sets isGrounded to false every frame

            if (playerLocation.position.x < cam.position.x - 14) // If the player is off the left edge of the screen they die
            {
                // Had trouble calling this function from HealthSystem so recreated it here
                Destroy(gameObject);                                     // Kills the player if they end up off the left edge of the screen
                SoundEffectBoard.PlayDie();                              // plays death audio
            }
            else if (playerLocation.position.x > cam.position.x + 12.5f) // If the player is touching the right edge of the screen restrict their movement
            {
                velocity.x = 0;                                          // Player can no longer move right if touching the right edge of the screen
            }
        }
コード例 #2
0
        /// <summary>
        /// Do Euler physics each tick
        /// </summary>
        void Update()
        {
            CalcHorizontalMovement();
            CalcVerticalMovement();

            // Applies velocity to position
            transform.position += velocity * Time.deltaTime;
            isGrounded          = false;

            aabb.RecalcAABB();
        }
コード例 #3
0
        /// <summary>
        /// Do Euler physics each tick
        /// </summary>
        void Update()
        {
            if (Time.deltaTime > 0.25f)
            {
                return;                         // quit early, do nothing, if lag spike
            }
            CalcHorizontalMovement();
            CalcVerticalMovement();

            // Applies velocity to position
            transform.position += velocity * Time.deltaTime;
            isGrounded          = false;

            aabb.RecalcAABB();
        }