public void Fire(Vector2 direct, bool isTouch) { if (Time.time - lastTimeFire < cooldown) { return; } lastTimeFire = Time.time; Show(0.1f); var go = GameObject.Instantiate(ArrowPref, firePoint.position, firePoint.rotation) as GameObject; go.transform.parent = view.root; var item = go.GetComponent <IMonoBehaviourPhysicItem>(); Vector3 direct3 = new Vector3(direct.x, direct.y, firePoint.position.z); if (isTouch) { var h = UltimateJoystick.GetHorizontalAxis("Joystick2"); var v = UltimateJoystick.GetVerticalAxis("Joystick2"); var vPos = new Vector3(h, v) * 100; direct3 = vPos + rootPos.position; direct3 = new Vector3(direct3.x, direct3.y, firePoint.position.z); } item.AddVelocity((direct3 - firePoint.position).normalized * maxSpeed); }
private void Shoot(UltimateJoystick joystick) { float x = joystick.GetHorizontalAxis(); float y = joystick.GetVerticalAxis(); if (x != 0.0f || y != 0.0f) { float angle = angle = Mathf.Atan2(y, x) * Mathf.Rad2Deg - 90; rb.MoveRotation(Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, 0, angle), moveSpeed * Time.time)); lastShootTime += Time.deltaTime; if (lastShootTime > shootSpeed) { lastShootTime = 0; float tan = Mathf.Tan((transform.rotation.eulerAngles.z + 90) * Mathf.PI / 180f); if (transform.rotation.eulerAngles.z < 180) { bullet.GetComponent <BulletMovement>().angle = new Vector2(-1, -tan).normalized; } else { bullet.GetComponent <BulletMovement>().angle = new Vector2(1, tan).normalized; } bullet.transform.position = transform.Find("ShootPoint").transform.position; Instantiate(bullet); } } }
// Update is called once per frame void Update() { h = UltimateJoystick.GetHorizontalAxis("WSJ"); v = UltimateJoystick.GetVerticalAxis("WSJ"); t1 = UltimateJoystick.GetJoystickState("WSJ"); t2 = UltimateJoystick.GetTapCount("WSJ"); }
public void Fire(Vector2 direct, bool isTouch) { if (Time.time - lastTimeFire < 0.5) { return; } lastTimeFire = Time.time; Show(0.1f); var go = GameObject.Instantiate(ShellPref, firePoint.position, firePoint.rotation) as GameObject; go.transform.parent = view.root; go.GetComponent <ExplosionShell>().damage = 100; var item = go.GetComponent <IMonoBehaviourPhysicItem>(); Vector3 direct3 = new Vector3(direct.x, direct.y, firePoint.position.z); if (isTouch) { var h = UltimateJoystick.GetHorizontalAxis("Joystick2"); var v = UltimateJoystick.GetVerticalAxis("Joystick2"); var vPos = new Vector3(h, v) * 100; direct3 = vPos + rootPos.position; direct3 = new Vector3(direct3.x, direct3.y, firePoint.position.z); } Vector3.Distance(firePoint.position, direct3); item.AddVelocity((direct3 - firePoint.position).normalized * maxSpeed); playerModel.GetBag().UseItem(itemData); }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs - Modified by Kaz Crowe //float h = CrossPlatformInputManager.GetAxis( "Horizontal" ); float h = UltimateJoystick.GetHorizontalAxis("Move"); //float v = CrossPlatformInputManager.GetAxis( "Vertical" ); float v = UltimateJoystick.GetVerticalAxis("Move"); bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
public void LookRotation(Transform character, Transform camera) { // float yRot = CrossPlatformInputManager.GetAxis("Mouse X") * XSensitivity; //float xRot = CrossPlatformInputManager.GetAxis("Mouse Y") * YSensitivity; float yRot = UltimateJoystick.GetHorizontalAxis("Look") * XSensitivity; float xRot = UltimateJoystick.GetVerticalAxis("Look") * YSensitivity; m_CharacterTargetRot *= Quaternion.Euler(0f, yRot, 0f); m_CameraTargetRot *= Quaternion.Euler(-xRot, 0f, 0f); if (clampVerticalRotation) { m_CameraTargetRot = ClampRotationAroundXAxis(m_CameraTargetRot); } if (smooth) { character.localRotation = Quaternion.Slerp(character.localRotation, m_CharacterTargetRot, smoothTime * Time.deltaTime); camera.localRotation = Quaternion.Slerp(camera.localRotation, m_CameraTargetRot, smoothTime * Time.deltaTime); } else { character.localRotation = m_CharacterTargetRot; camera.localRotation = m_CameraTargetRot; } UpdateCursorLock(); }
/// <summary> /// 캐릭터의 움직임 컨트롤 /// </summary> private void Move() { //실제 조이스틱 값 가져오는 부분 horizon = UltimateJoystick.GetHorizontalAxis("Move"); vertical = UltimateJoystick.GetVerticalAxis("Move"); //Debug.Log("h = " + vertical + " v = " + vertical); if (cam != null) { //카메라 기준으로 조이스틱 방향성 바꿔줌 camForward = Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized; desiredVelocity = vertical * camForward + horizon * cam.right; } else { //카메라가 없다면 기본 방향 desiredVelocity = vertical * Vector3.forward + horizon * Vector3.right; } //이동을 담당 navMeshAgent.destination = transform.position + desiredVelocity; //애니메이션 움직임 담당 [회전 포함] //실제 이동 없이 회전 만 시키기 위해서 MoveSpeedMultiplier 값을 0으로 바꿈 thirdPersonCharacter.Move(desiredVelocity, false, false); }
void FixedUpdate() { if (isDeath || isClear) { rb.velocity = Vector3.zero; return; } float h = UltimateJoystick.GetHorizontalAxis("Move"); float v = UltimateJoystick.GetVerticalAxis("Move"); m_CamForward = Vector3.Scale(Camera.main.transform.forward, new Vector3(1, 0, 1)).normalized; Vector3 move = v * m_CamForward + h * Camera.main.transform.right * speed; if (move == Vector3.zero) { animator.SetBool("Move", false); } else { animator.SetBool("Move", true); } rb.velocity = move; transform.Rotate(0f, h * rotationSpeed * Time.deltaTime, 0f); }
private void GetInput(out float speed) { // Read input //float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); //float vertical = CrossPlatformInputManager.GetAxis("Vertical"); float horizontal = UltimateJoystick.GetHorizontalAxis("Movement"); float vertical = UltimateJoystick.GetVerticalAxis("Movement"); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void Update() { _direction.x = UltimateJoystick.GetHorizontalAxis("MoveRotate"); _direction.z = UltimateJoystick.GetVerticalAxis("MoveRotate"); DebugExtension.DebugCircle(_player.Transform.position, Color.red, _agroDistance); MovePlayer(Time.deltaTime); RotatePlayer(Time.deltaTime); MoveCamera(Time.deltaTime); RotateCamera(); }
private void JoystickShooting(UltimateJoystick joystick) { if (PlayerController.instance == null) { return; } shootPosition = new Vector3(joystick.GetHorizontalAxis(), joystick.GetVerticalAxis(), 0); if (joystick.GetJoystickState()) { isShoot = true; TryShot(); PlayerController.instance.isBouderJoystickShoot = joystick.GetDistance() >= 0.9f; if (autoTarget.Count == 0) { if (PlayerController.instance.isBouderJoystickShoot) { PlayerController.instance.FlipX = shootPosition.x < 0; PlayerController.instance.SelectNonTarget(shootPosition); } } else { PlayerController.instance.SelectTarget(shootPosition); } } else { #if UNITY_EDITOR #else if (PlayerController.instance.currentGun == 6) { PlayerController.instance.DisableLaser(); } PlayerController.instance.EndShot(); #endif if (isShoot) { SoundController.instance.PlaySound(soundGame.soundbulletdrop); isShoot = false; } if (autoTarget.Count == 0) { PlayerController.instance.SelectNonTarget(!PlayerController.instance.FlipX ? Vector2.right : Vector2.left); } else { PlayerController.instance.SelectTarget(!PlayerController.instance.FlipX ? Vector2.right : Vector2.left); } } }
void OnFinishedFire() { isFireing = false; transform.localRotation = new Quaternion(); damagePoint.enabled = false; var ray = Vector3.zero; var v = UltimateJoystick.GetVerticalAxis("Joystick2"); var h = UltimateJoystick.GetHorizontalAxis("Joystick2"); ray = new Vector3(h, v) * 100; if (!isTouch) { var pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); ray = (pos - firePoint.position); // Debug.LogError(Vector2.Distance(ray,Vector2.zero)); } var tilesDown = Collision.Raycast(firePoint.position, new Vector2(1, 1), ray, false); if (tilesDown.Count > 0) { // ищем ближайшею int index = 0; float minDist = float.MaxValue; for (int i = 0; i < tilesDown.Count; i++) { var newDist = Vector3.Distance(firePoint.position, tileDataProvider.OffsetTileToWorldPos(tilesDown[i])) / tileDataProvider.TileSize; if (newDist < minDist) { minDist = newDist; index = i; } } if (minDist <= range) { tileDataProvider.DamageTile(tilesDown[index], 100); var pos = tileDataProvider.OffsetTileToWorldPos(tilesDown[index]); //var pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); var removeItemId = SwapItemManager.RemoveItem(pos); if (removeItemId != 0) { //сделать предмет } } } }
private void Move() { Vector3 dir; // if (CameraController.mainCameraON) // { dir = new Vector3(UltimateJoystick.GetVerticalAxis("PlayerMove"), 0, -UltimateJoystick.GetHorizontalAxis("PlayerMove")).normalized; rb.velocity = new Vector3(dir.x * moveSpeed * Time.deltaTime, 0, dir.z * moveSpeed * Time.deltaTime); // } /* * else * { * dir = new Vector3(UltimateJoystick.GetHorizontalAxis("PlayerMove") , 0, UltimateJoystick.GetVerticalAxis("PlayerMove")).normalized; * // rb.velocity = new Vector3((dir.x *Mathf.Cos(head.transform.rotation.eulerAngles.y)-dir.z* Mathf.Sin(head.transform.rotation.eulerAngles.y)) * GManager.instance.moveSpeed * Time.deltaTime, 0, (dir.x * Mathf.Sin(head.transform.rotation.eulerAngles.y) + dir.z * Mathf.Cos(head.transform.rotation.eulerAngles.y)) * GManager.instance.moveSpeed * Time.deltaTime); * float angle = (720 + head.transform.rotation.eulerAngles.y) % 360; * if (angle < 45 || angle >= 315) * { * rb.velocity = new Vector3(dir.x * SaveSystem.Instance.UserData.moveSpeed * Time.deltaTime, 0, dir.z * SaveSystem.Instance.UserData.moveSpeed * Time.deltaTime); * } * else if (angle < 135 && angle >= 45) * { * rb.velocity = new Vector3(dir.z * SaveSystem.Instance.UserData.moveSpeed * Time.deltaTime, 0, -dir.x * SaveSystem.Instance.UserData.moveSpeed * Time.deltaTime); * } * else if (angle < 225 && angle >= 135) * { * rb.velocity = new Vector3(-dir.x * SaveSystem.Instance.UserData.moveSpeed * Time.deltaTime, 0, -dir.z * SaveSystem.Instance.UserData.moveSpeed * Time.deltaTime); * } * else if (angle < 315 && angle >= 225) * { * rb.velocity = new Vector3(-dir.z * SaveSystem.Instance.UserData.moveSpeed * Time.deltaTime, 0, dir.x * SaveSystem.Instance.UserData.moveSpeed * Time.deltaTime); * } * } */ float turnY = Mathf.Acos(UltimateJoystick.GetHorizontalAxis("PlayerMove")) / Mathf.PI * 180; float vertical = UltimateJoystick.GetVerticalAxis("PlayerMove"); if (vertical < 0) { body.transform.rotation = Quaternion.Euler(0, turnY, 0); } else if (vertical > 0) { body.transform.rotation = Quaternion.Euler(0, -turnY, 0); } }
public void CheckAfterJump(UltimateJoystick joystick) { movePosition = new Vector3(joystick.GetHorizontalAxis(), joystick.GetVerticalAxis(), 0); var angle = Mathf.Atan2(movePosition.x, movePosition.y) * Mathf.Rad2Deg; var h = movePosition.x; if (angle <= 135f && angle >= -135f) { PlayerController.instance.speedmove = h > 0 ? 1.5f : -1.5f; PlayerController.instance.dirMove = h > 0 ? true : false; PlayerController.instance.playerState = PlayerController.PlayerState.Run; } else if ((angle > -180f && angle < -135f) || (angle > 135f && angle < 180f)) { PlayerController.instance.playerState = PlayerController.PlayerState.Sit; } }
private void HandleRotationMovement() { if (Time.timeScale < float.Epsilon) { return; } // Read the user input var x = UltimateJoystick.GetHorizontalAxis("Look"); var y = UltimateJoystick.GetVerticalAxis("Look") * 0.5f; // Adjust the look angle by an amount proportional to the turn speed and horizontal input. m_LookAngle += x * m_TurnSpeed; // Rotate the rig (the root object) around Y axis only: m_TransformTargetRot = Quaternion.Euler(0f, m_LookAngle, 0f); if (m_VerticalAutoReturn) { // For tilt input, we need to behave differently depending on whether we're using mouse or touch input: // on mobile, vertical input is directly mapped to tilt value, so it springs back automatically when the look input is released // we have to test whether above or below zero because we want to auto-return to zero even if min and max are not symmetrical. m_TiltAngle = y > 0 ? Mathf.Lerp(0, -m_TiltMin, y) : Mathf.Lerp(0, m_TiltMax, -y); } else { // on platforms with a mouse, we adjust the current angle based on Y mouse input and turn speed m_TiltAngle -= y * m_TurnSpeed; // and make sure the new value is within the tilt range m_TiltAngle = Mathf.Clamp(m_TiltAngle, -m_TiltMin, m_TiltMax); } // Tilt input around X is applied to the pivot (the child of this object) m_PivotTargetRot = Quaternion.Euler(m_TiltAngle, m_PivotEulers.y, m_PivotEulers.z); if (m_TurnSmoothing > 0) { m_Pivot.localRotation = Quaternion.Slerp(m_Pivot.localRotation, m_PivotTargetRot, m_TurnSmoothing * Time.deltaTime); transform.localRotation = Quaternion.Slerp(transform.localRotation, m_TransformTargetRot, m_TurnSmoothing * Time.deltaTime); } else { m_Pivot.localRotation = m_PivotTargetRot; transform.localRotation = m_TransformTargetRot; } }
private void Turn() { float turnY = Mathf.Acos(-UltimateJoystick.GetHorizontalAxis("PlayerTurn")) / Mathf.PI * 180; float horizontal = UltimateJoystick.GetHorizontalAxis("PlayerTurn"); float vertical = UltimateJoystick.GetVerticalAxis("PlayerTurn"); if (vertical > 0) { head.transform.rotation = Quaternion.Euler(0, turnY, 0); } else if (vertical < 0) { head.transform.rotation = Quaternion.Euler(0, -turnY, 0); } if ((Mathf.Pow(horizontal, 2) + Mathf.Pow(vertical, 2)) > 0.7f && !isShot && OptionManager.isJoystic) { StartCoroutine(ShotCorutine()); } }
private void JoystickMovement(UltimateJoystick joystick) { movePosition = new Vector3(joystick.GetHorizontalAxis(), joystick.GetVerticalAxis(), 0); if (joystick.GetJoystickState()) { PlayerController.instance.isBouderJoystickMove = joystick.GetDistance() >= 0.2f; if (PlayerController.instance.isBouderJoystickMove) { OnMove(movePosition); } } else { if (PlayerController.instance == null) { return; } StopMove(); } }
private void Move() { //실제 조이스틱 값 가져오는 부분 horizon = UltimateJoystick.GetHorizontalAxis("Move"); vertical = UltimateJoystick.GetVerticalAxis("Move"); //Debug.Log("h = " + vertical + " v = " + vertical); if (cam != null) { //카메라 기준으로 조이스틱 방향성 바꿔줌 camForward = Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized; desiredVelocity = vertical * camForward + horizon * cam.right; } else { //카메라가 없다면 기본 방향 desiredVelocity = vertical * Vector3.forward + horizon * Vector3.right; } //이동을 담당 navMeshAgent.destination = transform.position + desiredVelocity; }
void Update() { //해당 오브젝트가 비활성화 상태라면 움직이지 않음 [비용절약용 코드] if (!skinnedMeshRenderer.isVisible) { return; } if (!lookAhead)//기본 따라다니기 { //실제 러프를 거는 부분followedCam. followedCam.transform.localPosition = Vector3.Lerp(followedCam.transform.localPosition, player.transform.localPosition, Time.deltaTime * recoverStrong); } else //전방을 내다 보며 따라다니기 { //전방을 확인하기 위해 조이스틱 값을 가져옴 h = UltimateJoystick.GetHorizontalAxis("Move"); v = UltimateJoystick.GetVerticalAxis("Move"); //카메라와 조이스틱 포지션간의 왜곡을 보정하기 위해 방향 다시 계산. camForward = Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized; desiredVelocity = v * camForward + h * cam.right; //플레이어의 좌표와 왜곡 보정계산된 방향 가속도를 현재 좌표에 적용. pos = player.transform.localPosition; pos.z += desiredVelocity.z * distance; pos.x += desiredVelocity.x * distance; //러프를 걸 타겟 lookAheadTarget.transform.localPosition = pos; //실제 러프를 거는 followedCam. followedCam.transform.localPosition = Vector3.Lerp(followedCam.transform.localPosition, lookAheadTarget.transform.localPosition, Time.deltaTime * recoverStrong); //Debug.Log("h = [" + h + "] v = [" + v + "]" + " pos = " + pos); //Debug.Log("this = " + transform.localPosition + " lookAheadTarget = " + lookAheadTarget.transform.localPosition); } }
public void GetAxis() { // AxisOnChange.Invoke(Input.GetAxis(StringManager.AXIS_VERTICAL)); AxisOnChange.Invoke(UltimateJoystick.GetVerticalAxis(StringManager.ULTIMATE_JOYSTICK_MOVENMENT)); // Debug.Log($"MobileInputVertic:{UltimateJoystick.GetVerticalAxis(StringManager.ULTIMATE_JOYSTICK_MOVENMENT)}"); }
private void Movement(UltimateJoystick joystick) { Vector2 movePosition = new Vector2(transform.position.x, transform.position.y) + new Vector2(joystick.GetHorizontalAxis(), joystick.GetVerticalAxis()) * moveSpeed; if (movePosition.x > width) { movePosition.x = width; } if (movePosition.x < -width) { movePosition.x = -width; } if (movePosition.y > height) { movePosition.y = height; } if (movePosition.y < -height) { movePosition.y = -height; } rb.MovePosition(movePosition); }
void Update() { // Store the input positions movePosition = new Vector3(UltimateJoystick.GetHorizontalAxis("Movement"), UltimateJoystick.GetVerticalAxis("Movement"), 0); shootPosition = new Vector3(UltimateJoystick.GetHorizontalAxis("Shooting"), UltimateJoystick.GetVerticalAxis("Shooting"), 0); // If the user cannot control the player, then return. if (canControl == false) { return; } // If the shooting joystick is being used and the shooting timer is ready... if (UltimateJoystick.GetJoystickState("Shooting") && shootingTimer <= 0) { // Then reset the timer and shoot a bullet. shootingTimer = shootingCooldown; CreateBullets(); } // If the shoot timer is above zero, reduce it. if (shootingTimer > 0) { shootingTimer -= Time.deltaTime; } }
void Update() { if (Container == null) { return; } var offset = TileDataProvider.WorldPosToOffsetTile(pysicItem.GetBottomPos()); bool isStairs = MapGenerator.GetTile(new Vector2Int(offset.x, offset.y)).IsStairs(); joystickH = UltimateJoystick.GetHorizontalAxis("Joystick1"); joystickV = UltimateJoystick.GetVerticalAxis("Joystick1"); //jamp if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W) /*|| (joystickV >= 0 && joystickV < 0.4)*/) { if (oldJampFrame != Time.frameCount && (Collision.Raycast(pysicItem.Position, viewReciver.size, Vector2.down).Count != 0 || isStairs)) { countJampFrame = 0; pysicItem.AddVelocity(new Vector2(0, -pysicItem.velocity.y)); oldJampFrame = Time.frameCount; } } //jamp isStairs if (isStairs && (Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W) || joystickV > .5)) { pysicItem.ApplayVelocity(new Vector2(0, 4)); } // Down if (oldDownFrame != Time.frameCount && Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S) || joystickV < -.5) { pysicItem.AddVelocity(new Vector2(0, -Speed)); oldDownFrame = Time.frameCount; if (isStairs) { pysicItem.ApplayVelocity(new Vector2(0, -4)); } } // Left if (oldLeftFrame != Time.frameCount && Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A) || (joystickH < -.2)) { var speed = joystickH != 0 ? Speed * joystickH : -Speed; pysicItem.AddVelocity(new Vector2(speed, 0)); oldLeftFrame = Time.frameCount; controller.Rotat(-1); if (!isStairs) { if (Collision.Raycast(pysicItem.Position, viewReciver.size, Vector2.down).Count != 0) { var countTile = MaskManager.GetMaskLJamp(pysicItem.GetBottomLeftPos()); if (countTile > 0) { pysicItem.AddVelocity(new Vector2(0, -pysicItem.velocity.y)); pysicItem.SetPosition(new Vector2(pysicItem.Position.x - 1, pysicItem.Position.y + 16 * countTile + 1)); } } } } // Right if (oldRightFrame != Time.frameCount && Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D) || (joystickH > .2)) { var speed = joystickH != 0 ? Speed * joystickH : Speed; pysicItem.AddVelocity(new Vector2(speed, 0)); oldRightFrame = Time.frameCount; controller.Rotat(1); if (!isStairs) { if (Collision.Raycast(pysicItem.Position, viewReciver.size, Vector2.down).Count != 0) { var countTile = MaskManager.GetMaskRJamp(pysicItem.GetBottomRightPos()); //Debug.LogError(countTile); if (countTile > 0) { pysicItem.AddVelocity(new Vector2(0, -pysicItem.velocity.y)); pysicItem.SetPosition(new Vector2(pysicItem.Position.x + 1, pysicItem.Position.y + 16 * countTile + 1)); } } } } var joystickH2 = UltimateJoystick.GetHorizontalAxis("Joystick2"); var joystickV2 = UltimateJoystick.GetVerticalAxis("Joystick2"); bool joystick = Vector2.Distance(new Vector2(joystickH2, joystickV2), Vector2.zero) > 0.1; bool joystick0 = UltimateJoystick.GetIsDown("Joystick1"); var pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (!Settings.IS_EDIT_MOD && ( (!joystick0 || joystick0 && joystick) && (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.LeftControl) || joystick)) && !UICamera.IsGuiClick) { if (model.CurrentWeapon != null) { if (!joystick) { var dir = (pos - transform.position).normalized; controller.Rotat(dir.x); } else { controller.Rotat(joystickH2); } model.CurrentWeapon.Fire(pos, joystick); } } if (((!Settings.IS_EDIT_MOD) && ( (!joystick0 || joystick0 && joystick) && (Input.GetMouseButton(0) || Input.GetKey(KeyCode.LeftControl) || joystick)) && !UICamera.IsGuiClick)) { if (model.CurrentWeapon != null) { if (!joystick) { var dir = (pos - transform.position).normalized; controller.Rotat(dir.x); } else { controller.Rotat(joystickH2); } model.CurrentWeapon.FireCycle(pos, joystick); } } if (model.CurrentWeapon != null) { var rot = pos; if (joystick) { var v = UltimateJoystick.GetVerticalAxis("Joystick2"); var h = UltimateJoystick.GetHorizontalAxis("Joystick2"); rot = transform.position + new Vector3(h, v) * 100; } model.CurrentWeapon.Rotate(rot); } //Bag if (Input.GetKeyDown(KeyCode.Alpha1)) { model.UseItem(1); } if (Input.GetKeyDown(KeyCode.Alpha2)) { model.UseItem(2); } if (Input.GetKeyDown(KeyCode.Alpha3)) { model.UseItem(3); } if (Input.GetKeyDown(KeyCode.Alpha4)) { model.UseItem(4); } if (Input.GetKeyDown(KeyCode.Alpha5)) { model.UseItem(5); } if (Input.GetKeyDown(KeyCode.Alpha6)) { model.UseItem(6); } if (Input.GetKeyDown(KeyCode.Alpha7)) { model.UseItem(7); } if (Input.GetKeyDown(KeyCode.Alpha8)) { model.UseItem(8); } if (Input.GetKeyDown(KeyCode.Alpha9)) { model.UseItem(9); } }