Exemple #1
0
    public void FixedUpdate()
    {
        DebugDisplay.PrintLine($"Rise: {PlayerConstants.JUMP_RISE_GRAVITY}");
        DebugDisplay.PrintLine($"Fall: {PlayerConstants.FREE_FALL_GRAVITY}");

        // Many states use collision status(eg: are we touching the ground?)
        // to decide if they should change to a different state.
        // We need to update this information before
        Motor.UpdateCollisionStatus();

        // Run state logic that needs to be done early.
        // Usually, this is where state transitions happen.
        _currentState.EarlyFixedUpdate();

        // Run the current state's main logic.
        // Note that CurrentState may have been changed by EarlyFixedUpdate()
        _currentState.FixedUpdate();

        // Tell the motor to move at its current velocity.
        Motor.Move();

        // Display debugging metrics
        DebugDisplay.PrintLine("HSpeed: " + HSpeed);
        DebugDisplay.PrintLine("VSpeed: " + Motor.RelativeVSpeed);
        DebugDisplay.PrintLine("HAngleDeg: " + HAngleDeg);
        DebugDisplay.PrintLine("Double jump armed: " + DoubleJumpArmed);
        DebugDisplay.PrintLine("In double jump window: " + IsInDoubleJumpWindow());
        DebugDisplay.PrintLine("Jump height: " + (_debugJumpMaxY - LastJumpStartPos.y));
    }
    void Update()
    {
        DebugDisplay.PrintLine(_input.RightStick.ToString());

        // Adjust the angles with the right stick
        Vector3 rightStick = _input.RightStick;

        if (INVERT_HORIZONTAL)
        {
            rightStick.x *= -1;
        }
        if (INVERT_VERTICAL)
        {
            rightStick.y *= -1;
        }

        _hAngleDeg += rightStick.x * MAX_ROTSPEED_DEG * Time.deltaTime;
        _vAngleDeg += rightStick.y * MAX_ROTSPEED_DEG * Time.deltaTime;

        if (_vAngleDeg > MAX_VANGLE_DEG)
        {
            _vAngleDeg = MAX_VANGLE_DEG;
        }

        if (_vAngleDeg < MIN_VANGLE_DEG)
        {
            _vAngleDeg = MIN_VANGLE_DEG;
        }

        // Calculate the where the position would be (if we didn't zoom)
        Vector3 dir = SphericalToCartesian(_hAngleDeg, _vAngleDeg, 1);
        Vector3 pos = _target.position + (dir * ORBIT_RADIUS);

        // Zoom in if the view is obstructed
        float targetZoomDistance = GetZoomDistance(
            pos,
            _target.position,
            _target.position + (Vector3.up * PlayerConstants.BODY_HEIGHT)
            );

        float zoomSpeed = targetZoomDistance < _zoomDistance
            ? ZOOM_IN_SPEED
            : ZOOM_OUT_SPEED;

        _zoomDistance = Mathf.MoveTowards(
            _zoomDistance,
            targetZoomDistance,
            zoomSpeed * Time.deltaTime
            );

        pos = _target.position + (_zoomDistance * dir);

        // Jump to the position and look at the thing
        transform.position = pos;
        transform.LookAt(_target);
    }
    void Update()
    {
        DebugDisplay.PrintLine("Delta time: " + (Time.time / Time.frameCount));
        DebugDisplay.PrintLine("Animation speed: " + _animator.speed);
        _model.rotation = TweenUtils.DecayTowards(
            _model.rotation,
            GetTargetRot(),
            TWEEN_HALF_LIFE,
            Time.deltaTime
        );

        UpdateBones();
    }
Exemple #4
0
    public void Update()
    {
        if (Input.JumpPressed)
        {
            LastJumpButtonPressTime = Time.time;
        }

        if (Input.AttackPressed)
        {
            LastAttackButtonPressTime = Time.time;
        }

        // Let the animator know our rotation
        Anim.HAngleDeg = HAngleDeg;

        // DEV CHEAT: slow down time with a button
        DebugDisplay.PrintLine("CheatSlowTime: " + UnityEngine.Input.GetAxisRaw("CheatSlowTime"));
        Time.timeScale = Input.CheatSlowTimeHeld
            ? 0.25f
            : 1;
    }