void Start() { if (j.Count == 2) { if (!j[0].isLeft) { Debug.Log("Inverted JoyCons"); Joycon tmp; tmp = j[0]; j[0] = j[1]; j[1] = tmp; } for (int i = 0; i < j.Count; ++i) { Debug.Log(i); Joycon jc = j[i]; byte LEDs = 0x0; LEDs |= (byte)(0x1 << i); jc.Attach(leds_: LEDs); jc.Begin(); } } else { Debug.Log("No connected JoyCons"); } }
protected void UpdateHandRotation() { // make sure the Joycon only gets checked if attached if (joycons.Count > 0) { currentJoycon = joycons [jc_ind]; // j.SetRumble (160, 320, 0.2f, 200); // Then call SetRumble(0,0,0) when you want to turn it off. stick = currentJoycon.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = currentJoycon.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = currentJoycon.GetAccel(); orientation = currentJoycon.GetVector(); //Vector3 v = orientation.eulerAngles; gameObject.transform.rotation = orientation; //SetRotation(); eulerAngle = orientation.eulerAngles; } }
private void Start() { centerCamera = GameObject.FindGameObjectWithTag("MainCamera"); initPos = item.transform.position; joyconLeft = JoyconHelper.GetLeftJoycon(); joyconRight = JoyconHelper.GetRightJoycon(); }
void FixedUpdate() { if (joycons.Count > 0) { Joycon j = joycons [jc_ind]; if (j.GetButtonUp(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 released"); rb.useGravity = true; //Debug.Log (transform.forward); accel = j.GetAccel(); Debug.Log(accel); // Joycon x axis is the same as Unity's y axis float upForce = System.Math.Abs(accel.x); // Joycon z axis is the same as Unity's z axis float forwardForce = System.Math.Abs(accel.z); Vector3 force = new Vector3(0, upForce, forwardForce) * thrust; rb.AddForce(force); } if (j.GetButtonDown(Joycon.Button.DPAD_UP)) { reset(); } } }
void FixedUpdate() { if (joycons.Count > 0) { Joycon j = joycons [jc_ind]; if (j.GetButtonUp(Joycon.Button.SHOULDER_2)) { ActiveBag.Throw(j); } if (j.GetButtonDown(Joycon.Button.DPAD_UP)) { ActiveBag.Reset(); } if (j.GetButton(Joycon.Button.DPAD_LEFT)) { ActiveBag.Move(false); } if (j.GetButton(Joycon.Button.DPAD_RIGHT)) { ActiveBag.Move(true); } if (j.GetButtonDown(Joycon.Button.DPAD_DOWN)) { ActiveBag = gameObject.AddComponent <Application.Bag>(); } // if (j.GetButton(Joycon.Button.STICK)) { // var stickX = j.GetStick()[0]; // if (Mathf.Abs(stickX) > 0.2) { // rotateBag(stickX); // } // } } }
// Update is called once per frame void Update() { if (joycons.Count > 0) { Joycon j = joycons[main.currentJoyconMouth]; if (CheckShake() && canSnap) { snaping = true; } if (snaping && canSnap) { Snap(); } } if (cooldown < cooldownAfterSwap) { cooldown += Time.deltaTime; } else { canSnap = true; } }
// Use this for initialization void Start() { // Load all the gestures from disk foreach (Gesture gesture in gestures) { gesture.LoadData(); } // Grab joycons from JoyconManager foreach (Joycon jc in JoyconManager.Instance.j) { if (jc.isLeft) { leftJoycon = jc; } if (!jc.isLeft) { rightJoycon = jc; } } if (leftJoycon == null || rightJoycon == null) { Debug.LogError("Unable to find left and right joycon!"); Destroy(gameObject); } }
private void GetInput(out float speed) { Joycon j = JoyconManager.Instance.j[1]; float[] position = j.GetStick(); // Read input float horizontal = position[0]; float vertical = position[1]; 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()); } }
void Start() { instance = this; rigidbody = GetComponent <Rigidbody2D>(); collider = GetComponent <Collider2D>(); diaryIsRead = false; nearCloset = false; nearDiary = false; isHidden = false; isReading = false; music = GameObject.Find("MusicManager").GetComponent <MusicManager>(); wallbump = 0; source = GetComponents <AudioSource>(); test = true; realDistance = (boss.transform.position - transform.position).magnitude; distance = 0; rad = 0.0f; gyro = new Vector3(0, 0, 0); accel = new Vector3(0, 0, 0); // get the public Joycon array attached to the JoyconManager in scene joycons = JoyconManager.Instance.j; j = joycons [jc_ind]; flashlight = GetComponent <RayLight2D>(); StartCoroutine("HeartBeat"); }
// Update is called once per frame void FixedUpdate() { if (joycons.Count > 0) { if (Input.GetButtonDown("Fire2")) { transform.rotation = joycons[jc_ind].GetVector(); } Joycon j = joycons[jc_ind]; accel = j.GetAccel(); accelMagnitude = accel.magnitude; orientation = j.GetVector(); body.MoveRotation(orientation); } else { float xRot = Input.GetAxis("Horizontal"); float yRot = Input.GetAxis("Vertical"); //float zRot = Input.GetAxis("Yaw"); //rotDir = new Vector3(xRot, yRot, zRot).normalized; //body.MoveRotation(body.rotation * Quaternion.Euler(rotDir * rotSpeed)); Quaternion deltaRotation = Quaternion.AngleAxis(xRot * rotSpeed, Vector3.down) * Quaternion.AngleAxis(yRot * rotSpeed, Vector3.right); body.MoveRotation(deltaRotation.normalized * transform.rotation); } }
// Update is called once per frame void Update() { Joycon j = joycons[jc_ind]; //Tekst wordt omgezet naar Goed bezig! warning.text = "Goed bezig!"; if (currentForce.joint.currentForce[1] > -600) { alreadyPlayed = false; } //Als de force op as Y lager is dan -700 dan moet de tekst "Je knie mag niet voorbij je tenen!" zijn. if (currentForce.joint.currentForce[1] < -600) { Debug.Log("Rumble"); //Verstuurt rumble naar joy-con wanneer knie te ver naar voren staat. j.SetRumble(160, 160, 0.6f, 1000); warning.text = "Je knie mag niet voorbij je tenen!"; if (!alreadyPlayed) { if (feedbackSound != null) { audioSource.PlayOneShot(feedbackSound, 0.7f); alreadyPlayed = true; } } } }
void CleanUp() { // removes dropped controllers from list List <Joycon> rem = new List <Joycon>(); for (int i = 0; i < j.Count; i++) { Joycon v = j[i]; if (v.state == Joycon.state_.DROPPED) { if (v.other != null) { v.other.other = null; // The other of the other is the joycon itself } v.Detach(); rem.Add(v); foreach (Button b in mActivity.con) { if (b.Enabled & b.Tag == (Object)v) { b.SetBackgroundColor(Android.Graphics.Color.Gray); //= System.Drawing.Color.FromArgb(0x00, System.Drawing.SystemColors.Control); b.Enabled = false; b.SetBackgroundResource(Resource.Drawable.cross); break; } } mActivity.AppendTextBox("Removed dropped controller to list. Can be reconnected.\r\n"); } } foreach (Joycon v in rem) { j.Remove(v); } }
void Start() { gyro = new Vector3(0, 0, 0); accel = new Vector3(0, 0, 0); // get the public Joycon object attached to the JoyconManager in scene j = JoyconManager.Instance.j; }
// Update is called once per frame void Update() { if (isMoving) { transform.position = new Vector3(playerTrfm.position.x + posXfromPlayer, transform.position.y, transform.position.z); chargeTime += Time.deltaTime; if (chargeTime >= attackInterval) { Attack(); chargeTime %= attackInterval; } } // ジョイコンで回転させる //rb.MoveRotation(actionInput.GetJoyconAngle() + startAngle); //koitan if (m_joyconR == null) { var joycons = JoyconManager.Instance.j; m_joyconR = joycons.Find(c => !c.isLeft); return; } if (m_joyconR.GetButtonDown(Joycon.Button.SHOULDER_2)) { m_joyconR.Recenter(); } }
void SetKeys(ref Keys key, Joycon joycon) { key.JoyStick.x = joycon.GetStick()[0]; key.JoyStick.y = joycon.GetStick()[1]; key.JoyGyro = joycon.GetGyro(); key.JoyAccel = joycon.GetAccel(); key.JoyRad = joycon.GetVector(); Vector3 gy = key.JoyGyro; gy.x = -key.JoyGyro.y; gy.z = -key.JoyGyro.x; gy.y = key.JoyGyro.z; key.JoyGyro = gy; Vector3 ac = key.JoyGyro; ac.x = -key.JoyAccel.y; ac.z = -key.JoyAccel.x; ac.y = 0f;//key.JoyAccel.z; key.JoyAccel = ac; //なぜか↑のほうむくから補正 key.JoyGyro.x += 0.01f; }
void Update() { for (int i = 0; i < j.Count; ++i) { Joycon jc = j [i]; jc.Update(); } }
void Start() { j = JoyconManager.Instance.j[joyconID]; if (j == null) { Destroy(gameObject); } }
public override bool GetButtonDown(Joycon joycon) { bool last = GetButton(joycon); joycon.Update(); return(!last && GetButton(joycon)); }
public override bool GetButtonUp(Joycon joycon) { bool last = GetButton(joycon); joycon.Update(); return(last && !GetButton(joycon)); }
void OnApplicationQuit() { for (int i = 0; i < j.Count; ++i) { Joycon jc = j [i]; jc.Detach(); } }
// Get the Joycon object; note that the JoyconManager is required. private void Start() { // Get the public Joycon object attached to the JoyconManager in scene j = JoyconManager.Instance.j; rotationSpeed = 100.0f; currentPos = transform.position; }
void Start() { joycons = JoyconManager.Instance.j; if (joycons.Count > 0) { j = joycons[jc_ind]; } }
// Use this for initialization void Start() { if (!useKeys) { joycons = JoyconManager.Instance.j; j = joycons[controllerID]; } }
void Start() { joyconManager = JoyconManager.Instance; joycon = joyconManager.GetJoycon(joyconType); // get the public Joycon array attached to the JoyconManager in scene joycons = JoyconManager.Instance.j; }
// Use this for initialization void Start() { firePoint = transform.Find("FirePoint"); joycons = JoyconManager.Instance.j; if (joycons.Count > 0) { j = joycons[jc_ind]; } }
// Use this for initialization void Start() { joycons = JoyconManager.Instance.j; // joycon = joycons.Find(con => con.isLeft); joycon = joycons.Find(con => !con.isLeft); didScattered = false; }
void Start() { selected = false; joycons = JoyconManager.Instance.j; if (joycons.Count > 0) { j = joycons[jc_ind]; } }
void Awake() { if (instance != null) { Destroy(gameObject); } instance = this; j = new Joycon(); }
void BreakRumbles() { Joycon j = main.joycons[main.currentJoyconMouth]; j.SetRumble(0f, 0f, 0f); j = main.joycons[main.currentJoyconPlayer]; j.SetRumble(0f, 0f, 0f); }
// Update is called once per frame void Update() { if (joycons.Count > 0) { Joycon j = joycons[jc_ind]; gyro = j.GetGyro(); gameObject.transform.position.Set(gyro.x, gyro.y, 0); } }