public void OnTriggerEnter(Collider other) { TargetCube targetCube = other.GetComponent <TargetCube>(); if (targetCube != null) { targetCube.DestroyObject(); } }
// Use this for initialization void Start() { height = ColliderHeight * transform.lossyScale.y; width = ColliderWidth * transform.lossyScale.x; tc = GetComponent <TargetCube>(); inertia = mass / 12.0f * (height * height + width * width); gravityVector = new Vector2(0, -gravityConstant); LinearVelocity = new Vector2(0, 0); AngularVelocity = 0.0f; }
public void OnTriggerEnter(Collider other) { TargetCube targetCube = other.GetComponentInParent <TargetCube>(); if (targetCube != null) { bool hasEnoughVelocity = (saberEdgeVelocity.magnitude >= GameManager.Instance.slashIntensityThreshold) ? true : false; bool hasCorrectAngle = (Vector3.Dot(-targetCube.transform.up, saberEdgeVelocity.normalized) >= GameManager.Instance.slashAngleThreshold) ? true : false; if (hasEnoughVelocity && hasCorrectAngle && saberColor == targetCube.cubeColor) { targetCube.CorrectHit(); VRControllerManager.instance.PlayHaptic(transform.parent.gameObject, 10, .1f, .01f); } else { targetCube.DestroyObject(); } } }
public void SetActive(bool state) { if (m_Renderer == null) { m_Renderer = GetComponent <Renderer>(); } m_Renderer.material.color = state ? m_ActiveColor : m_InActiveColor; var size = new Vector3(1, 1, 0.1F); transform.localScale = state ? Vector3.one * 0.4F : Vector3.one * 0.25F; if (state == true) { m_SelectedTarget = this; } if (state == false && m_SelectedTarget == this) { m_SelectedTarget = null; } }