- Home /
How do I get character dialogue to pop up?
Hi. I'm an artist, and have little experience with code. I'm trying to get characters to appear with dialogue when a character reaches a certain area. Like this, with a button click to bring the next one.
My lack of experience with code means I'm probably not using the right key terms when I search in google.
Can any of you help me?
Answer by IrshadKhan_ · Apr 19, 2015 at 06:12 PM
using OnMouseDown Function and switch statement think for logic read unity document
for example
public int tmpswthc;
public string tmpmsg;
public OnMouseDown(){
switch(tmpswthc){
case 0:
// Dosomething
break;
case 1:
// Dosomething
break;
}
}
Answer by JoshuaCreighton · Apr 20, 2015 at 03:11 AM
that depends on how you want to activate the pop-up, ive wrote a little script for you that recognises if it hits a collider
public class PopupManager : MonoBehaviour
{
public string message;
bool showMessage = false;
public void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);
if (hit != null)
{
if (hit.collider != null)
{
if (hit.collider.tag == "Blaa")
{
message = hit.collider.GetComponent<AI>.message;
showMessage = true;
}
}
else
{
message = null;
showMessage = true;
}
}
}
void OnGUI()
{
GUI.BeginGroup(new Rect(0, Screen.height - 300, Screen.width, 300));
GUI.Label(new Rect(5, 5, Screen.width - 5, 295), message);
GUI.EndGroup();
}
}
Edit: This is just a rough idea of what you could do, also dont know if it works because i dont do 2D
Hope this Helps
Your answer
Follow this Question
Related Questions
2D Platformer – changing the cursor position when facing left or right 0 Answers
wanna know what make my char stop 0 Answers
Moving Forward 1 Answer
Character Speech 1 Answer
Character Customization 1 Answer