public void OnTriggerExit2D(Collider2D collision) { if (collision.tag == "Player") // player has left the range { interacting_state = InteractingStates.NO_RANGE_TO_INTERACT; Destroy(GameObject.Find("InteractingAnim(Clone)")); if (dialog_panel != null) { Destroy(dialog_panel); } } }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player") // player in range now { interacting_state = InteractingStates.WAITING_INTERACTION; GameObject obj = Instantiate(interacting_anim); obj.transform.position = new Vector3( transform.position.x + GetComponentInParent <SpriteRenderer>().size.x / 2 - obj.GetComponent <SpriteRenderer>().size.x / 2, transform.position.y, transform.position.z); Debug.Log(GetComponentInParent <SpriteRenderer>().size.x); } }
public void Update() { if (interacting_state == InteractingStates.WAITING_INTERACTION) // player is in range to talk { if (Input.GetButtonDown("Interact")) // player begins talking { interacting_state = InteractingStates.INTERACTING; dialog_panel = Instantiate(copy_panel); // create the prefab of the dialog panel // set the dialog data and pass it to the dialog manager DialogManager.DialogData data; data.actual_node = actual_node; data.dialog_node = dialog_node; data.dialog_panel = dialog_panel; data.interactive_target = gameObject; data.portrait_npc = portrait_npc; data.name_npc = npc_name; GameObject.Find("DialogManager").SendMessage("StartDialog", data); } } }
public void SetToWaitingInteraction() { GameObject.Find("GameController").GetComponent <GameController>().SaveNPC(actual_node.node_id, dialog_type); interacting_state = InteractingStates.WAITING_INTERACTION; }