コード例 #1
0
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
                x = XCI.GetAxis(XboxAxis.LeftStickX),
                y = XCI.GetAxis(XboxAxis.LeftStickY)
            };

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #2
0
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
                x = CrossPlatformInputManager.GetAxis("Horizontal"),
                y = CrossPlatformInputManager.GetAxis("Vertical")
            };

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #3
0
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
                x = Input.GetAxisRaw("Horizontal"),
                y = Input.GetAxisRaw("Vertical")
            };

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #4
0
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
                x = heroInput.GetKey(KeyCode.A) && canMove ? -1 : (heroInput.GetKey(KeyCode.D) && canMove  ? 1 : 0),
                y = heroInput.GetKey(KeyCode.S) && canMove  ? -1 : (heroInput.GetKey(KeyCode.W) && canMove  ? 1 : 0)
            };

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
                x = RunAxis.x,
                y = RunAxis.y
            };

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #6
0
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
                x = movementHorizontal /*Input.GetAxis("Horizontal")*/,
                y = movementVertical/*Input.GetAxis("Vertical")*/
            };

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #7
0
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
                //x = CrossPlatformInputManager.GetAxis("Horizontal"),
                //y = CrossPlatformInputManager.GetAxis("Vertical")
                x = Input.GetAxis("Horizontal"),                         //Michael Melatti comment out and make my own input.
                y = Input.GetAxis("Vertical")
            };

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #8
0
        private Vector2 GetInput()
        {
            if (GameManager.Instance.IsPlaying && !GameManager.Instance.IsPaused)
            {
                Vector2 input = new Vector2
                {
                    x = Input.GetAxis("Horizontal"),
                    y = Input.GetAxis("Vertical")
                };
                movementSettings.UpdateDesiredTargetSpeed(input);
                return(input);
            }

            return(Vector2.zero);
        }
コード例 #9
0
        private Vector2 GetInput()
        {
            // Disable strafing
            Vector2 input = new Vector2
            {
                x = CrossPlatformInputManager.GetAxis("Horizontal"),
                y = CrossPlatformInputManager.GetAxis("Vertical")
            };

            if (movementSettings.UseKeysForRotation)
            {
                input.x = 0;
            }
            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #10
0
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
                x = CrossPlatformInputManager.GetAxis("Mouse X"),
                y = CrossPlatformInputManager.GetAxis("Mouse Y")
            };

//			if(input.x > 0f)
//			{
//				input.x = 0f;
//			}

            movementSettings.UpdateDesiredTargetSpeed(input);

            return(input);
        }
        private Vector2 GetInput()
        {
            Vector2 input;

            if (advancedSettings.StrikeMouvement)
            {
                input = Vector2.zero;
            }
            else
            {
                input = new Vector2 {
                    x = CrossPlatformInputManager.GetAxis("Horizontal"),
                    y = CrossPlatformInputManager.GetAxis("Vertical")
                };
                movementSettings.UpdateDesiredTargetSpeed(input);
            }
            return(input);
        }
コード例 #12
0
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
#if UNITY_ANDROID
                x = dirX,
                y = dirY
#endif
#if UNITY_STANDALONE_WIN
                x = CrossPlatformInputManager.GetAxis("Horizontal"),
                y = CrossPlatformInputManager.GetAxis("Vertical")
#endif
            };

            //dirX = 0;
            //dirY = 0;
            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #13
0
        private Vector2 GetInput()
        {
            float tempX;
            float tempY;

            if (Input.GetKey(currentInput[0]))
            {
                tempY = 1;
            }
            else
            if (Input.GetKey(currentInput[2]))
            {
                tempY = -1;
            }
            else
            {
                tempY = 0;
            }
            if (Input.GetKey(currentInput[1]))
            {
                tempX = -1;
            }
            else
            if (Input.GetKey(currentInput[3]))
            {
                tempX = 1;
            }
            else
            {
                tempX = 0;
            }

            Vector2 input = new Vector2
            {
                x = tempX,
                y = tempY
                    //x = CrossPlatformInputManager.GetAxis("Horizontal"),
                    //y = CrossPlatformInputManager.GetAxis("Vertical")
            };

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #14
0
        private Vector2 GetInput()
        {
            Vector2 input;

            if (!PlayerScript.beStill && !PlayerScript.inBoat)
            {
                input = new Vector2
                {
                    x = CrossPlatformInputManager.GetAxis("Horizontal"),
                    y = CrossPlatformInputManager.GetAxis("Vertical")
                };
            }
            else
            {
                input = new Vector2(0, 0);
            }
            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #15
0
        private Vector2 GetInput()
        {
            if (!allowMovement)
            {
                return(Vector2.zero);
            }

            Vector2 input = new Vector2
            {
                x = CrossPlatformInputManager.GetAxis("Horizontal"),
                y = CrossPlatformInputManager.GetAxis("Vertical")
            };

            if (Input.GetMouseButton(1))
            {
                input.y = 1;
            }
            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #16
0
        private Vector2 GetInput()
        {
            Vector2 input;

            // Sabotaged to make auto-run
            if (movementSettings.isAutoRun)
            {
                input = Vector2.up;
            }
            else
            {
                input = Vector2.zero;
//				input = new Vector2
//				{
//					x = CrossPlatformInputManager.GetAxis ("Horizontal"),
//					y = CrossPlatformInputManager.GetAxis ("Vertical")
//				};
            }
            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #17
0
        private Vector2 GetInput()
        {
            Vector2 input;

            if (name == "Player1")
            {
                input = new Vector2 {
                    x = CrossPlatformInputManager.GetAxis("Horizontal"),
                    y = CrossPlatformInputManager.GetAxis("Vertical")
                };
            }
            else
            {
                input = new Vector2
                {
                    x = CrossPlatformInputManager.GetAxis("HorizontalJoy"),
                    y = CrossPlatformInputManager.GetAxis("VerticalJoy")
                };
            }
            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #18
0
        private Vector2 GetInput()
        {
            if (hfConfig.controllerInput.GetSensorValue(hfConfig.moveForward) > 800)
            {
                verticalInputValue = 1f;
            }
            else if (hfConfig.controllerInput.GetSensorValue(hfConfig.moveBackward) > 800)
            {
                verticalInputValue = -1f;
            }
            else
            {
                verticalInputValue = 0f;
            }

            if (hfConfig.controllerInput.GetSensorValue(hfConfig.moveLeft) > 800)
            {
                horizontalInputValue = -1f;
            }
            else if (hfConfig.controllerInput.GetSensorValue(hfConfig.moveRight) > 800)
            {
                horizontalInputValue = 1f;
            }
            else
            {
                horizontalInputValue = 0f;
            }

            Vector2 input = new Vector2
            {
                x = horizontalInputValue,
                y = verticalInputValue
            };


            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2(0, 0);

            if (this.gameObject.tag == "Player")
            {
                input = new Vector2
                {
                    x = CrossPlatformInputManager.GetAxis("Horizontal1"),
                    y = CrossPlatformInputManager.GetAxis("Vertical1")
                };
            }
            else if (this.gameObject.tag == "Player 2")
            {
                input = new Vector2
                {
                    x = CrossPlatformInputManager.GetAxis("Horizontal2"),
                    y = CrossPlatformInputManager.GetAxis("Vertical2")
                };
            }
            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
コード例 #20
0
        private Vector2 GetInput()
        {
            //if (currentPlatform == RuntimePlatform.WindowsEditor || currentPlatform == RuntimePlatform.WindowsPlayer)
            //{
            Vector2 input = new Vector2
            {
                x = CrossPlatformInputManager.GetAxisRaw("Horizontal"),
                y = CrossPlatformInputManager.GetAxisRaw("Vertical")
            };

            //}
            //else
            //{
            //    Vector2 input = new Vector2
            //    {
            //        x = RunAxis.x,
            //        y = RunAxis.y
            //    };
            //}

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
        void FixedUpdate()
        {
            StateCheck();

            if (m_PreviousState == State.Airborne && m_State != State.Airborne)
            {
                m_Jumping = false;
                audioSettings.playerAudio.PlayLand();
            }

            if (m_PreviousState == State.OnWall && m_State != State.OnWall)
            {
                timeTillCanReattachToWall = advancedSettings.wallReattachmentTimeout;
            }

            Vector2 input = GetInput();

            movementSettings.UpdateDesiredTargetSpeed(input);

            // Handle movement
            if (IsNonZero(input))
            {
                // Always move along the camera forward as it is the direction that it being aimed at
                Vector3 desiredMove = cameraTransform.forward * input.y + cameraTransform.right * input.x;

                if (m_State == State.Grounded)
                {
                    desiredMove  = Vector3.ProjectOnPlane(desiredMove, m_SurfaceContactNormal).normalized;
                    desiredMove *= movementSettings.currentTargetSpeed;

                    // TODO this speed limiting thing should be in other states as well (to some degree)
                    float targetSpeed = movementSettings.currentTargetSpeed;
                    if (m_RigidBody.velocity.sqrMagnitude < targetSpeed * targetSpeed)
                    {
                        m_RigidBody.AddForce(desiredMove * SlopeMultiplier(), ForceMode.Impulse);
                    }
                }
                else if (m_State == State.OnWall)
                {
                    if (!m_Jump)
                    {
                        desiredMove  = Vector3.ProjectOnPlane(desiredMove, Vector3.up).normalized;
                        desiredMove *= movementSettings.currentTargetSpeed;

                        m_RigidBody.AddForce(desiredMove, ForceMode.Impulse);
                    }

                    m_RigidBody.AddForce(-Physics.gravity, ForceMode.Acceleration);
                }
                else if (m_State == State.Airborne && advancedSettings.airControl)
                {
                    desiredMove  = Vector3.ProjectOnPlane(desiredMove, Vector3.up).normalized;
                    desiredMove *= movementSettings.forwardSpeed * advancedSettings.airControlMultiplier;

                    m_RigidBody.AddForce(desiredMove, ForceMode.Impulse);
                }
            }

            // Handle jumps

            if (m_State == State.Grounded)
            {
                m_RigidBody.drag = advancedSettings.onSurfaceRigidbodyDrag;

                if (m_Jump)
                {
                    m_RigidBody.drag     = m_defaultDrag;
                    m_RigidBody.velocity = new Vector3(m_RigidBody.velocity.x, 0f, m_RigidBody.velocity.z);
                    m_RigidBody.AddForce(new Vector3(0f, movementSettings.jumpForce, 0f), ForceMode.Impulse);

                    m_Jumping = true;
                    audioSettings.playerAudio.PlayJump();
                }

                if (!m_Jumping && IsZero(input) && m_RigidBody.velocity.magnitude < 1f)
                {
                    m_RigidBody.Sleep();
                }
            }
            else if (m_State == State.OnWall)
            {
                m_RigidBody.drag = advancedSettings.onSurfaceRigidbodyDrag;

                Vector3 awayFromWall = m_SurfaceContactNormal;
                Vector3 desiredMove  = cameraTransform.forward * input.y + cameraTransform.right * input.x;
                desiredMove = Vector3.ProjectOnPlane(desiredMove, Vector3.up);

                if (m_Jump)
                {
                    m_RigidBody.velocity = new Vector3(m_RigidBody.velocity.x, 0f, m_RigidBody.velocity.z);

                    Vector3 force = (
                        Vector3.up * movementSettings.wallJumpUpwardsModifier +
                        desiredMove.normalized * movementSettings.wallJumpSidewaysModifier
                        ) * movementSettings.jumpForce;
                    force += awayFromWall * movementSettings.wallJumpDefaultAwayFromWallForce;

                    float awayFromWallComponent = Vector3.Dot(force, awayFromWall);
                    if (awayFromWallComponent < movementSettings.wallJumpMinAwayFromWallForce)
                    {
                        force += awayFromWall * (-awayFromWallComponent + movementSettings.wallJumpMinAwayFromWallForce);
                    }

                    m_RigidBody.drag = m_defaultDrag;
                    m_RigidBody.AddForce(force, ForceMode.Impulse);
                    m_Jumping = true;

                    timeTillCanReattachToWall = advancedSettings.wallReattachmentTimeout;

                    audioSettings.playerAudio.PlayJump();
                }
                else
                {
                    bool wantsToFallOffWall = IsNonZero(desiredMove) && Vector3.Angle(awayFromWall, desiredMove) < maxAwayFromWallInputAngle;
                    if (wantsToFallOffWall)
                    {
                        wantedToFallOffWallTime += Time.fixedDeltaTime;
                    }
                    else
                    {
                        wantedToFallOffWallTime = 0f;
                    }

                    if (wantsToFallOffWall && wantedToFallOffWallTime >= movementSettings.timeToFallOffWall)
                    {
                        wantedToFallOffWallTime = 0f;

                        timeTillCanReattachToWall = advancedSettings.wallReattachmentTimeout;
                    }
                    else
                    {
                        StickToWallHelper();
                    }
                }
            }
            else if (m_State == State.Airborne)
            {
                m_RigidBody.drag = m_defaultDrag;

                if (!m_Jumping)
                {
                    if (m_PreviousState == State.Grounded)
                    {
                        StickToGroundHelper();
                    }
                }
            }

            if (!isAirborne && IsNonZero(velocity) && IsNonZero(input))
            {
                ProgressStepCycle();
            }

            if (timeTillCanReattachToWall >= 0f)
            {
                timeTillCanReattachToWall -= Time.fixedDeltaTime;
            }

            m_Jump = false;
        }
コード例 #22
0
 public Vector2 GetInput(Vector2 input)
 {
     movementSettings.UpdateDesiredTargetSpeed(input);
     return(input);
 }
        ////////////////////////////////////////
        private void FixedUpdate()
        {
            GroundCheck();

            //		int moveHorizontal = 0;
            //		Debug.Log(myo.transform.up.z);
            myoLeft = myo.transform.right.y;
            myoUp   = myo.transform.up.z;

            // Horisontal control left/right
            if (myoLeft <= 0.15 && myoLeft >= -0.15)
            {
                moveLeftRight = 0;
                //			Debug.Log(moveLeftRight);
            }
            if (myoLeft >= 0.15)
            {
                moveLeftRight = -1;
                //			Debug.Log(moveLeftRight);
            }

            if (myoLeft <= -0.15)
            {
                moveLeftRight = 1;
                //			Debug.Log(moveLeftRight);
            }

            Debug.Log(myoUp);
            // Horisontal control front/back
            if (myoUp <= 0.15 && myoUp >= -0.15)
            {
                moveFrontBack = 0;
//				Debug.Log(moveFrontBack);
            }

            if (myoUp >= 0.15)
            {
                moveFrontBack = 1;
//				Debug.Log(moveFrontBack);
            }

            if (myoUp <= -0.15)
            {
                moveFrontBack = -1;
//				Debug.Log(moveFrontBack);
            }

            Vector2 input = new Vector3(moveLeftRight, moveFrontBack);

//			Vector2 input2 = GetInput ();
            //Vector2 input = new Vector3 (myo.transform.right.x, myo.transform.up.z);
            movementSettings.UpdateDesiredTargetSpeed(input);

            if ((Mathf.Abs(input.x) > float.Epsilon || Mathf.Abs(input.y) > float.Epsilon) && (advancedSettings.airControl || m_IsGrounded))
            {
                // always move along the camera forward as it is the direction that it being aimed at
                Vector3 desiredMove = cam.transform.forward * input.y + cam.transform.right * input.x;
                desiredMove = Vector3.ProjectOnPlane(desiredMove, m_GroundContactNormal).normalized;

                desiredMove.x = desiredMove.x * movementSettings.CurrentTargetSpeed;
                desiredMove.z = desiredMove.z * movementSettings.CurrentTargetSpeed;
                desiredMove.y = desiredMove.y * movementSettings.CurrentTargetSpeed;


                if (m_RigidBody.velocity.sqrMagnitude <
                    (movementSettings.CurrentTargetSpeed * movementSettings.CurrentTargetSpeed))
                {
                    m_RigidBody.AddForce(desiredMove * SlopeMultiplier(), ForceMode.Impulse);
                }
            }

            if (m_IsGrounded)
            {
                m_RigidBody.drag = 5f;

                if (m_Jump)
                {
                    m_RigidBody.drag     = 0f;
                    m_RigidBody.velocity = new Vector3(m_RigidBody.velocity.x, 0f, m_RigidBody.velocity.z);
                    m_RigidBody.AddForce(new Vector3(0f, movementSettings.JumpForce, 0f), ForceMode.Impulse);
                    m_Jumping = true;
                }

                if (!m_Jumping && Mathf.Abs(input.x) < float.Epsilon && Mathf.Abs(input.y) < float.Epsilon && m_RigidBody.velocity.magnitude < 1f)
                {
                    m_RigidBody.Sleep();
                }
            }
            else
            {
                m_RigidBody.drag = 0f;
                if (m_PreviouslyGrounded && !m_Jumping)
                {
                    StickToGroundHelper();
                }
            }
            m_Jump = false;
        }
コード例 #24
0
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
                x = CrossPlatformInputManager.GetAxis("Horizontal1" + p_Num),
                y = CrossPlatformInputManager.GetAxis("Vertical1" + p_Num)
            };
            var cameraForward = Vector3.Scale(cameraTransform.forward, new Vector3(1, 0, 1)).normalized;

            if (Input.GetButton("Crouch" + p_Num) && !m_Jumping)
            {
                Crouching = true;
                if (HeightM > m_HeightM / 2)
                {
                    HeightM = Mathf.SmoothDamp(HeightM, HeightM / 2, ref yVelocity, 0.1f);
                }
            }
            else
            {
                Crouching = false;
                if (HeightM < m_HeightM)
                {
                    HeightM = Mathf.SmoothDamp(HeightM, m_HeightM, ref yVelocity, 0.1f);
                }
            }


            ///////////////////4月27日 段差///////////////////////////////////////////////////////////////////////////////////////////////////////////////
            if (input.x != 0 || input.y != 0)
            {
                Vector3 direction = cameraTransform.right * input.x + cameraForward * input.y;

                //登れる段差を表示
                Debug.DrawLine(transform.position + new Vector3(0f, stepOffset, 0f), transform.position + new Vector3(0f, stepOffset, 0f) + direction * slopeDistance, Color.green);
                Debug.DrawLine(stepRay.position, stepRay.position + direction * stepDistance, Color.blue, 0.1f, false);
                //ステップ用のレイが地面に接触しているか
                if (Physics.Linecast(stepRay.position, stepRay.position + direction * stepDistance, out stepHit, LayerMask.GetMask("Field", "Block")) && (Mathf.Abs(input.x) > float.Epsilon || Mathf.Abs(input.y) > float.Epsilon))
                {
                    Debug.DrawLine(stepRay.position, stepRay.position + direction * stepDistance, Color.blue, 0.1f, false);

                    // 進行方向の地面の角度が指定以下、または登れる段差より下だった場合の移動
                    if (Vector3.Angle(transform.up, stepHit.normal) <= slopeLimit ||
                        (Vector3.Angle(transform.up, stepHit.normal) > slopeLimit &&
                         !Physics.Linecast(transform.position + new Vector3(0f, stepOffset, 0f), transform.position + new Vector3(0f, stepOffset, 0f) + direction * slopeDistance, LayerMask.GetMask("Field", "Block")))
                        )
                    {
                        m_RigidBody.velocity = new Vector3(0f, ((Quaternion.FromToRotation(Vector3.up, stepHit.normal) * direction) * 2f).y, 0f) + direction * movementSettings.CurrentTargetSpeed; //上と進行方向に力を加える
//                    Debug.Log(Vector3.Angle(transform.up, stepHit.normal));
                    }
                    else
                    {
                    }
                    //ステップ用のレイが地面に接していなければ
                }
                else
                {
                }
            }
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }