This Might be a fairly simple solution to this but a lot of the answers in finding are either for 3d or take a large route and add way to many things to it. I am simply trying to make it so that when a player gets close to the target/NPC a small chat bubble would appear above their head when go away when they leave.
This is a very simple version of what I have at the moment. There was a line that called for AddComponent() but it kept telling me the command simply doesnt exsist. Even when I look it up on the unity wiki and what not.
void FixedUpdate()
{
var ChatBubbleShowing = false;
float minDist = 3;
float dist = Vector3.Distance(pl.transform.position, transform.position);
if((dist < minDist) && ChatBubbleShowing == false)
{
ChatBubbleShowing = true;
var chatBubble = new GameObject("Chat Bubble");
}
}
=======
The main goal Im having at the moment is try trying to make it so that the player walks up to the NPC (2d top down), a small text box shows up over the NPC showing that you can interact with the NPC. and when the player does. They movement is locked, and a GUI shows up. A player can then close the GUI and then once again move again. instead of locking their movement. Simply walking too far will also cause the GUI to close. But again I am a bit stuck on the the whole “Creating and Destorying a game object” part.