void Update() { /* A décommenter pour utiliser la méthode utilisant la distance entre l'objet cible et la main virtuelle right_hand_rv_position = right_hand_rv.transform.position; cible_position = this.transform.position; distance = (cible_position - right_hand_rv_position).magnitude; if (distance < 0.3F & selectionnable == false) { Debug.Log("Enter"); etat = Etats_cible.SELECTIONNABLE; old_color = this.renderer.material.color; this.renderer.material.color = new Color(1.0F, 0.0F, 0.0F); } else if (distance >= 0.3F & selectionnable == true) { Debug.Log("Exit"); etat = Etats_cible.RAS; this.renderer.material.color = old_color; }*/ if (etat == Etats_cible.SELECTIONNABLE & this.transform.parent == null & left_hand.b1 == true) { etat = Etats_cible.SELECTIONNE; this.transform.parent = right_hand_rv.transform; } if (etat == Etats_cible.SELECTIONNE & left_hand.b1 == false) { this.transform.parent = null; } }
void OnTriggerExit(Collider other) { if (other.gameObject.name == right_hand_rv.name) { Debug.Log("Exit"); etat = Etats_cible.LIBRE; this.GetComponent<Renderer>().material.color = old_color; } }
// Update is called once per frame void OnTriggerEnter(Collider other) { if (other.gameObject.name == right_hand_rv.name) { Debug.Log("Enter"); etat = Etats_cible.SELECTIONNABLE; old_color = this.GetComponent<Renderer>().material.color; this.GetComponent<Renderer>().material.color = new Color(1.0F, 0.0F, 0.0F); } }
// Use this for initialization void Start() { etat = Etats_cible.LIBRE; right_hand_rv_position = new Vector3(0.0F, 0.0F, 0.0F); cible_position = new Vector3(0.0F, 0.0F, 0.0F); }