How to make a NPC and make him request food


Hi, I’m new to game development and right now I’m trying to make a “Fast Food Simulator” where the player can move trough a fast food and he has to cook and bring the people (NPCs) the food they want. This is the problem, how do I create the NPCs and make them accept only the food they requested? Like, if the NPC requests for some nuggets, I want to make so they won’t accept fries or other stuff, and I want them to request the food they want randomly from a list I’ll create and make a drawing of the food appear for what they are requesting.

Right now I made all the player movements with the Camera and everything and I also made the fast food map, so the only problems right now are:

  • Making the NPCs;
  • Making them request food from a random list of foods;
  • Making a drawing appear of the food they requested;
  • Making them only accept the food they requested and no other food.

Thanks in advance

Hey there,
for most of your question you just need object variables. Inside the sprite-object for your npc (depends on which look your game has (sideview, top-down, isometric, etc.) you can add different variables for the request.
One way would be to use the “structure”-type for each recipe and add variables for the ingredients.
happy meal (structure-variable)
-cola (boolean-child variable)
-fries (boolean-child variable)
-cheeseburger (boolean-child variable)

Whenever you finish one task you can set the child-boolean of the task (like preparing cola) on true. When all booleans are true you can sucessfully deliver the food. If not the NPCs will get angry and (maybe) leave (or whatever you wanne make him doing).

Now you can create a few recipes this way and let randomize which one will be picked when the NPC enters your restaurant. So you always will have different tasks to handle - even more when it’s possible to prepare additional orders like in “Cook, Serve, Delicious”.
If you don’t prepare the right things, the needed variables won’t change to true and when time runs out you loose.

Things like blending in sprites is pretty easy. You can handle this with making the variables a condition and under actions just create an object with the sprite on the x/y axis.

I hope this will help - even when just talking about the concepts behind.

I think your question is too broad.

The above answer is correct, you will need to use variables and many other things, but you should start with small steps and then get some experience on these things.

Asking how to “create the NPCs and have them accept only the food they requested” is basically like asking someone to make your game.

My recommendation is to focus on smaller problems:

  1. How to use variables (including learning the difference between global, scene, and object variables)
  2. How to use variable structures
  3. How to display the sprites
  4. How to manipulate sprites
    Etcetera etcetera…

After learning those basic things, you’ll probably understand how you can make your game work the way you want.

1 Like

Hey, I just read your answers and thank you both for the help, I’ll start learning more things from now. I had another question tho, is there an easy way to make a “view bobbing” like in Minecraft? Like if you walk the camera will move left and right a bit, I have a hand on the right side of the screen and I wanna make it move too, here’s a video on how a guy did it on Unity: SIMPLE VIEW BOBBING in Unity - YouTube