Пример #1
0
        private float MapZoom(float target)
        {
            float inaxis  = KS_Input.GetAxis("mapMoveIn");
            float outaxis = KS_Input.GetAxis("mapMoveOut");

            if (inaxis > 0f)
            {
                target += ZoomSpeed;
            }

            if (outaxis > 0f)
            {
                target -= ZoomSpeed;
            }


            if (target < minCameraHeight)
            {
                target = minCameraHeight;
            }
            if (target > maxCameraHeight)
            {
                target = maxCameraHeight;
            }

            return(target);
        }
Пример #2
0
        private Vector3 MapMovement(Vector3 target)
        {
            target += Vector3.left * (KS_Input.GetAxis("mapMoveX") * (mapMoveSpeed * MoveSpeed));
            target += Vector3.forward * (KS_Input.GetAxis("mapMoveY") * (mapMoveSpeed * MoveSpeed));

            return(target);
        }
        // Update is called once per frame
        private void FixedUpdate()
        {
            if (Manager.State != KS_Manager.GameState.Playing)
            {
                return;
            }


            MoveCamera(KS_Input.GetAxis("View Horizontal"), KS_Input.GetAxis("View Vertical"));
            MovePlayer(KS_Input.GetAxis("Move Horizontal"), KS_Input.GetAxis("Move Vertical"));

            currentVelocity = Vector3.Slerp(currentVelocity, targetVelocity, Time.deltaTime * movementSmooth);

            rb.AddRelativeForce(targetVelocity, ForceMode.Force);

            if (IsGrounded() || IsSwimming)
            {
                rb.drag = 2.5f;
            }
            else
            {
                rb.drag = 1;
            }

            if (KS_Input.GetInputDown("jump"))
            {
                if ((IsGrounded() || IsSwimming))
                {
                    Jump();
                }
            }

            if (KS_Input.GetInputDown("crouch"))
            {
                Crouch();
            }

            if (KS_Input.GetInputDown("run"))
            {
                print("Running");
                running = true;
            }

            if (KS_Input.GetInputUp("run"))
            {
                print("walking");
                running = false;
            }

            raycastInteractable();
        }