Exemple #1
0
        void Update()
        {
            if (PauseController.isPaused || OutcomeController.instance.outcomeReached)
            {
                return;
            }

            targetDirection.Set(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), 0);
            targetDirection.Normalize();
            if (targetDirection.magnitude != 0)
            {
                voluntaryMoveDirection = targetDirection;
            }

            rb.AddForce(targetDirection * accelerationMagnitude * ((Vector2.up * controlFactor.y) + (Vector2.right * controlFactor.x)));

            if (rb.velocity.sqrMagnitude > topSpeed * topSpeed && constrainVelocity)
            {
                rb.velocity = Vector3.MoveTowards(rb.velocity, rb.velocity.normalized * topSpeed, (topSpeed / timeToResetSpeed) * Time.deltaTime);
            }

            ManageWeapon();
            ManagePower();

            Vector3 mouseDirection = (cam.MousePositionFromPlayerPOV() - transform.position).normalized;

            targetorAxis.transform.right = mouseDirection;
        }