Hi guys ,
I just need your little help about the logic behind game objectives .
I want my player to follow the path and first get some capsule from house and then go to another house and if the player collected the capsule then it can able to get another thing or it cannot . Gui text will pop there and say “Hey! you need capsule first”.
I can script the Gui text but how i achieve that objectives thing .
collect First and if collected first then use in second or can collect second or if not collected then second is also not collected and says … .
Your question is very generic and open-ended and so my answer is very generic. In your player script:
private bool lootedCapsule;
Whenever player loots (by whatever means) the capsule:
lootedCapsule = true;
Whenever player triggers (by whatever means) stuff in the house:
if (lootedCapsule)
GetNextThing(); // whatever you need to do here
else
ShowCapsuleNeededText(); // whatever you need to do here
This is nowhere near a true objective system and it would highly depend on your specific requirements and expectations. Above example is hardly extendable and I would not really recommend doing it this way for many items.
You could keep a list of things you have looted.
private List<string> lootedObjects = new List<string>();
Then when you loot something, you add it:
lootedObjects.Add("capsule");
Then when you check for loot you do:
if (lootedObjects.Contains("capsule")) ..
This is slightly more extendable, but still not a very good design.
I guess, in a simple scenario all your looting and triggers could be done via OnTriggerEnter()
.