예제 #1
0
    private void FixedUpdate()
    {
        // Measure movement since last frame
        Vector2 deltaPos           = (Vector2)transform.position - previousPosition;
        float   horizontalDeltaPos = Mathf.Abs(deltaPos.x);

        OnPlayerMovement?.Invoke(horizontalDeltaPos);
        previousPosition = transform.position;

        // Move player
        controller.Move(horizontalMove * Time.fixedDeltaTime, false, jump);
        jump = false;
    }
예제 #2
0
    IEnumerator actuallyInstantiateAndInherit(DeadBody DB)
    {
        yield return(new WaitForSeconds(2.8f));

        GameObject child = DB.getAlive();
        //GSGOnPlayerMovement GSGOPM = child.GetComponent<GSGOnPlayerMovement>();
        //this.GetComponent<PlayerMovement>().moveSpeed = GSGOPM.speed;

        OnPlayerMovement OPM = child.GetComponent <OnPlayerMovement>();

        this.GetComponent <PlayerMovement>().moveSpeed = OPM.getSpeed() + 2;

        this.GetComponent <SpellManager>().spell = child.GetComponent <Spells>();
        CanInherit = true;
        this.tag   = "Player";
    }
예제 #3
0
        private void SetAnimatorValues()
        {
            _movement.x = Input.GetAxisRaw("Horizontal");
            _movement.y = Input.GetAxisRaw("Vertical");

            if (Input.GetAxisRaw("Horizontal") > 0.5f || Input.GetAxisRaw("Horizontal") < -0.5f)
            {
                _lastMovement = new Vector2(Input.GetAxisRaw("Horizontal"), 0f);
                OnPlayerMovement?.Invoke(true);
            }
            if (Input.GetAxisRaw("Vertical") > 0.5f || Input.GetAxisRaw("Vertical") < -0.5f)
            {
                _lastMovement = new Vector2(0f, Input.GetAxisRaw("Vertical"));
                OnPlayerMovement?.Invoke(true);
            }

            animator.SetFloat(Speed, _movement.sqrMagnitude);
            animator.SetFloat(Horizontal, _movement.x);
            animator.SetFloat(Vertical, _movement.y);
            animator.SetFloat(LastHorizontal, _lastMovement.x);
            animator.SetFloat(LastVertical, _lastMovement.y);
        }