// Update is called once per frame void Update() { h = UltimateJoystick.GetHorizontalAxis("WSJ"); v = UltimateJoystick.GetVerticalAxis("WSJ"); t1 = UltimateJoystick.GetJoystickState("WSJ"); t2 = UltimateJoystick.GetTapCount("WSJ"); }
void Update() { // Store the input positions movePosition = UltimateJoystick.GetPosition("Movement"); shootPosition = UltimateJoystick.GetPosition("Shooting"); // 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; } }
// 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 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); }
void FixedUpdate() { // If the user cannot control the player... if (canControl == false) { // Then reset the player's rotation, position, velocity and angular vel. myRigidbody.rotation = Quaternion.identity; myRigidbody.position = Vector3.zero; myRigidbody.velocity = Vector3.zero; myRigidbody.angularVelocity = Vector3.zero; } else { // Figure out the rotation that the player should be facing and apply it. Vector3 lookRot = new Vector3(movePosition.x, 0, movePosition.y); transform.LookAt(transform.position + lookRot); // Also figure out the rotation of the player's gun and apply it. Vector3 gunRot = new Vector3(shootPosition.x, 0, shootPosition.y); gunTrans.LookAt(gunTrans.position + gunRot); // Apply the input force to the player. myRigidbody.AddForce(transform.forward * UltimateJoystick.GetDistance("Movement") * 1000.0f * accelerationSpeed * Time.deltaTime); // If the player's force is greater than the max speed, then normalize it. if (myRigidbody.velocity.magnitude > maxSpeed) { myRigidbody.velocity = myRigidbody.velocity.normalized * maxSpeed; } // Run the CheckExitScreen function to see if the player has left the screen. CheckExitScreen(); } }
void FixedUpdate() { Vector2 launchStick = UltimateJoystick.GetPosition("LaunchStick"); if (launchStick.magnitude > 0) { this.ForceAmount = Mathf.Lerp(this.ForceAmountMin, this.ForceAmountMax, launchStick.magnitude); } if ((launchStick.x > 0) && (launchStick.y >= 0)) { if (this.PathRenderer != null) { this.PathRenderer.Enable(); } this.ForceAngle = Vector2.Angle(launchStick, Vector2.right); this.ForceAngle = Mathf.Clamp(this.ForceAngle, this.ForceAngleMin, this.ForceAngleMax); } else if ((launchStick.x < 0) && (launchStick.y <= 0)) { if (this.PathRenderer != null) { this.PathRenderer.Enable(); } this.ForceAngle = Vector2.Angle(launchStick, Vector2.left); this.ForceAngle = Mathf.Clamp(this.ForceAngle, 0.0f, 45.0f); } else if ((launchStick.x == 0) && (launchStick.y == 0)) { if (this.PathRenderer != null) { this.PathRenderer.Disable(); } } }
//private void Start() //{ // WeaponOff(); // Level = 1; // respawnPoint = GameObject.FindGameObjectWithTag("Respawn").GetComponent<Transform>(); //부활장소 // loading = FindObjectOfType<LoadingScript>(); //로딩창 // expBar = GameObject.Find("ExpBar").GetComponent<Image>(); // hpBar = GameObject.Find("Hp").GetComponent<Image>(); // expText = GameObject.Find("ExpText").GetComponent<Text>(); // playerName = GameObject.Find("PlayerNickName").GetComponent<Text>(); // smooth = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<SmoothFollow>(); private void Start() { Joystick = GameObject.Find("Joystick").GetComponent <UltimateJoystick>(); //WeaponOff(); // 전재현 추가 Level = 1; // 전재현 추가 respawnPoint = GameObject.FindGameObjectWithTag("Respawn").GetComponent <Transform>(); //부활장소 loading = FindObjectOfType <LoadingScript>(); //로딩창 expBar = GameObject.Find("ExpBar").GetComponent <Image>(); //경험치 바 hpBar = GameObject.Find("Hp").GetComponent <Image>(); //hp 바 expText = GameObject.Find("ExpText").GetComponent <Text>(); playerName = GameObject.Find("PlayerNickName").GetComponent <Text>(); smooth = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <SmoothFollow>(); // monster = GameObject.FindGameObjectWithTag("Enemy").GetComponent<Monster>(); CoolTime = GameObject.FindGameObjectsWithTag("skill"); for (int i = 0; i < 3; i++) { CoolTime[i].GetComponent <Image>().color = new Color(41f / 255f, 9f / 255f, 9f / 255f, 0f / 255f); } equipmentManager.WeaponSet(0); // 전재현 추가 colOnce = false; // 전재현 추가 playerName.text = PhotonNetwork.player.NickName; isPlayerMove = false; respawnBtn = GameObject.Find("RespawnBtn").GetComponent <Button>(); }
/* -----< DECLARATIONS - END >----- */ void Start() { //Find Objects nc = GameObject.FindObjectOfType <NumberCruncher>(); myJoystick = GameObject.FindObjectOfType <UltimateJoystick>(); myFire = GameObject.FindObjectOfType <UltimateButton>(); levelManager = GameObject.FindObjectOfType <LevelManager>(); //TODO: Add comments to whole section float distance = transform.position.z - Camera.main.transform.position.z; Vector3 leftmost = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distance)); Vector3 rightmost = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, distance)); xmin = leftmost.x + padding; xmax = rightmost.x - padding; //Get the size of the player controls from the PPM //Also applies changes made to the controls in the setting menu myJoystick.joystickSize = PlayerPrefsManager.ControlsSize_Get(); myFire.buttonSize = PlayerPrefsManager.ControlsSize_Get(); myFire.UpdatePositioning(); // ask UB to update our changes myJoystick.UpdatePositioning(); // ask UJ to update our changes } //Start() -end
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(); }
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); }
/// <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); }
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); }
void SetDisableVisuals(UltimateJoystick targ) { if (targ.disableVisuals == true) { if (targ.showHighlight == true) { targ.showHighlight = false; } if (targ.showTension == true) { targ.showTension = false; } if (targ.joystickBase != null && targ.joystickBase.GetComponent <Image>().enabled == true) { targ.joystickBase.GetComponent <Image>().enabled = false; } if (targ.joystick != null && targ.joystick.GetComponent <Image>().enabled == true) { targ.joystick.GetComponent <Image>().enabled = false; } } else { if (targ.joystickBase != null && targ.joystickBase.GetComponent <Image>().enabled == false) { targ.joystickBase.GetComponent <Image>().enabled = true; } if (targ.joystick != null && targ.joystick.GetComponent <Image>().enabled == false) { targ.joystick.GetComponent <Image>().enabled = true; } } }
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 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); } } }
void SetHighlight(UltimateJoystick targ) { if (targ.showHighlight == true) { if (targ.highlightBase != null && targ.highlightBase.gameObject.activeInHierarchy == false) { targ.highlightBase.gameObject.SetActive(true); } if (targ.highlightJoystick != null && targ.highlightJoystick.gameObject.activeInHierarchy == false) { targ.highlightJoystick.gameObject.SetActive(true); } targ.UpdateHighlightColor(targ.highlightColor); } else { if (targ.joystick == null) { return; } if (targ.highlightBase != null && targ.highlightBase != targ.joystickBase.GetComponent <Image>() && targ.highlightBase.gameObject.activeInHierarchy == true) { targ.highlightBase.gameObject.SetActive(false); } if (targ.highlightJoystick != null && targ.highlightJoystick != targ.joystick.GetComponent <Image>() && targ.highlightJoystick.gameObject.activeInHierarchy == true) { targ.highlightJoystick.gameObject.SetActive(false); } } }
// Update is called once per frame void FixedUpdate() { pushObjectBackInFrustum(Player); Vector2 moveDirection = UltimateJoystick.GetPosition("Movement"); Vector2 movement = new Vector2(moveDirection.x, moveDirection.y); transform.Translate(movement * Speed * Time.deltaTime); }
public void Init() { string joystickName = GetComponent <UltimateJoystick>().joystickName; m_Joystick = UltimateJoystick.GetJoystick(joystickName); m_IsActive = true; }
public override void UpdateInput() { Vector2 movePosition = UltimateJoystick.GetPosition(MoveJoystickName); if (OnMove != null) { OnMove(movePosition); } }
private void DisableStick(string name) { UltimateJoystick s = UltimateJoystick.GetJoystick(name); if (s != null) { CanvasGroup cg = s.GetComponent <CanvasGroup>(); cg.alpha = 0.0f; } }
void Update() { if (UltimateJoystick.GetJoystickState("Fire1")) { if (IsFiring == false) { StartCoroutine(FiringPistol()); } } }
private void Update() { if (!m_Jump) { // Modified by Kaz Crowe. Get the count of the 'Camera' joystick to catch when the user has acheived the tap count. m_Jump = UltimateJoystick.GetTapCount("Look"); //m_Jump = CrossPlatformInputManager.GetButtonDown("Jump"); // If you want a nice and easy UI Button to use for your Mobile Games, please see the Ultimate Button package on the Unity Asset Store. // Asset Store Link: https://www.assetstore.unity3d.com/en/#!/content/28824 } }
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); } }
Vector2 GetJoystickDir() { Vector2 dir = UltimateJoystick.GetPosition("MoveJoystick"); if (dir.magnitude > 0) { if (Mathf.Abs(dir.x) > Mathf.Abs(dir.y)) { return(Mathf.Sign(dir.x) * Vector2.up); } else { return(-Mathf.Sign(dir.y) * Vector2.right); } } return(Vector2.zero); }
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; } }
void SetAnimation(UltimateJoystick targ) { if (targ.useAnimation == true) { if (targ.joystickAnimator != null && targ.joystickAnimator.enabled == false) { targ.joystickAnimator.enabled = true; } } else { if (targ.joystickAnimator != null && targ.joystickAnimator.enabled == true) { targ.joystickAnimator.enabled = false; } } }
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; } }
void ResetTouchActions( UltimateJoystick uj ) { uj.tapCountOption = UltimateJoystick.TapCountOption.NoCount; uj.tapCountDuration = 0.5f; uj.targetTapCount = 2; uj.useAnimation = false; uj.SetAnimation(); uj.useFade = false; uj.fadeUntouched = 1.0f; uj.fadeTouched = 0.5f; uj.HandleFade( "Reset" ); }
void SetAnimation( UltimateJoystick uj ) { if( uj.useAnimation == true ) { if( uj.joystickAnimator != null ) if( uj.joystickAnimator.enabled == false ) uj.joystickAnimator.enabled = true; } else { if( uj.joystickAnimator != null ) if( uj.joystickAnimator.enabled == true ) uj.joystickAnimator.enabled = false; } }
void ResetSizeAndPlacement( UltimateJoystick uj ) { uj.joystickTouchSize = UltimateJoystick.JoystickTouchSize.Default; uj.joystickSize = 2.5f; uj.radiusModifier = 4.5f; uj.touchBasedPositioning = false; uj.overrideTouchSize = false; uj.tbp_X = 50.0f; uj.tbp_Y = 75.0f; uj.cs_X = 5.0f; uj.cs_Y = 20.0f; }
CanvasScaler GetParentCanvas( UltimateJoystick joystick ) { Transform parent = joystick.transform.parent; while( parent != null ) { if( parent.transform.GetComponent<CanvasScaler>() ) return parent.transform.GetComponent<CanvasScaler>(); parent = parent.transform.parent; } return null; }
void ResetStyleAndOptions( UltimateJoystick uj ) { uj.touchPad = false; uj.throwable = true; uj.throwDuration = 0.5f; uj.showHighlight = true; uj.highlightColor = new Color( 0.118f, 0.992f, 0.0f, 1.0f ); uj.SetHighlight(); uj.showTension = true; uj.tensionColorNone = new Color( 0.118f, 0.992f, 0.0f, 0.0f ); uj.tensionColorFull = new Color( 0.118f, 0.992f, 0.0f, 1.0f ); uj.SetTensionAccent(); uj.axis = UltimateJoystick.Axis.Both; uj.boundary = UltimateJoystick.Boundary.Circular; }
void TensionAccentReset( UltimateJoystick uj ) { uj.tensionAccentUp.color = uj.tensionColorNone; uj.tensionAccentDown.color = uj.tensionColorNone; uj.tensionAccentLeft.color = uj.tensionColorNone; uj.tensionAccentRight.color = uj.tensionColorNone; }
void SetTouchPad( UltimateJoystick ult ) { if( ult.touchPad == true ) { if( ult.showHighlight == true ) ult.showHighlight = false; if( ult.showTension == true ) ult.showTension = false; if( ult.dynamicPositioning == false ) ult.dynamicPositioning = true; if( ult.joystickBase != null && ult.joystickBase.GetComponent<Image>().enabled == true ) ult.joystickBase.GetComponent<Image>().enabled = false; if( ult.joystick.GetComponent<Image>().enabled == true ) ult.joystick.GetComponent<Image>().enabled = false; } else { if( ult.joystickBase != null ) { if( ult.joystickBase.GetComponent<Image>().enabled == false ) ult.joystickBase.GetComponent<Image>().enabled = true; } if( ult.joystick.GetComponent<Image>().enabled == false ) ult.joystick.GetComponent<Image>().enabled = true; } }
void SetTensionAccent( UltimateJoystick uj ) { if( uj.showTension == true ) { if( uj.tensionAccentUp == null || uj.tensionAccentDown == null || uj.tensionAccentLeft == null || uj.tensionAccentRight == null ) return; if( uj.tensionAccentUp != null && uj.tensionAccentUp.gameObject.activeInHierarchy == false ) uj.tensionAccentUp.gameObject.SetActive( true ); if( uj.tensionAccentDown != null && uj.tensionAccentDown.gameObject.activeInHierarchy == false ) uj.tensionAccentDown.gameObject.SetActive( true ); if( uj.tensionAccentLeft != null && uj.tensionAccentLeft.gameObject.activeInHierarchy == false ) uj.tensionAccentLeft.gameObject.SetActive( true ); if( uj.tensionAccentRight != null && uj.tensionAccentRight.gameObject.activeInHierarchy == false ) uj.tensionAccentRight.gameObject.SetActive( true ); TensionAccentReset( uj ); } else { if( uj.tensionAccentUp != null && uj.tensionAccentUp.gameObject.activeInHierarchy == true ) uj.tensionAccentUp.gameObject.SetActive( false ); if( uj.tensionAccentDown != null && uj.tensionAccentDown.gameObject.activeInHierarchy == true ) uj.tensionAccentDown.gameObject.SetActive( false ); if( uj.tensionAccentLeft != null && uj.tensionAccentLeft.gameObject.activeInHierarchy == true ) uj.tensionAccentLeft.gameObject.SetActive( false ); if( uj.tensionAccentRight != null && uj.tensionAccentRight.gameObject.activeInHierarchy == true ) uj.tensionAccentRight.gameObject.SetActive( false ); } }
void SetHighlight( UltimateJoystick uj ) { if( uj.showHighlight == true ) { if( uj.highlightBase != null && uj.highlightBase.gameObject.activeInHierarchy == false ) uj.highlightBase.gameObject.SetActive( true ); if( uj.highlightJoystick != null && uj.highlightJoystick.gameObject.activeInHierarchy == false ) uj.highlightJoystick.gameObject.SetActive( true ); uj.UpdateHighlightColor( uj.highlightColor ); } else { if( uj.highlightBase != null && uj.highlightBase.gameObject.activeInHierarchy == true ) uj.highlightBase.gameObject.SetActive( false ); if( uj.highlightJoystick != null && uj.highlightJoystick.gameObject.activeInHierarchy == true ) uj.highlightJoystick.gameObject.SetActive( false ); } }