Ever wanted to make an RPG, but couldn't make an NPC? Well, This is how I do make my NPCs!
First, you need to have made the player, and an HUD layer. Then, put the NPC in the game. No behaviors. BUT, you need to give it one instance variable.
This will tell if you have talked to this NPC already, like if the NPC gives you an Item, you don't want it to give it OVER and OVER! So, you need that.
Then in the HUD layer, add a bar and text on the screen like this:
Do you see the NPC on screen? We want him to give the player a boat, so he can travel. So, what we want to do, is make an event:
"Player on Collision with NPC", but if you want to press a special key to talk to the NPC, (lets say Z). Then, you want to add another condition to the Collision one:
"On Z Pressed"
BUT some people are like "Well, what if I don't want to have the player be on collision with the NPC? What if I want him/her to be able to Talk to the NPC within a certain distance? Lets say withing 200 pixels of the NPC." Well in that case, instead of having the "On Collision Event", you want to have:
"System ==> Compare two Values ==> distance(Player.X, Player.Y, NPC.X, NPC.Y) Less Or Equal to 200"
Ok, now we need to add an action to the Events that we added.
Make the action set the text in the HUD bar "NPCNAME: Hi there! Here is a free Boat!"
Then add 3 more actions in this order, "NPC ==> Set Talked to 1",
"System ==> Wait 4 seconds", and Set Text to "You: Thanks!"
Remember the Events that trigger talking to the NPC? Make those again, but add another Condition:
"NPC ==> Talked = 1"
Then add an action to that.
Add: "Set Text to "NPCNAME: Enjoy that Boat!"
Then add 2 more actions in this order, "System ==> Wait 4 seconds", and Set Text to "You: I will!"
You have now made your first NPC!
BONUS FOR TOP-DOWN NPCs:
If you have Top-Down NPCs you can use the Runaway Plugin!
Give the NPCs the Runaway behavior, and it gives the NPCs are more real feel. It makes the NPCs wander around the area depending on the properties you set. Pretty neat, eh?
Well, I hoped this tutorial helped you!