예제 #1
0
    void CalculateMoveDirection()
    {
        MoveDirection = new Vector3(0.0f, MoveDirection.y, 0.0f);

        // Walk.
        Vector3 dir = new Vector3(MyInput.GetAxis("Horizontal"), 0.0f, MyInput.GetAxis("Vertical"));

        dir   = m_target.transform.TransformDirection(dir);
        dir.y = 0.0f;

        if (MyInput.GetButton("Sprint"))
        {
            dir *= m_runSpeed;
        }
        else
        {
            dir *= m_walkSpeed;
        }

        MoveDirection += dir;

        // Jump.
        if (m_target.isGrounded && MyInput.GetButtonDown("Jump"))
        {
            ChangeState(new FPSCharacterStateJump());
        }

        // Character controller don't have gravity support, so apply it here.
        MoveDirection = new Vector3(
            MoveDirection.x,
            MoveDirection.y - m_jumpSpeed * Time.deltaTime,
            MoveDirection.z
            );
    }
예제 #2
0
    public void PUpdate()
    {
        // WASDの入力
        float h = MyInput.GetAxis("Horizontal");
        float v = MyInput.GetAxis("Vertical");
        // Shiftの入力でスピードを変更
        float s = speed * (1 + MyInput.GetAxis("Dash"));
        // 移動方向の計算 単位ベクトル化
        Vector3 dir = Vector3.Normalize(transform.forward * v + transform.right * h);

        // コントローラーで移動
        controller.SimpleMove(dir * s);

        // マウス感度の調整
        float m = mouseSensi * 0.05f;
        // マイスの移動量か矢印キーの入力を取得
        float mX = MyInput.GetAxis("Mouse X") * m
                   + MyInput.GetAxis("LeftRight") * m * 400f * Time.deltaTime;
        float mY = MyInput.GetAxis("Mouse Y") * m
                   + MyInput.GetAxis("UpDown") * m * 400f * Time.deltaTime;

        // 体や首を回転
        rot = new Vector3(Mathf.Clamp(rot.x - mY, -80, 80), rot.y + mX, 0f);
        transform.eulerAngles = new Vector3(0, rot.y, 0);
        neck.localEulerAngles = new Vector3(rot.x, 0, 0);
    }
    private void Update()
    {
        if (GameManager.instance.input_active && player.can_input)
        {
            if (MyInput.GetButton("Attack"))
            {
                bool skill_used = ProcessSkillButton(MyInput.GetAxis("Attack"), 0);
                if (skill_used)
                {
                    MyInput.ClearBuffer("Attack");
                }
            }
            if (MyInput.GetButtonDown("Skill1", skill_buffer))
            {
                bool skill_used = ProcessSkillButton(MyInput.GetAxis("Skill1"), 1);
                if (skill_used)
                {
                    MyInput.ClearBuffer("Skill1");
                }
            }
            if (MyInput.GetButtonDown("Skill2", skill_buffer))
            {
                bool skill_used = ProcessSkillButton(MyInput.GetAxis("Skill2"), 2);
                if (skill_used)
                {
                    MyInput.ClearBuffer("Skill2");
                }
            }
            if (MyInput.GetButtonDown("Skill3"))
            {
                bool skill_used = ProcessSkillButton(MyInput.GetAxis("Skill3"), 3);
                if (skill_used)
                {
                    MyInput.ClearBuffer("Skill3");
                }
            }
            if (MyInput.GetButtonDown("ActiveSkill"))
            {
                if (player.inventory.active_item != null)
                {
                    player.inventory.active_item.active_ability.TryUse();
                }
            }
            if (MyInput.GetButtonDown("UseConsumable"))
            {
                player.inventory.TryUseConsumable();
            }
        }

        input = new Vector2(MyInput.GetAxis("Horizontal"), MyInput.GetAxis("Vertical"));
        Move();
    }
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        if (isLocalPlayer)
        {
            MovementDirection =
                MyInput.GetAxis("Horizontal") * m_screenMovementRight +
                MyInput.GetAxis("Vertical") * m_screenMovementForward;

            m_playerMovementPlane.normal = transform.up;
            //Debug.Log("transform.position.y = " + transform.position.y);
            m_playerMovementPlane.distance = -transform.position.y + m_cursorPlaneHeight;

            HandleCameraMovement();
        }

        UpdateAnimator();
    }
        protected override void Update()
        {
            this.normalSpeed = this.basenormalSpeed * RCM.Cheat.SpeedMultiplier;
            this.sprintSpeed = this.basesprintSpeed * RCM.Cheat.SpeedMultiplier;
            this.swimSpeed   = this.baseswimSpeed * RCM.Cheat.SpeedMultiplier;


            if (RCM.Cheat.FlyMode)
            {
                this.gravity        = 0f;
                this.controllerType = ControllerType.Ground;

                bool button  = MyInput.GetButton("LeftControl");
                bool sprint  = MyInput.GetButton("Sprint");
                bool button2 = MyInput.GetButton("Jump");

                float updown = 0f;
                if (button2)
                {
                    updown = 1f;
                }
                if (button)
                {
                    updown = -1f;
                }

                Vector3 lhs = new Vector3(MyInput.GetAxis("Strafe"), updown, MyInput.GetAxis("Walk"));
                this.moveDirection  = base.transform.right * lhs.x + base.transform.up * lhs.y + base.transform.forward * lhs.z;
                this.moveDirection *= sprint ? sprintSpeed : normalSpeed;
                this.controller.Move(moveDirection * Time.deltaTime);

                LastFlyMode = true;
                return;
            }
            else
            {
                base.Update();
            }
            if (LastFlyMode)
            {
                this.gravity = this.basegravity;
                LastFlyMode  = false;
            }
        }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        // Get mouse movement.
        float xMouse = MyInput.GetAxis("Mouse X");
        float yMouse = MyInput.GetAxis("Mouse Y");

        // Update pitch and yaw angle.
        m_pitchAngle -= yMouse * m_sensitivity;
        m_yawAngle   += xMouse * m_sensitivity;

        m_pitchAngle = Mathf.Clamp(m_pitchAngle, -m_minPitchAngle, m_maxPitchAngle);

        // Rotate to new angle.
        Quaternion rot = Quaternion.Euler(m_pitchAngle, m_yawAngle, 0.0f);
        float      t   = FPSConstants.MAX_FPS * Time.deltaTime / (m_smoothness + 1.0f);

        //m_target.localRotation = Quaternion.Lerp (m_target.localRotation, rot, t);
        m_target.localRotation = Quaternion.Slerp(m_target.localRotation, rot, t);
    }