private void UpdateVirtualAxes(Vector3 value) { var delta = startPos - value; delta.y = -delta.y; delta /= MovementRange; if (useX) { horizontalVirtualAxis.Update(-delta.x); } if (useY) { verticalVirtualAxis.Update(delta.y); } }
void UpdateVirtualAxes(Vector3 value) { if (Math.Abs(value.x) < 4 && Math.Abs(value.y) < 4) { value = Vector3.zero; GameLogicHandler.onLeftClick(lastPosition); } #if UNITY_EDITOR value = value * 0.1f; #else value = value * 0.1f; #endif m_HorizontalVirtualAxis.Update(value.x); m_VerticalVirtualAxis.Update(value.y); }
void UpdateVirtualAxes(Vector3 value) { var delta = m_StartPos - value; delta.y = -delta.y; delta /= MovementRange; if (m_UseX) { m_HorizontalVirtualAxis.Update(-delta.x); } if (m_UseY) { m_VerticalVirtualAxis.Update(delta.y); } }
void UpdateVirtualAxes(Vector3 value) { var delta = initialTouchPosition - value; delta.y = -delta.y; delta /= MovementRangeRadius; if (shouldUseX) { horizontalVirtualAxis.Update(-delta.x); } if (shouldUseY) { verticalVirtualAxis.Update(delta.y); } }
void UpdateVirtualAxis(Vector3 value) { Vector3 delta = m_AnchorPos - value; //float radius = MovementRadius / UIRoot.GetPixelSizeAdjustment(gameObject); //delta /= -_movement_radius; if (m_UseX) { m_HorizontalVirtualAxis.Update(delta.x != 0 ? -Mathf.Sign(delta.x) : 0); } if (m_UseY) { m_VerticalVirtualAxis.Update(delta.y != 0 ? -Mathf.Sign(delta.y) : 0); } }
// Update is called once per frame void Update() { //If space is pressed then reset the 'neutral' device orientation if (Input.GetKeyDown(KeyCode.Space)) { ConfigureVerticalOrientationOffset(); } //Get the base acceleration values float verticalAcceleration = GetValueAboveThreshold(AdjustAccelerationForInitialTilt(GetTiltAdjustedVerticalAcceleration() - verticalAccelerationOffset), verticalAccelerationThreshold); float horizontalAcceleration = GetValueAboveThreshold(Input.acceleration.x, horizontalAccelerationThreshold); //Transform into scaled acceleration values (-1 to +1) float verticalAxisValue = GetAccelerationValueAsRatioOfMaxAcceleration(verticalAcceleration, verticalAccelerationMax); float horizontalAxisValue = GetAccelerationValueAsRatioOfMaxAcceleration(horizontalAcceleration, horizontalAccelerationMax); //Update the axis values in the CrossPlatformInputManager, ready for other game components to read as input verticalAxis.Update(verticalAxisValue); horizontalAxis.Update(horizontalAxisValue); }
private void UpdateVirtualAxes(Vector3 value) { //Debug.Log ("UpdateVirtualAxes"); var delta = startPos - value; delta.y = -delta.y; delta /= MovementRange; if (useX) { // PlayerCtrl.MakeMove (delta.x, 0); ToNewPositionX += delta.x; horizontalVirtualAxis.Update(-delta.x); } if (useY) { //PlayerCtrl.MakeMove (0, delta.y); ToNewPositionY += delta.y; verticalVirtualAxis.Update(delta.y); } }
void HandleAnalogEvent(object sender, AnalogInputChangedArgs args) { ControlPlane.AnalogEvent analog = args.Event; //Debug.Log(analog.AnalogInput.ToString() + ": 0x" + analog.AnalogValue.ToString()); float val = analog.AnalogValue; val = (val - 511.5f) / 511.5f; if (Mathf.Abs(val) < 0.1f) { val = 0; } if (analog.AnalogInput == AnalogInputValues.JoystickX) { m_HorizontalVirtualAxis.Update(val); } if (analog.AnalogInput == AnalogInputValues.JoystickY) { m_VerticalVirtualAxis.Update(val); } }
private void SendInput() { Vector2 movement = Vector2.ClampMagnitude(delta, movementMaxRange); if (movement != Vector2.zero && !smallCircle.gameObject.activeSelf) { smallCircle.gameObject.SetActive(true); smallCircle.position = bigCircle.position + (Vector3)movement; } else if (movement != Vector2.zero && smallCircle.gameObject.activeSelf) { smallCircle.position = bigCircle.position + (Vector3)movement; } else if (movement == Vector2.zero && smallCircle.gameObject.activeSelf) { smallCircle.gameObject.SetActive(false); } movement /= movementMaxRange; if (Mathf.Abs(movement.x) > Mathf.Abs(movement.y)) { movement.y = 0; } else if (Mathf.Abs(movement.y) > Mathf.Abs(movement.x)) { movement.x = 0; } if (useX) { horizontalAxis.Update(movement.x); } if (useY) { verticalAxis.Update(movement.y); } }
void Update() { if (cam == null) { cam = Camera.main; // sometimes null for a few cycles if (cam != null && cam.tag == "DeathCamera") { cam = null; } } if (cam == null) { return; // sometimes null for a few cycles } RaycastHit hit; bool setAxes = false; for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); if (touch.phase == TouchPhase.Began && !EventSystem.current.IsPointerOverGameObject(touch.fingerId) && GUIPanel.PanelContainingPoint(touch.position) == null) { if (touchedTapComponent != null) { touchedTapComponent.TapEnd(); touchedTapComponent = null; } lookTouchId = touch.fingerId; lookTouchStart = touch.position; if (TapRaycast(touch.position, out hit)) { TapComponent hitTapComponent = hit.transform.GetComponent <TapComponent>(); if (hitTapComponent != null && hit.distance <= hitTapComponent.maxDistance) { touchedTapComponent = hitTapComponent; touchedTapComponent.TapStart(PlayerComponent.instance); } } } // don't move joystick and camera with same touch if (lookTouchId == joystick.dragTouchId) { lookTouchId = -1; if (touchedTapComponent != null) { touchedTapComponent.TapEnd(); touchedTapComponent = null; } } if (touch.fingerId == lookTouchId) { setAxes = true; hAxis.Update(touch.deltaPosition.x * 150f / cam.pixelHeight); vAxis.Update(touch.deltaPosition.y * 150f / cam.pixelHeight); if ((touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary) && touchedTapComponent != null) { // check for early cancel (tap left component) if (TapRaycast(touch.position, out hit)) { TapComponent hitTapComponent = hit.transform.GetComponent <TapComponent>(); if (hitTapComponent != touchedTapComponent || hit.distance > touchedTapComponent.maxDistance) { touchedTapComponent.TapEnd(); touchedTapComponent = null; } } else { touchedTapComponent.TapEnd(); touchedTapComponent = null; } } if (touch.phase == TouchPhase.Ended && touchedTapComponent != null) { touchedTapComponent.TapEnd(); touchedTapComponent = null; } if (touch.phase == TouchPhase.Ended && (touch.position - lookTouchStart).magnitude / GUIPanel.scaleFactor < DRAG_THRESHOLD) { if (TapRaycast(touch.position, out hit)) { CarryableComponent hitCarryable = hit.transform.GetComponent <CarryableComponent>(); if (hitCarryable != null && hitCarryable.enabled) { if (hitCarryable.IsCarried()) { hitCarryable.Throw(PlayerComponent.instance); } else if (hit.distance <= CARRY_DISTANCE) { if (carriedComponent != null && carriedComponent.IsCarried()) { carriedComponent.Drop(); } hitCarryable.Carry(PlayerComponent.instance); carriedComponent = hitCarryable; } } } } } // end if touch.fingerId == lookTouchId } if (!setAxes) { lookTouchId = -1; hAxis.Update(0); vAxis.Update(0); } }
void Update() { if (cam == null) { cam = Camera.current; // sometimes null for a few cycles if (cam != null && cam.tag == "DeathCamera") { cam = null; } } if (cam == null) { return; // sometimes null for a few cycles } bool setAxes = false; for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); if (touch.phase == TouchPhase.Began && !EventSystem.current.IsPointerOverGameObject(touch.fingerId)) { if (touchedTapComponent != null) { touchedTapComponent.TapEnd(); } lookTouchId = touch.fingerId; RaycastHit hit; if (Physics.Raycast(cam.ScreenPointToRay(touch.position), out hit)) { TapComponent hitTapComponent = hit.transform.GetComponent <TapComponent>(); if (hitTapComponent != null) { touchedTapComponent = hitTapComponent; touchedTapComponent.TapStart(PlayerComponent.instance, hit.distance); } } } // don't move joystick and camera with same touch if (lookTouchId == joystick.dragTouchId) { lookTouchId = -1; if (touchedTapComponent != null) { touchedTapComponent.TapEnd(); touchedTapComponent = null; } } if (touch.fingerId == lookTouchId) { setAxes = true; hAxis.Update(touch.deltaPosition.x * 150f / cam.pixelHeight); vAxis.Update(touch.deltaPosition.y * 150f / cam.pixelHeight); if (touch.phase == TouchPhase.Ended && touchedTapComponent != null) { touchedTapComponent.TapEnd(); touchedTapComponent = null; } } } if (!setAxes) { lookTouchId = -1; hAxis.Update(0); vAxis.Update(0); } }
void UpdateVirtualAxes(Vector2 delta) { m_horizontalVirtualAxis.Update(delta.x); m_verticalVirtualAxis.Update(delta.y); }
void UpdateVirtualAxes(Vector2 value) { virtualAxisHorizontal.Update(value.x); virtualAxisVertical.Update(value.y); }