// Update is called once per frame void Update() { //ジョイスティックの位置を固定 CrossPlatformInputManager.SetAxis("Horizontal", 0); CrossPlatformInputManager.SetAxis("Vertical", 0); if (Input.GetKeyDown("p")) { OnPause(); } if (hantei == 2) { time += Time.deltaTime; if (time >= 1) { secound++; time = 0; } if (secound < 10) { timetext.text = "00" + ":" + "0" + secound.ToString(); } else { timetext.text = "00" + ":" + secound.ToString(); } } }
public virtual void OnDrag(PointerEventData ped) { Vector2 zero = Vector2.zero; if (RectTransformUtility.ScreenPointToLocalPointInRectangle(this.bgImage.get_rectTransform(), ped.get_position(), ped.get_pressEventCamera(), out zero)) { zero.x /= this.bgImage.get_rectTransform().sizeDelta.x; zero.y /= this.bgImage.get_rectTransform().sizeDelta.y; this.inputVector = new Vector3(zero.x * 2f, zero.y * 2f, 0f); this.unNormalizedInput = this.inputVector; this.inputVector = (this.inputVector.magnitude <= 1f) ? this.inputVector : this.inputVector.normalized; this.joystickKnobImage.get_rectTransform().anchoredPosition = new Vector3(this.inputVector.x * (this.bgImage.get_rectTransform().sizeDelta.x / ((float)this.joystickHandleDistance)), this.inputVector.y * (this.bgImage.get_rectTransform().sizeDelta.y / ((float)this.joystickHandleDistance))); if (!this.joystickStaysInFixedPosition && (this.unNormalizedInput.magnitude > this.inputVector.magnitude)) { Vector3 position = this.bgImage.get_rectTransform().position; position.x += ped.get_delta().x; position.y += ped.get_delta().y; position.x = Mathf.Clamp(position.x, this.bgImage.get_rectTransform().sizeDelta.x, (float)Screen.width); position.y = Mathf.Clamp(position.y, 0f, Screen.height - this.bgImage.get_rectTransform().sizeDelta.y); this.bgImage.get_rectTransform().position = position; } CrossPlatformInputManager.SetAxis("Horizontal", this.inputVector.x); CrossPlatformInputManager.SetAxis("Vertical", this.inputVector.y); } }
// Update is called once per frame void Update() { #if MOBILE_INPUT if (speed > 0) { speed -= speedDecay; } if (speed < 0) { speed += speedDecay; } if (rotation > 0) { rotation -= rotationDecay; } if (rotation < 0) { rotation += rotationDecay; } if (pan > 0) { pan -= panDecay; } if (pan < 0) { pan += panDecay; } CrossPlatformInputManager.SetAxis("Vertical", speed / axisFactor); CrossPlatformInputManager.SetAxis("Rotate", rotation / axisFactor); CrossPlatformInputManager.SetAxis("Pan", pan / axisFactor); #endif }
// Update is called once per frame void Update() { if (!isBalancing) { return; } // Move towards the other rope node. transform.LookAt(_moveTowards); // Walk slowly forward, it should be facing the node at the other end. CrossPlatformInputManager.SetAxis("Horizontal", 0); CrossPlatformInputManager.SetAxis("Vertical", characterSpeed); var difference = BalanceAngleDifference(); dialRoot.rotation = Quaternion.Euler(0, 0, difference); Camera.main.transform.Rotate(Vector3.forward, difference * characterSpeed, Space.Self); if (difference > angleThreshold || difference < _inverseAngleThreshold) { // What happens when it's too much? We fall off I assume. print("Fall off"); // Why can't I add force here? Is there some tick box on? var rb = _character.GetComponent <Rigidbody>(); rb.AddForce(new Vector3(1, 1, 0) * difference); // Whatever happens, we still have to end the balance. EndBalance(); } }
// Update is called once per frame void Update() { if (Application.isEditor && !TestRun) { return; } CrossPlatformInputManager.SetAxis("Vertical", dj.Vertical); CrossPlatformInputManager.SetAxis("Horizontal", dj.Horizontal); }
private void SetAxiesFromVector(Vector3 movement) { //float h = Vector3.Dot(movement, horizontalDirection) / horizontalDirection.magnitude; //float v = Vector3.Dot(movement, verticalDirection) / verticalDirection.magnitude; float h = movement.ScalarProjection(horizontalDirection); float v = movement.ScalarProjection(verticalDirection); CrossPlatformInputManager.SetAxis(horizontalAxis, h); CrossPlatformInputManager.SetAxis(verticalAxis, v); }
private void UpdateVirtualAxes(Vector3 value) { if (useX) { CrossPlatformInputManager.SetAxis(horizontalAxisName, value.x); } if (useY) { CrossPlatformInputManager.SetAxis(verticalAxisName, value.y); } }
// Update is called once per frame void Update() { if (player.onGround) { lineRenderer.SetActive(true); AnimateLine(hort); } else { lineRenderer.SetActive(false); } if (flag == 1) { jumpPosition = new Vector3(xCom.x, destination.position.y, destination.position.z); player.Jump(jumpPosition); jumpPosition = Vector3.zero; flag = 0; } if (CrossPlatformInputManager.GetAxis("FUCKINGPAUSE") > 0 || (Input.GetKeyDown(KeyCode.Escape) && player.Alive == true)) { Pause(); CrossPlatformInputManager.SetAxis("FUCKINGPAUSE", 0); } if (flag == 0 && LePlayer.gameObject.GetComponent <Rigidbody>() && LePlayer.GetComponent <Rigidbody>().velocity.magnitude == 0 && !isInUI && !(CrossPlatformInputManager.GetAxis("FUCKINGPAUSE") > 0) && Input.GetMouseButtonDown(0)) { timeForHortizonal = !timeForHortizonal; xCom = pointAlongLine; if (!gamePaused) { flag = 1; } } if (player.touchedTarget) { StartCoroutine(targerAnimation()); StartCoroutine(ReLocateTower()); int jumTo = currTower + 1; if (jumTo == towers.Length) { jumTo = 0; } target.Jump(towers[jumTo].GetChild(0).position); } }
void Start() { myBody = this.GetComponent <Rigidbody2D>(); if (PlayerPrefs.GetString("landingBool") != "false" && PlayerPrefs.GetString("landingBool") != "true") { PlayerPrefs.SetString("landingBool", "false"); } if (PlayerPrefs.GetString("landingBool") == "true") { CrossPlatformInputManager.SetAxis("Vertical", 0.5f); moveForce = 5.0f; } }
// Update is called once per frame void Update() { if (Screen.orientation == ScreenOrientation.Portrait) { if (Input.GetMouseButtonDown(0) && ok) { //クリックし始め //position=Camera.main.ScreenToWorldPoint(Input.mousePosition); stickunder.position = Input.mousePosition; joystick.position = Input.mousePosition; position = Input.mousePosition; //stick.CreateVirtualAxes (); //stick.UpdateVirtualAxes(Input.mousePosition); Debug.Log("joystick" + joystick.localPosition); Debug.Log("mouse" + Input.mousePosition); if (0 == 0) { push = true; } } if (Input.GetMouseButton(0) && push) { joystick.position = new Vector2(Mathf.Clamp(Input.mousePosition.x, position.x + sticklimit * -1, position.x + sticklimit), Mathf.Clamp(Input.mousePosition.y, position.y + sticklimit * -1, position.y + sticklimit)); Vector2 move = position - new Vector2(Input.mousePosition.x, Input.mousePosition.y); CrossPlatformInputManager.SetAxis("Horizontal", (move.x * -1) / 30); CrossPlatformInputManager.SetAxis("Vertical", (move.y * -1) / 30); } if (Input.GetMouseButtonUp(0)) { //指を離す ok = true; push = false; CrossPlatformInputManager.SetAxis("Horizontal", 0); CrossPlatformInputManager.SetAxis("Vertical", 0); joystick.localPosition = new Vector3(1000, 1000, 1000); stickunder.localPosition = new Vector3(1000, 1000, 1000); } } else { ok = true; push = false; CrossPlatformInputManager.SetAxis("Horizontal", 0); CrossPlatformInputManager.SetAxis("Vertical", 0); joystick.localPosition = new Vector3(1000, 1000, 1000); stickunder.localPosition = new Vector3(1000, 1000, 1000); } }
private void Update() { //Debug.Log("Update " + joystick.Vertical + " " + _verticalAxisPressed + " " + _verticalAxisReset); if (joystick.Vertical <= 0) { _verticalAxisReset = true; } if (joystick.Vertical > 0 && !_verticalAxisPressed && _verticalAxisReset) { _verticalAxisPressed = true; _verticalAxisReset = false; CrossPlatformInputManager.SetButtonDown("Jump"); } CrossPlatformInputManager.SetAxis("Horizontal", joystick.Horizontal); }
public IEnumerator PlayerMovesZAxis() { //uses virtual input to see whether the player moves on y axis and not x GameObject initalPos = new GameObject(); var playerA = new GameObject().AddComponent <FirstPersonController> (); initalPos.transform.position = new Vector3(0, 0); playerA.transform.position = initalPos.transform.position; yield return(null); CrossPlatformInputManager.SetAxis("Virtical", 1); Assert.True(playerA.transform.position.z > initalPos.transform.position.z || playerA.transform.position.z < initalPos.transform.position.z && playerA.transform.position.x == initalPos.transform.position.x); }
private void DoTouchRaycasts() { var lookup = GetSuccessfulTouchRaycastLookup(); Vector3 offset = Vector3.zero; float slowValue = 0; if (lookup.Count == 1) { var hit = lookup.First().Value; slowValue = hit.collider == fineTuneCollider ? 1 : 0; offset = orbiter.InverseTransformPoint(hit.point).normalized; } CrossPlatformInputManager.SetAxis(moveSlowAxis, slowValue); if (vectorGizmo != null) { vectorGizmo.Value = offset; } SetAxiesFromVector(offset); }
void Update() { if (Input.GetKey("space")) { CrossPlatformInputManager.SetButtonDown("Jump"); } else { CrossPlatformInputManager.SetButtonUp("Jump"); } if (Input.GetKey("c")) { CrossPlatformInputManager.SetButtonDown("Sneak"); } else { CrossPlatformInputManager.SetButtonUp("Sneak"); } CrossPlatformInputManager.SetAxis("Horizontal", Input.GetAxis("Horizontal")); CrossPlatformInputManager.SetAxis("Vertical", Input.GetAxis("Vertical")); }
public void HandleInput(float value) { CrossPlatformInputManager.SetAxis(axis, (value * 2f) - 1f); }
private void Update() { //Check if we are running either in the Unity editor or in a standalone build. #if UNITY_STANDALONE || UNITY_WEBPLAYER //Check if we are running on iOS, Android, Windows Phone 8 or Unity iPhone #elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_IPHONE //Check if Input has registered more than zero touches Vector2 dragOffset = Vector2.zero; if (Input.touchCount > 0) { //Store the first touch detected. Touch myTouch = Input.touches[0]; switch (myTouch.phase) { //Check if the phase of that touch equals Began case TouchPhase.Began: //If so, set touchOrigin to the position of that touch _touchOrigin = myTouch.position; // enable the nobs _touchNob1.transform.position = _touchOrigin; _touchNob2.transform.position = _touchOrigin; break; case TouchPhase.Moved: _touchNob1.SetActive(true); _touchNob2.SetActive(true); break; case TouchPhase.Canceled: case TouchPhase.Ended: //Set touchOrigin.x to -1 so that our default if statement will evaluate false and not repeat immediately. _touchOrigin.x = -1; dragOffset = Vector2.zero; // disable touch nobs _touchNob1.SetActive(false); _touchNob2.SetActive(false); break; default: if (_touchOrigin.x >= 0) { //Calculate the difference between the beginning and end of the touch. var scaledOffset = (myTouch.position - _touchOrigin) / _touchJoystickAmplitude; // clamp the magnitude to 1 dragOffset = Vector2.ClampMagnitude(scaledOffset, 1); _touchNob2.transform.position = _touchOrigin + dragOffset * _touchJoystickAmplitude; } break; } if (dragOffset.magnitude <= _deadZone) { dragOffset = Vector2.zero; } Debug.DrawLine(_touchOrigin, myTouch.position, Color.green); // set the CrossPlatformInputManager axis, but use lerp to make the transition smoothe CrossPlatformInputManager.SetAxis("Horizontal", dragOffset.x); CrossPlatformInputManager.SetAxis("Vertical", dragOffset.y); } #endif //End of mobile platform dependendent compilation section started above with #elif }
public void OnPointerDown(PointerEventData eventData) { CrossPlatformInputManager.SetAxis(m_Axis.ToString(), m_Value); }
public void ResetMovement() { CrossPlatformInputManager.SetAxis("Horizontal", 0); }
public void LeftBtnClick() { CrossPlatformInputManager.SetAxis("Horizontal", -1); }
public void OnPointerUp(PointerEventData eventData) { CrossPlatformInputManager.SetAxis(m_Axis.ToString(), 0); }
private void FixedUpdate() { float x = CrossPlatformInputManager.GetAxis("Mouse X"); float y = CrossPlatformInputManager.GetAxis("Mouse Y"); if (x != 0 || y != 0) { CrossPlatformInputManager.SetAxis("Mouse X", 0.0f); CrossPlatformInputManager.SetAxis("Mouse Y", 0.0f); } GravityDrctInBattleWorld = battle_transform.InverseTransformDirection(Physics.gravity); if (isChangingGravity) { float step = gravityRotateSpeed * Time.deltaTime; changingProcess += step; if (changeMode == ChangingMode.rotate) { if (changingProcess > 1) { changingProcess = 1; isChangingGravity = false; } //Vector3 lastGravityDrct = Physics.gravity;// Vector3 lastGravityDrct = GravityDrctInBattleWorld;// //Physics.gravity = Vector3.Slerp(originGravityDrct, targetGravityDrct, changingProcess); GravityDrctInBattleWorld = Vector3.Slerp(originGravityDrct, targetGravityDrct, changingProcess); Physics.gravity = battle_transform.TransformDirection(GravityDrctInBattleWorld); //player.transform.rotation = Quaternion.FromToRotation(lastGravityDrct, Physics.gravity) * player.transform.rotation; player.transform.rotation = Quaternion.FromToRotation(battle_transform.TransformDirection(lastGravityDrct), Physics.gravity) * player.transform.rotation; } else if (changeMode == ChangingMode.revert) { player.transform.RotateAround(player.transform.position + player.transform.up * plrCapsule.height * transform.localScale.y, player.transform.right, 180.0f * step); //(new Vector3(1, 0, 0), 3.14f * step); if (changingProcess > 1) { changingProcess = 1; isChangingGravity = false; player.transform.rotation = Quaternion.FromToRotation(-player.transform.up, targetGravityDrct) * player.transform.rotation; } //Physics.gravity = Vector3.Lerp(originGravityDrct, targetGravityDrct, changingProcess); GravityDrctInBattleWorld = Vector3.Lerp(originGravityDrct, targetGravityDrct, changingProcess); Physics.gravity = battle_transform.TransformDirection(GravityDrctInBattleWorld); } //Debug.Log (player.transform.up); } else if (battleControlCentor.isSwitchingLevel) { //do nothing. } else if ((canChangeGravityInAir || tpc.m_IsGrounded) && getSlideDrctFromAxis(x, y) == slideDrct.upSlide) { targetGravityDrct = getPlayerDrct(battle_transform.InverseTransformDirection(player.transform.forward)); //originGravityDrct = Physics.gravity; originGravityDrct = GravityDrctInBattleWorld; isChangingGravity = true; changingProcess = 0; changeMode = ChangingMode.rotate; } else if ((canChangeGravityInAir || tpc.m_IsGrounded) && getSlideDrctFromAxis(x, y) == slideDrct.downSlide) { //targetGravityDrct = getPlayerDrct(player.transform.forward); //originGravityDrct = getPlayerDrct(-Physics.gravity) * 0.3f; originGravityDrct = getPlayerDrct(-GravityDrctInBattleWorld) * 0.3f; //targetGravityDrct = getPlayerDrct(-Physics.gravity); targetGravityDrct = getPlayerDrct(-GravityDrctInBattleWorld); isChangingGravity = true; changingProcess = 0; changeMode = ChangingMode.revert; } //Debug.Log (targetGravityDrct); }
void DoSetAxis() { #if CROSS_PLATFORM_INPUT CrossPlatformInputManager.SetAxis(axisName.Value, value.Value); #endif }