How would I go about creating a quest system in unity with C#
Well, since the question is very vague, and I have a lot of time, I will go over the aspects of a quest system that I think you need.
What is important in a quest? Well, you need to have a start, and end, and possibly some conditions as to if you can finish. For example, this could be a quest:
-
At inn, learn that there are creatures menacing the town, and that there is a 100 amount reward for killing 10 of them.
-
A quest description (e.g. how much the quest is worth (100), where it starts (inn), what the objective is (kill 10), and where it ends (inn)),
-
A dialog system, the is flexible enough to display the quest information,
-
A way to give the player that quest description,
-
And last but very much not least, a way of determining when to kick off the dialog.
-
Now go and kill 10 enemies
-
First, you need a HP system, and a method of notifying when a creature is killed
-
Then, you need to notify some sort of quest handler, that checks what the quest needs (in this case, kills) and if there is match with a possible quest event, decrements/increments that number.
-
Once the requisite number of enemies has been killed, show another dialog that you have succeeded, and go back to the start.
-
Go back to the inn and get the reward
-
First, you need a mechanism of determining you are in the inn, in the right spot, which you presumably have from the first step.
-
Then, you need to show a dialog of the reaction to your success
-
Then, add the 100 to the players wallet, then quest over.
In terms of implementation, I would go for a OOP/MVC based system, where the quest description if the model, the view is the GUI, and the controller both updates the view and checks for the objectives. I would have a Quest class that was built up from a string that would describe the quest, and would be changed by the controller. This architecture would also enable quest creation by a writer.—
I’ve just created a code for the quest giver, to show the player if he has a quest or not.
using UnityEngine;
using System.Collections;
public class questGiver : MonoBehaviour {
public bool onQuest;
public GameObject questMark;
public Material questMarkedOn;
public Material questMarkedOff;
// Update is called once per frame
void Update () {
if(onQuest) {
questMark.renderer.material = questMarkedOn;
}
else {
questMark.renderer.material = questMarkedOff;
}
}
}
so in the quest marked on you should fill in a Eg. a yellow renderer, and in quest marked on you should fill in a invisible renderer.
and in the quest mark its gonna be your object that could be a 3d question mark.
and if the quest giver is on a quest you simply checks on the checkbox saying on quest.
and the quests you would have to create piece for piece.
Tutorial rpg full: BurgzergArcade.com is for sale | HugeDomains