I really want to make it so when you touch an npc it displays some gui, like a text box. Then next to it a few buttons and when you click the buttons its shows another text box and so on its for an android RPG I’m making and I’m really stuck with getting it so when you touch a npc it shows gui. im a massive newbie to scripting so please explain in detail. i know its a lot to ask but PLEASE HELP, thanks
#pragma strict
var show : boolean;
var show2 : boolean;
var target : Transform;
var screenPosX : Vector3 = camera.WorldToScreenPoint (target.position);
print ("target is " + screenPosX.x + " pixels from the left");
var screenPosY : Vector3 = camera.WorldToScreenPoint (target.position);
print ("target is " + screenPosY.y + " pixels from the top");
// screen position of gameobject
var oSPX = Mathf.Round(screenPosX.x / 100);
var oSPY = Mathf.Round(screenPosY.y / 100);
if(show2 === true);
{
}
function Update () {
for (var touch : Touch in Input.touches) {
if (touch.phase == TouchPhase.Began) {
show = true;
Debug.Log("niceballsTrue");
Debug.Log(show);
var touchPositionXRounded = Mathf.Round(touch.position.x / 100);
var touchPositionYRounded = Mathf.Round(touch.position.y / 100);
}
else
{
show = false;
Debug.Log("False");
Debug.Log(show);
}
if(show === true)
{
Debug.Log("OMG IT WORKSish");
}
else if (touchPositionXRounded == oSPX)
{
if (touchPositionYRounded == oSPY) {
show2 = true;
}
Debug.Log("ITS ALIVE":)
}
else
{
Debug.Log("printed false :(");
}
}
}