// Use this for initialization public void Initialize(bool vrPlayer) { if (!vrPlayer) { transform.SetParent(null); if (!gameObject.activeSelf) { gameObject.SetActive(true); } initialized = true; } else { steamVRController = SteamVR_Controller.Input((int)controller.index); if (!steamVRController.valid) { Debug.LogError(gameObject.name + " on device index " + controller.index + "is not Active!"); } else { initialized = true; } if (initialized) { transform.localScale = new Vector3(.02f, .02f, 1); transform.SetParent(controller.transform); transform.localPosition = new Vector3(0, 0, .4f); transform.localRotation = Quaternion.identity; } } thisRigidBody = GetComponent <Rigidbody>(); selector = GetComponentInChildren <SaberSelector>(); isLeft = gameObject.name.ToLower().Contains("left"); boxCollider = GetComponent <BoxCollider>(); notesInContact = new List <Note>(); previousPosition = transform.position; vibrationQueue = new List <VibrationRequest>(); }
private void OnTriggerEnter(Collider other) { if (IsGrabbed()) { return; } SaberSelector selector = other.GetComponent <SaberSelector>(); if (selector == null) { selector = other.GetComponentInChildren <SaberSelector>(); } if (selector == null) { return; } selector.Attach(gameObject); /*Saber saber = other.gameObject.transform.GetComponentInParent<Saber>(); * if (saber != null) * { * float zPoint = Vector3.Distance() * float relativeZ = (totalBeats/currentWidthOfMinimap) * zPoint; * if (relativeZ < currentWidthOfMinimap) relativeZ = currentWidthOfMinimap; * else if (relativeZ > totalBeats) relativeZ = totalBeats; * Debug.LogWarning("relative z - " + relativeZ); * BeatMap.SkipToBeat(BeatMap.RoundToRelativeBeat(relativeZ,BeatMap.currentNoteMode)); * Vector3 newposition = new Vector3(transform.position.x, transform.position.y, * currentWidthOfMinimap - ((currentWidthOfMinimap / totalBeats * 2) * relativeZ)); * transform.position = newposition; * Update(); * } * else * { * BeatMap.Log("saber NOT found"); * }*/ }