Quest Machine MiniMap Integration
-
- Posts: 7
- Joined: Fri Jan 01, 2021 12:53 pm
Quest Machine MiniMap Integration
Hi all. new guy here, and a little lost with this Mammoth tool (thats a good thing)
Actually, pretty cool stuff, but , i am at a point now where i wish to have icons on my mini map for quest givers, or direction to quests themselves.
I honestly have no idea where to begin. i did do a search here in the forums, but the only info i found was related to QuestDialog. Is this the same?
If there is anyone who could point me to an article, video or anything that touches on this, i would be very greatful. Ty.
Actually, pretty cool stuff, but , i am at a point now where i wish to have icons on my mini map for quest givers, or direction to quests themselves.
I honestly have no idea where to begin. i did do a search here in the forums, but the only info i found was related to QuestDialog. Is this the same?
If there is anyone who could point me to an article, video or anything that touches on this, i would be very greatful. Ty.
Re: Quest Machine MiniMap Integration
Hi,
Here are two ways to manage minimap icons:
1. Assuming your existing minimap system has a way to turn icons on and off, your quests can use a Scene Event action or custom quest action to turn them on and off.
2. Or you can hook into the existing quest indicator system.
For #1:
Here are two ways to manage minimap icons:
1. Assuming your existing minimap system has a way to turn icons on and off, your quests can use a Scene Event action or custom quest action to turn them on and off.
2. Or you can hook into the existing quest indicator system.
For #1:
- For discussion, let's say your minimap system has a script named MinimapEntity that controls whether the GameObject's minimap icon is visible or invisible.
- To use a Scene Event action, find the point in the quest where you want to change the minimap icon, such as the main quest's Active state > Actions, which run when the quest goes active: Add a "Scene Event" action. This is a UnityEvent that's tied to GameObject(s) in a specific scene. You could configure it, for example, to call the MinimapEntity's method to change the icon's visibility:
- If you don't know ahead of time which scene the GameObject will be in, or if you don't want to use a Scene Event, you can write your own custom actions. Make a copy of Plugins / Pixel Crushers / Quest Machine / Templates / QuestActionTemplate.cs. Move it outside the Plugins folder so it can access your minimap system. Then customize it where the comments indicate. For example, your script might look like:
Then add that action:
Code: Select all
namespace PixelCrushers.QuestMachine { public class MinimapIconQuestAction : QuestAction { // These values will appear in the quest editor's inspector: public string gameObjectName; public bool on; public override void Execute() { // Find the GameObject even if it's inactive: var gameObject = GameObjectUtility.GameObjectHardFind(gameObjectName); // Set its minimap icon on or off: gameObject.GetComponent<MinimapEntity>().SetMinimapIcon(on); } } }
- Quest Machine has 5 built-in types of UIs:
- Quest Dialogue UI: Used by quest givers to show offer text, quest hand-ins, etc.
- Quest Journal UI: Window showing the details of the player's active and completed quests.
- Quest HUD: Onscreen summary of active quests.
- Quest Alert UI: Informational messages that pop up onscreen for a duration, such as "Task completed. Return to NPC."
- Quest Indicators: Typically shown as overhead images to indicate that a quest giver wants to talk.
- When a GameObject (e.g., quest giver) has a quest indicator, it's managed by a QuestIndicatorManager script that figures out what indicator image to show. The QuestIndicatorManager manages another script called QuestIndicatorUI that actually shows the indicator image. Look at any of the NPCs, such as the Villager, in the Demo scene, to see how it's set up. Both of these scripts are subclassable. You can make a subclass of QuestIndicatorUI that also sets your minimap icon. For example, the subclass might look like:
Code: Select all
public class CustomQuestIndicatorUI : QuestIndicatorUI { public override void SetIndicator(int index, bool value) { base.SetIndicator(index, value); // If requested to set the "Interact" indicator, also set the minimap icon: if (index == (int)QuestIndicatorState.Interact) { GetComponentInParent<MinimapEntity>().SetMinimapIcon(value); } } }
- A GameObject's QuestIndicatorManager typically points to a prefab that has a QuestIndicatorUI script. At runtime, it instantiates the prefab. (It's also fine if the QuestIndicatorManager points to a scene object instead of a prefab.) Replace the prefab/scene object's QuestIndicatorUI with your custom subclass.
Re: Quest Machine MiniMap Integration
The second part of this is making sure that minimap icons are turned back on/off when the player leaves the scene and returns; or saves the game, quits, and loads the saved game.
The easiest way to do this is to save the minimap icon's state. Quest Machine's save system is fairly easily extended. To save data, write a small "Saver" script. You can find a starter template in Plugins / Pixel Crushers / Common / Templates. Example:
The easiest way to do this is to save the minimap icon's state. Quest Machine's save system is fairly easily extended. To save data, write a small "Saver" script. You can find a starter template in Plugins / Pixel Crushers / Common / Templates. Example:
Code: Select all
namespace PixelCrushers
{
public class MinimapEntitySaver : Saver
{
public override string RecordData()
{ // Return "Y" if the icon is on:
return GetComponent<MinimapEntity>().isOn ? "Y" : "N";
}
public override void ApplyData(string data)
{ // Set the icon state based on the saved data:
GetComponent<MinimapEntity>().SetMinimapIcon(data == "Y");
}
}
}
-
- Posts: 7
- Joined: Fri Jan 01, 2021 12:53 pm
Re: Quest Machine MiniMap Integration
Well, my entire game is in a single scene at all times, so that part is easy enough to not worry about. But im still stumblin around trying to figure out the first steps mentioned. I'm a real knuclehead of sorts, i never import demo scenes, and i note that you specifaclly mentioned it as reference. I think i may break my rule of thumb this once. Thanks Tony.
Re: Quest Machine MiniMap Integration
You could import the demo scene into a separate project just to see how it works. No need to keep it in your main project if you don't want to.
Since I don't know how your minimap system is designed, I tried to supply a few different options. A basic Scene Event action is probably the easiest way to go.
Since I don't know how your minimap system is designed, I tried to supply a few different options. A basic Scene Event action is probably the easiest way to go.
-
- Posts: 7
- Joined: Fri Jan 01, 2021 12:53 pm
Re: Quest Machine MiniMap Integration
Indeed. Well, for now, i have taken your advice on the demo scene and am getting aquainted with things. Shall see how it goes.
Re: Quest Machine MiniMap Integration
BTW, there's also a whole series of video tutorials that may be helpful:
https://www.pixelcrushers.com/quest-mac ... tutorials/
https://www.pixelcrushers.com/quest-mac ... tutorials/
-
- Posts: 7
- Joined: Fri Jan 01, 2021 12:53 pm
Re: Quest Machine MiniMap Integration
Yea, this stuff is awsome, and its starting to click. Thanks for the links, the help, and the plugin . Amazing stuff.
Re: Quest Machine MiniMap Integration
Glad to help!