Player's conversation with NPC

memmaralit

  • Posts: 24
Hi! I was able to set up and use the dialogue extension Justin created (thanks, Justin!). Now i need to get my player 'talk' to NPCs. What i did first is to create a region and that region follows the player, whenever an NPC is inside that region (meaning the player is very close to the NPC) AND player presses ENTER, the dialogue would appear. I tried it but it doesn't work. I think i'm having trouble with the regions. Any ideas will be surely appreciated. Thanks!!!
-EsChay

MattHutchings

  • Posts: 224
Hi there,
Maybe try creating a boolean canNPCtalk have the default to false and have two number attribute for the player location X and Y, then simply create a "custom region" rather than using an actual region. So if you wanted the NPC to be say 20px way from the player's location to then be able to talk you can do this using the player's current location as a reference from the NPC's current location. Which would be something like if the NPC is within 20px of the player's current X and Y location then set canNPCtalk to true then you can use this attribute to allow the enter key to be pressed and bring up your dialog.
Does this make sense? If not i'll wipe up a code snippet for you.

Bests,
Matt.

AV 2525

  • Posts: 4
I'm still not very experienced, and also a bit delirious right now, but hopefully this will help....

The way I chose to go about this, was to create a region around the NPCs. That would allow me to call upon specific dialog, based on which region the player was in.

I ran into two problems, initially. When I pressed the button to start dialog, it would work fine. When I pressed it again to continue through the dialog tree, the dialog would start over. Duh. "If player is in region and presses button,  start dialog." So, I created a boolean to disable the behavior after the dialog started (false), and reenable after dialog ended (true).

The second problem I had was that my player could still move around while dialog was open. I didn't want this. So, I used the same boolean that disable "start dialog" to disable movement. After the conversation was over, the boolean flipped back to true, and I could move again and restart the conversation, if wanted.

I was just playing around, and have since removed dialog from that project, but I think that's how I did it.

AV 2525

  • Posts: 4
More clarity: To disable the movement, I put my whole movement behavior in an If statement. If boolean = true, follow these rules for movement. So, when boolean flipped to false, I could not move.

memmaralit

  • Posts: 24
Hi, Matt! I understood everything except the "custom region" part. I think i need a code snippet. Thank you so much for your help!

Hi, AV 2525! Thank you for your help! I'm combining your idea and Matt's. I encountered the problems you mentioned when i first tried the dialogue extension with my game. Thanks for the solutions!

You guys are awesome! Thank you! I appreciate it. :)
-EsChay