Пример #1
0
    public void Duck()
    {
        if (controller.collisions.below && directionalInput.y == -1)
        {
            controller.CalculateRaySpacing();
            if (boxCollider.offset == Vector2.zero)
            {
                boxCollider.offset = boxCollider.offset + Vector2.down * colliderHeight / 4;
            }
            boxCollider.size    = new Vector2(boxCollider.size.x, colliderHeight * 0.5f);
            playerState.ducking = true;
            playerAnimation.Duck(playerState.ducking);
        }
        else if (controller.CeilingCheck() && !playerState.dashing)
        {
            controller.CalculateRaySpacing();
            if (boxCollider.offset != Vector2.zero)
            {
                boxCollider.offset = Vector2.zero;
            }

            boxCollider.size = new Vector2(boxCollider.size.x, colliderHeight);

            if ((directionalInput.y != -1) || (playerState.jumping) || !controller.collisions.below)
            {
                boxCollider.size    = new Vector2(boxCollider.size.x, colliderHeight);
                playerState.ducking = false;
                playerAnimation.Duck(playerState.ducking);
            }
        }
    }
Пример #2
0
    public void OnCarryInput()
    {
        if (!_controller.collisions.below)
        {
            return;
        }

        if (_touching && !_holding)
        {
            _originalSize   = _collider.size;
            _originalOffset = _collider.offset;

            _playerAnimator.Pickup(_touching);
            _holding = _touching;
            _holding.Pickup();
            var bounds = _collider.bounds;
            bounds.Encapsulate(_holding.Collider.bounds);
            ResizeCollider(bounds);
        }
        else if (_holding)
        {
            _playerAnimator.Putdown(_holding);
            _holding.PutDown();
            _holding         = null;
            _collider.offset = _originalOffset;
            _collider.size   = _originalSize;
            _controller.CalculateRaySpacing();
        }
    }
Пример #3
0
    private void HandleDuck()
    {
        //todo: change raycast amount
        float directionVertical = Input.GetAxisRaw("Vertical");

        if (directionVertical < -.5f || Input.GetKey(KeyCode.S))
        {
            animator.Play("crouch");
            ducking   = true;
            coll.size = new Vector2(
                coll.size.x,
                originalSize / 2f
                );
            coll.offset = new Vector2(
                0f,
                -1 * originalSize / 4f
                );
        }
        else
        {
            ducking   = false;
            coll.size = new Vector2(
                coll.size.x,
                originalSize
                );
            coll.offset = new Vector2(
                0f,
                0f
                );
        }

        controller.CalculateRaySpacing();
    }
Пример #4
0
    void Resize()
    {
        float   resizeValue  = .75f;
        Vector2 resizeVector = new Vector2(transform.localScale.x, transform.localScale.y - resizeValue);

        if (isScalingDown)
        {
            transform.localScale = resizeVector;
        }
        else
        {
            transform.localScale = originalSize;
        }

        playerController.CalculateRaySpacing();
        playerController.UpdateRaycastOrigins();
    }
Пример #5
0
    void UpdateCrouchState(Vector2 input, Vector3 velocity)
    {
        previousCrouchState = crouching;
        crouching           = (ropeAttached) ? false : (input.y < -0.5 && controller.collisions.below);

        // If player is uncrouching, check that there is room to.
        if (previousCrouchState && !crouching)
        {
            crouching = controller.CheckUncrouch(velocity * Time.deltaTime);
        }

        controller.SetCrouchCollisions(crouching);

        // // If crouch state changed, update raycast spacing
        if (previousCrouchState != crouching)
        {
            controller.CalculateRaySpacing();
        }
    }
Пример #6
0
    public void OnTransformationButtonClicked()
    {
        if (julia.CanTransform && juliett.CanTransform)
        {
            IsSmallForm             = !IsSmallForm;
            physicalCollider.size   = CurrentPlayerCharacter.PhysicalBounds.size;
            physicalCollider.offset = CurrentPlayerCharacter.PhysicalBounds.center;
            controller.CalculateRaySpacing();

            CurrentPlayerCharacter.IsActive = true;
            WaitingPlayerCharacter.IsActive = false;
            CurrentPlayerCharacter.OnTransformation(WaitingPlayerCharacter);

            PlayerTransformed(IsSmallForm);
            CanDoSpecialAction       = true;
            IsTransformationCoolTime = true;
            PlayTransformationEffects();
            soundEffects.PlayTransformationSound();
        }
        else
        {
            soundEffects.PlayTransformationDeniedSound();
        }
    }
Пример #7
0
    void FixedUpdate()
    {
        this.previousDirX = dirX;
        if (directionalInput.y == -1 && controller.collisions.below && !crouching)
        {
            controller.collider.size   = new Vector2(controller.collider.size.x, 1f);
            controller.collider.offset = new Vector2(controller.collider.offset.x, -0.5f);
            controller.UpdateRaycastOrigins();
            controller.CalculateRaySpacing();
            crouching = true;
        }
        else if (!controller.collisions.below || directionalInput.y != -1 && crouching && !tilemap.HasTile(mapGrid.WorldToCell(transform.position + 0.5f * new Vector3(1, 1, 0))))
        {
            controller.collider.size   = new Vector2(controller.collider.size.x, 2f);
            controller.collider.offset = new Vector2(controller.collider.offset.x, 0f);
            controller.UpdateRaycastOrigins();
            controller.CalculateRaySpacing();
            crouching = false;
        }

        CalculateVelocity();
        HandleWallSliding();

        if ((wallSliding || controller.collisions.grabLedge))
        {
            firePoint.transform.localPosition = firePointPositionWallSliding;
        }
        else if (crouching)
        {
            firePoint.transform.localPosition = firePointPositionCrouching;
        }
        else
        {
            if (directionalInput.x != 0 && directionalInput.y == 1)
            {
                firePoint.transform.localPosition = firePointPositionLookDiag;
            }
            else if (directionalInput.x == 0 && directionalInput.y == 1)
            {
                firePoint.transform.localPosition = firePointPositionLookTop;
            }
            else if (directionalInput.x == 0 && directionalInput.y == -1 && !controller.collisions.below)
            {
                firePoint.transform.localPosition = firePointPositionLookDown;
            }
            else
            {
                firePoint.transform.localPosition = firePointPositionStanding;
            }
        }

        if (controller.collisions.climbingLedge)
        {
            Vector2 pos = Vector2.LerpUnclamped(new Vector2(transform.position.x, transform.position.y), controller.collisions.ledgeFinalPos, moveSpeed / 2 * Time.fixedDeltaTime);
            transform.position = pos;
            Vector2 distance = controller.collisions.ledgeFinalPos - new Vector2(transform.position.x, transform.position.y);
            dirX = (int)Mathf.Sign(distance.x);
            if (distance.magnitude < 0.2f)
            {
                transform.position = controller.collisions.ledgeFinalPos;
                controller.collisions.climbingLedge = false;
                controller.collisions.grabLedge     = false;
                if (tilemap.HasTile(mapGrid.WorldToCell(transform.position + 0.5f * new Vector3(1, 1, 0))))
                {
                    controller.collider.size   = new Vector2(controller.collider.size.x, 1f);
                    controller.collider.offset = new Vector2(controller.collider.offset.x, -0.5f);
                    controller.UpdateRaycastOrigins();
                    controller.CalculateRaySpacing();
                    crouching = true;
                }
            }
        }

        if (controller.collisions.grabLedge)
        {
            velocity.y = 0;
        }
        if (controller.collisions.climbingLedge)
        {
            velocity.y = 0;
            velocity.x = 0;
        }

        if (directionalInput.x == -1)
        {
            dirX = -1;
        }
        else if (directionalInput.x == 1)
        {
            dirX = 1;
        }

        if (wallSliding && wallDirX == 1)
        {
            dirX = -1;
        }
        else if (wallSliding && wallDirX == -1)
        {
            dirX = 1;
        }

        GetComponent <SpriteRenderer>().flipX = dirX == -1;
        firePoint.transform.localPosition     = new Vector2(firePoint.transform.localPosition.x * dirX, firePoint.transform.localPosition.y);


        animator.SetBool("onGround", controller.collisions.below);
        animator.SetFloat("velX", Mathf.Abs(velocity.x));
        animator.SetFloat("velY", velocity.y);
        animator.SetBool("wallSliding", wallSliding);
        animator.SetBool("crouching", crouching);

        controller.Move(velocity * Time.deltaTime, directionalInput);

        if (controller.collisions.above || controller.collisions.below)
        {
            if (controller.collisions.slidingDownMaxSlope)
            {
                velocity.y += controller.collisions.slopeNormal.y * -gravity * Time.deltaTime;
            }
            else
            {
                velocity.y = 0;
            }
        }
    }
Пример #8
0
    // Update is called once per frame
    void Update()
    {
        //reset
        if (GlobalVars.resetTimer > 0)
        {
            resetPlayer();
        }
        if (!GlobalVars.paused)
        {
            //input
            if (Input.GetKey(KeyCode.A) && canMove)
            {
                input.x = -1;
            }
            else if (Input.GetKey(KeyCode.D) && canMove)
            {
                input.x = 1;
            }
            else if (!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D) && !buttonHeld)
            {
                input.x = 0;
            }
            if (!canMove)
            {
                input      = Vector2.zero;
                velocity.x = 0;
            }

            //wallSlide
            int wallDirX = (controller.collisions.left) ? -1 : 1;
            if (controller.collisions.left && input.x == -1 || controller.collisions.right && input.x == 1)
            {
                wallSlideOn = true;
            }
            if (Input.GetKeyDown(KeyCode.S) && disableWallSlideTimer <= 0)
            {
                disableWallSlideTimer = 0.5f;
            }
            if (disableWallSlideTimer > 0)
            {
                wallSlideOn = false;
            }
            if (disableWallSlideTimer > 0)
            {
                disableWallSlideTimer -= Time.deltaTime;
            }
            if ((controller.collisions.left || controller.collisions.right) && !controller.collisions.below && velocity.y <= jumpHeight && wallSlideOn)
            {
                if (wallSliding == false)
                {
                    maxVelocity.y = wallSlideSpeedMax;
                    wallSliding   = true;
                }
                if (slideTime > 0 && !Input.GetKeyDown(KeyCode.Space) && velocity.y < jumpHeight && !(input.x == 0 && Input.GetKeyDown(KeyCode.Space)))
                {
                    velocity.x = 0;
                    if (input.x != wallDirX && input.x != 0)
                    {
                        slideTime -= Time.deltaTime;
                    }
                    else
                    {
                        slideTime = maxSlideTime;
                    }
                    if (!myParticleSystem.isPlaying)
                    {
                        myParticleSystem.Play();
                    }
                }
                else
                {
                    slideTime = maxSlideTime;
                }
            }
            else
            {
                wallSliding   = false;
                maxVelocity.y = originalMaxVelocity.y;
            }
            if (wallSliding)
            {
                if (maxVelocity.y < originalMaxVelocity.y)
                {
                    maxVelocity.y = maxVelocity.y + 0.5f;
                }
            }

            //general movement
            if (!rolled)
            {
                velocity.x = Mathf.Clamp(velocity.x, -maxVelocity.x, maxVelocity.x);
            }
            velocity.y  = Mathf.Clamp(velocity.y, -maxVelocity.y, Mathf.Infinity);
            velocity.y += gravity * Time.deltaTime;
            //if (canMove)
            //{
            controller.Move(velocity * Time.deltaTime);
            //}`

            Vector3 distanceBetweenOldAndNewPos = transform.position - controller.collisions.positionOld;

            //collide with ground.
            if (controller.collisions.above || controller.collisions.below)
            {
                if (controller.collisions.below)
                {
                    wallSlideOn = false;
                }
                velocity.y = 0;
                if (velocity.y != 0)
                {
                    jumpTimer = 0;
                }
            }

            //collide with walls.
            if (controller.collisions.left && velocity.x < 0 && !controller.collisions.climbingSlope)
            {
                velocity.x = 0;
            }

            if (controller.collisions.right && velocity.x > 0 && !controller.collisions.climbingSlope)
            {
                velocity.x = 0;
            }

            //jump and WallJump

            if (Input.GetKeyDown(KeyCode.Space) && (controller.collisions.canJump || controller.collisions.below) && !controller.collisions.ceilingAbove && canMove)
            {
                velocity.y += jumpHeight;
                jumpTimer   = maxJumpTime;
            }

            if (Input.GetKeyDown(KeyCode.Space) && wallSliding && canMove)
            {
                if (velocity.y <= 6)
                {
                    if (wallDirX == input.x)
                    {
                        velocity.x = -wallDirX * wallJumpClimb.x;
                        velocity.y = wallJumpClimb.y;
                        if (input.x == 1)
                        {
                            myRenderer.flipX = false;
                        }
                        else
                        {
                            myRenderer.flipX = true;
                        }
                    }
                    else if (input.x == 0)
                    {
                        wallSlideOn = false;
                        velocity.x  = -wallDirX * wallJumpOff.x;
                        velocity.y  = wallJumpOff.y;
                    }
                    else
                    {
                        velocity.x = -wallDirX * wallLeap.x;
                        velocity.y = wallLeap.y;
                        if (input.x == -1)
                        {
                            myRenderer.flipX = true;
                        }
                        else
                        {
                            myRenderer.flipX = false;
                        }
                    }
                    //jumpTimer = maxJumpTime;
                }
            }

            if (Input.GetKey(KeyCode.Space) && !(controller.collisions.canJump || controller.collisions.below) && jumpTimer > 0 && !controller.collisions.above && velocity.y > 0 && !controller.collisions.ceilingAbove && canMove)
            {
                velocity.y += jumpHeight * 4 * Time.deltaTime;
                jumpTimer  -= Time.deltaTime;
            }

            if (jumpTimer == 0)
            {
                if (controller.collisions.above)
                {
                    velocity.y = 0;
                    //velocity.y -= jumpHeight;
                }
            }

            //left and right
            if (input.x == -1 && !rolled)
            {
                velocity.x -= moveSpeed * Time.deltaTime;
            }
            if (input.x == 1 && !rolled)
            {
                velocity.x += moveSpeed * Time.deltaTime;
            }

            if (input.x != -1 && input.x != 1 && velocity.x != 0)
            {
                velocity.x = Mathf.Lerp(velocity.x, 0f, Time.deltaTime * 5f);
            }

            //roll
            if (rollTimer > 0)
            {
                rollTimer -= Time.deltaTime;
            }
            //crouch
            if (Input.GetKey(KeyCode.S) && controller.collisions.below && canMove || controller.collisions.ceilingAbove && controller.collisions.below && canMove)
            {
                if (!rolled)
                {
                    controller.myCollider.transform.localScale    = newSize;
                    controller.myCollider.transform.localPosition = newPosition;
                    controller.UpdateRayCastOrigins();
                    controller.CalculateRaySpacing();
                    rolled = true;
                }
            }
            else if ((!Input.GetKey(KeyCode.S) || !controller.collisions.below) && !controller.collisions.ceilingAbove)
            {
                controller.myCollider.transform.localScale    = originalSize;
                controller.myCollider.transform.localPosition = originalPosition;
                controller.UpdateRayCastOrigins();
                controller.CalculateRaySpacing();
                rolled = false;
            }

            if (rolled)
            {
                velocity.x = Mathf.Clamp(velocity.x, -originalMaxVelocity.x / 2f, originalMaxVelocity.x / 2f);
                if (input.x == 1)
                {
                    velocity.x += (moveSpeed * 0.5f) * Time.deltaTime;
                }
                if (input.x == -1)
                {
                    velocity.x -= (moveSpeed * 0.5f) * Time.deltaTime;
                }
            }

            if (Input.GetKeyUp(KeyCode.S) || !controller.collisions.below)
            {
                rolled = false;
            }

            //sprint
            if (Input.GetKey(KeyCode.LeftShift))
            {
                maxVelocity.x = originalMaxVelocity.x * 1.25f;
            }
            else if (!Input.GetKey(KeyCode.LeftShift))
            {
                maxVelocity.x = originalMaxVelocity.x;
            }

            //Rotation
            if (!controller.collisions.below)
            {
                if (input.x == -1 && !controller.collisions.left)
                {
                    if (velocity.y >= 0)
                    {
                        myRotation.z += 0.45f;
                    }
                    if (velocity.y < 0)
                    {
                        myRotation.z -= 0.35f;
                        myRotation.z  = Mathf.Clamp(myRotation.z, -5f, 5f);
                    }
                }
                if (input.x == 1 && !controller.collisions.right)
                {
                    if (velocity.y >= 0)
                    {
                        myRotation.z -= 0.45f;
                    }
                    if (velocity.y < 0)
                    {
                        myRotation.z += 0.35f;
                        myRotation.z  = Mathf.Clamp(myRotation.z, -5f, 5f);
                    }
                }
                if (input.x == -1 && controller.collisions.right)
                {
                    myRotation.z += 0.75f;
                }
                if (input.x == 1 && controller.collisions.left)
                {
                    myRotation.z -= 0.75f;
                }
                if (input.x == 0 || (controller.collisions.left && input.x == -1 || controller.collisions.right && input.x == 1))
                {
                    myRotation.z = Mathf.Lerp(myRotation.z, 0f, Time.deltaTime * 4f);
                }
                //animationGameObject.eulerAngles = Vector3.Lerp(animationGameObject.eulerAngles, new Vector3(0, 0, controller.collisions.slopeAngle), Time.deltaTime*2f);
            }
            else
            {
                myRotation = Vector3.zero;
            }

            myRotation.z = Mathf.Clamp(myRotation.z, -8f, 8f);
            animationGameObject.eulerAngles = myRotation;
            //particleSystemShape
            ParticleSystem.ShapeModule shape = myParticleSystem.shape;
            //animations
            if (rolled || controller.collisions.ceilingAbove && controller.collisions.below)
            {
                myAnimator.SetBool("ducked", true);
            }
            else if (!rolled && !controller.collisions.ceilingAbove)
            {
                myAnimator.SetBool("ducked", false);
            }
            if (theWomb == null)
            {
                myAnimator.SetBool("born", true);
            }
            if (wallSliding && wallSlideOn)
            {
                if (wallDirX == 1 && !myRenderer.flipX || wallDirX == -1 && myRenderer.flipX)
                {
                    myAnimator.SetBool("rightWallGrab", true);
                    myAnimator.SetBool("leftWallGrab", false);
                    if (Mathf.Abs(velocity.y) > 6)
                    {
                        shape.box = new Vector3(0.5f, 1f, shape.box.z);
                        myParticleSystem.Play();
                    }
                }
                else if (wallDirX == 1 && myRenderer.flipX || wallDirX == -1 && !myRenderer.flipX)
                {
                    myAnimator.SetBool("leftWallGrab", true);
                    myAnimator.SetBool("rightWallGrab", false);
                    if (Mathf.Abs(velocity.y) > 6)
                    {
                        shape.box = new Vector3(0.5f, 1f, shape.box.z);
                        myParticleSystem.Play();
                    }
                }
            }
            else
            {
                myAnimator.SetBool("rightWallGrab", false);
                myAnimator.SetBool("leftWallGrab", false);
            }
            if (Mathf.Abs(velocity.x) > 2 && canMove)
            {
                if (myAnimator.GetBool("running") == false && controller.collisions.canJump && !controller.collisions.left && !controller.collisions.right)
                {
                    myAnimator.SetBool("running", true);
                }
                if (velocity.x < 0)
                {
                    if (controller.collisions.below)
                    {
                        myRenderer.flipX = true;
                    }
                }
                else
                {
                    if (controller.collisions.below)
                    {
                        myRenderer.flipX = false;
                    }
                }
            }
            if (Mathf.Abs(velocity.x) < 2 && controller.collisions.canJump)
            {
                if (myAnimator.GetBool("running") == true)
                {
                    //particleSystem.maxParticles = 25;
                    myAnimator.SetBool("running", false);
                }
            }

            if (!controller.collisions.above && (controller.collisions.canJump || controller.collisions.below) && velocity.y <= 0)
            {
                if (myAnimator.GetBool("grounded") == false)
                {
                    if (myParticleSystem != null)
                    {
                        shape.box = new Vector3(1f, 0.5f, shape.box.z);
                        myParticleSystem.maxParticles = 25;
                        myParticleSystem.Play();
                    }
                    myAnimator.SetBool("grounded", true);
                }
                if (myAnimator.GetCurrentAnimatorStateInfo(0).IsName("land") && myAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1)
                {
                    myAnimator.SetBool("landed", false);
                }
                if (myAnimator.GetCurrentAnimatorStateInfo(0).IsName("runland") && myAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1)
                {
                    myAnimator.SetBool("runlanded", false);
                }
                if (myAnimator.GetBool("falling") == true && myAnimator.GetBool("grounded") == true)
                {
                    myAnimator.SetBool("landed", true);
                    myAnimator.SetBool("runlanded", true);
                    myAnimator.SetBool("falling", false);
                }
            }
            else if (!controller.collisions.canJump && !controller.collisions.below)
            {
                if (myAnimator.GetBool("grounded") == true)
                {
                    myAnimator.SetBool("grounded", false);
                    myAnimator.SetBool("landed", false);
                    myAnimator.SetBool("runlanded", false);
                }
                if (velocity.y < -2)
                {
                    if (myAnimator.GetBool("falling") == false)
                    {
                        myAnimator.SetBool("falling", true);
                    }
                }
                if (velocity.y > 0)
                {
                    if (myAnimator.GetBool("falling") == true)
                    {
                        myAnimator.SetBool("falling", false);
                    }
                }
            }
        }
    }
Пример #9
0
    /*
     * 0 -  just the head
     * 1 - head and torso
     * 2 - head torso and one arm
     * 3 - head torso and both arms
     * 4 - head torso, both arms and one leg
     * 5 - full body
     * 6 - head, torso and one leg
     * 7 - head, torso and both legs
     * 8 - head, torso, leg and one arm
     * 9 - head, torso, arm and two legs
     */

    private void handleBodyCollisions()
    {
        //Debug.Log(myTarget.name);

        if (this.tag.Equals("leg") || this.tag.Equals("arm"))
        {
            return;
        }

        if (state == 1 || state == 2 || state == 3)
        {
            canBump1 = true;
        }
        if (state == 1)
        {
            canBump2 = true;
        }

        if (myAnimator.GetInteger("state") == 0)
        {
            Vector3 temp1 = new Vector3(0f, 0, 0);

            changeBoxCollider(2.2f, 2.1f, 0f, 1f);
            myController.CalculateRaySpacing();
            needMove      = false;
            raycastOffset = 1f;
        }
        else if (myAnimator.GetInteger("state") == 1)
        {
            changeBoxCollider(2.2f, 3.32f, -0.09f, 1.49f);
            myController.CalculateRaySpacing();
            needMove      = true;
            raycastOffset = 2f;
        }
        else if (myAnimator.GetInteger("state") == 2)
        {
            Vector3 temp1 = new Vector3(1.25f, 0, 0);

            if (canBump2)
            {
                Vector3 temp = new Vector3(0, 1f, 0);
                gameObject.transform.position += temp;
                canBump2 = false;
            }
            changeBoxCollider(3.45f, 2.27f, 0.48f, 0.07f);
            myController.CalculateRaySpacing();
            raycastOffset = 1f;
        }
        else if (myAnimator.GetInteger("state") == 3)
        {
            Vector3 temp1 = new Vector3(1.25f, 0, 0);

            if (isClimbing)
            {
                changeBoxCollider(3.45f, 2.27f, 0.48f, 0.07f);
                myController.CalculateRaySpacing();
            }
            else
            {
                changeBoxCollider(3.45f, 2.27f, 0.48f, 0.07f);
                myController.CalculateRaySpacing();
            }
            raycastOffset = 1f;
        }
        else if (myAnimator.GetInteger("state") == 4)
        {
            if (canBump1)
            {
                Vector3 temp = new Vector3(0, 1.4f, 0);
                gameObject.transform.position += temp;
                canBump1 = false;
            }
            if (isClimbing)
            {
                changeBoxCollider(1.43f, 3.64f, 0.17f, 0f);
                myController.CalculateRaySpacing();
            }
            else
            {
                changeBoxCollider(2.22f, 4.25f, -0.08f, 0f);
                myController.CalculateRaySpacing();
            }
            raycastOffset = 2f;
        }
        else if (myAnimator.GetInteger("state") == 5)
        {
            if (isClimbing)
            {
                changeBoxCollider(1.43f, 3.64f, 0.17f, 0f);
                myController.CalculateRaySpacing();
            }
            else
            {
                changeBoxCollider(2.22f, 4.25f, -0.08f, 0f);
                myController.CalculateRaySpacing();
            }
            raycastOffset = 2f;
        }
        else if (myAnimator.GetInteger("state") == 6)
        {
            if (canBump1)
            {
                Vector3 temp = new Vector3(0, 2f, 0);
                gameObject.transform.position += temp;
                canBump1 = false;
            }
            changeBoxCollider(2.22f, 4.25f, -0.09f, 0f);
            myController.CalculateRaySpacing();
            raycastOffset = 2f;
        }
        else if (myAnimator.GetInteger("state") == 7)
        {
            changeBoxCollider(2.22f, 4.25f, -0.08f, 0f);
            myController.CalculateRaySpacing();
            raycastOffset = 2f;
        }
        else if (myAnimator.GetInteger("state") == 8)
        {
            if (canBump1)
            {
                Vector3 temp = new Vector3(0, 2f, 0);
                gameObject.transform.position += temp;
                canBump1 = false;
            }
            changeBoxCollider(2.22f, 4.25f, -0.08f, 0f);
            myController.CalculateRaySpacing();
            raycastOffset = 2f;
        }
        else if (myAnimator.GetInteger("state") == 9)
        {
            changeBoxCollider(2.22f, 4.25f, -0.08f, 0f);
            myController.CalculateRaySpacing();
            raycastOffset = 2f;
        }
    }
Пример #10
0
 //force recheck of character ray casting
 //NOTE:added this so when chrouches, rays changes with him
 void ReCheck()
 {
     controller.UpdateRaycastOrigins();
     controller.CalculateRaySpacing();
 }