Jump to content
  • Advertisement
lollydipstick

C# Trying to Create an In-Game Bestiary for a Horror Game

Recommended Posts

A small team of friends and I are trying to create a minimalistic, exploration-based horror game inspired by things like Yume Nikki and LSD Dream Emulator. One of the things we want to include is a bestiary of sorts where players can use the E/interact key to add an NPC in the maps to a bestiary that will be located in the pause menu and will give a bit of flavor text on each creature. Unfortunately, I have spent the past few hours scouring YouTube and gaming forums for tutorials or advice on how to do this, but I have yet to come across anything helpful.

Ideally, the player would just be able to walk up to an NPC, hit E or whatever the interact button is while near it, and have its entry in the bestiary automatically be unlocked in the pause menu. Until the player actually interacts with this NPC, its image in said bestiary would be either a silhouette or a question mark. I immensely appreciate any advice that you can give me! Thank you all in advance!

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

The problem seems to have at least two components - interacting with NPCs, and managing the UI element where the NPCs are displayed. Is there any specific part of the problem you're looking for advice on?

Also, what languages and/or development tools (e.g. game engines or libraries) are you using?

[Edit: I see there's a 'C#' tag. Info about engines/libraries/etc. would probably still be useful.]

Edited by Zakwayda

Share this post


Link to post
Share on other sites

For interacting with an NPC you need to first lookup any NPCs in your location. This is typically done using a Quad Tree or similar structure so you are cutting down the number of possible matches in the second stept, test if your player matches two criteria on each NPC in the list you got from the tree.

An NPC is a legal target if the player matches

  • Certain distance between the character and the NPC, for example below 2 meters
  • They are facing each other so you know that the player currently wants to interact with exactly that NPC and not the NPC that is located behind him for example

Now you know which NPC to toggle and can use it's class or component whether you are using OOP or ECS stile NPCs to trigger an interaction/ message to be send to the BestiaryManager knowing all those entries or let the NPC send his entry directly. Display it and you are done

Share this post


Link to post
Share on other sites
14 hours ago, Zakwayda said:

The problem seems to have at least two components - interacting with NPCs, and managing the UI element where the NPCs are displayed. Is there any specific part of the problem you're looking for advice on?

Also, what languages and/or development tools (e.g. game engines or libraries) are you using?

[Edit: I see there's a 'C#' tag. Info about engines/libraries/etc. would probably still be useful.]

I'm using Unity3D so yes, it would be C#. I'm kind of just looking for advice on where to start. I'm a novice when it comes to programming, so I'm not even sure about where to begin.

13 hours ago, Pepsidog said:

Like enter the gungeon or spelunky?

Yes. We just kind of want an in-game bestiary of NPCs the player has encountered, where each entry displays the NPC's sprite and some flavor text.

11 hours ago, Shaarigan said:

For interacting with an NPC you need to first lookup any NPCs in your location. This is typically done using a Quad Tree or similar structure so you are cutting down the number of possible matches in the second stept, test if your player matches two criteria on each NPC in the list you got from the tree.

An NPC is a legal target if the player matches

  • Certain distance between the character and the NPC, for example below 2 meters
  • They are facing each other so you know that the player currently wants to interact with exactly that NPC and not the NPC that is located behind him for example

Now you know which NPC to toggle and can use it's class or component whether you are using OOP or ECS stile NPCs to trigger an interaction/ message to be send to the BestiaryManager knowing all those entries or let the NPC send his entry directly. Display it and you are done

Yeah, I think you lost me unfortunately. I'll do some research on quad trees.

Share this post


Link to post
Share on other sites
2 hours ago, lollydipstick said:

Yeah, I think you lost me unfortunately. I'll do some research on quad trees.

Since you're using Unity, you maybe (probably) don't need to worry too much about low-level details like quad trees. For example, you might instead be able to leverage Unity's physics/collision system (triggers, raycasting, etc.) for this. Or, depending on how many NPCs you have, you might be able to get away with a brute-force check, at least initially.

In any case, I'd definitely break it down into sub-problems, as Shaarigan suggests. The interaction part and the UI part are more or less completely unrelated and separate from one another (or at least can be), so you should be able to tackle them as separate problems. Assuming NPC interaction will be needed for other things as well, getting an interaction system up and running seems like a good place to start. Once that's working, you can tackle the UI part (which might be the easier of the two tasks). Lastly, you can certainly do the UI part first if that seems more manageable - you can just enabled/disable the character entries through some other means (e.g. clicking on them or whatever) for testing purposes.

Share this post


Link to post
Share on other sites

I'd agree on the sub tasks.

First, are you able to pick the character?  The detail on a quadtree is an implementation detail which probably doesn't matter on Unity.  First you've got to be able to actually pick the thing you want to review.

Next, you'll need to have some data on the character.  In Unity the blueprints you use for your characters, NPCs, monsters, etc, might have a behaviour you add with a text field.  Or you might have ID's assigned to each type of creature in your game that can be looked up. Whatever method you go with, you obtain a blob of text associated with the thing.

With that done you know both the thing being selected and can obtain the data to be displayed. The next task is to actually display that message in a way that looks good in your game.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!