0 votes

Sorry for the noob-ness, but I'm looking to create a very basic interaction between the player and an NPC in my 2D RPG, where the player approaches the NPC and interacts with them and a dialogue box pops up with a simple message. I've created the player and the NPC, but haven't been able to make anything happen.

I don't even have any sample code to share because I've tried following several tutorials but not gotten anywhere, and I think I need to take a step back and get a fresh perspective.

So any guidance on the most basic way to cause a player action to trigger an NPC response would be hugely appreciated!

Godot version 3.2.3
in Engine by (166 points)

1 Answer

0 votes
Best answer

I'll give you one way to do this:

Have an Area2D on the player character and another one on the NPC. On the player, check for input and if the input is the correct input for interaction, check if the player is in the NPC's area. If it is, then pop up the dialogue box.

by (8,152 points)
selected by

This sounds good - what kind of code would be needed to make the dialogue box pop up?


Simply showing and hiding the dialogue box would be enough.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.