- Home /
Objectives based on object appear.
On the start I will sorry for my gramatic, I am Polish. So I am working at RTS game and I want to add objectives based on creating something. I am looking for script that writes in the left up corner objectives you can change in public var and if particular "gameobject" appears on the scene next to the text of objectives will appear text "completed". For example: In the left up corner writes "1. Build a radar" and when u build a radar, ("gameobject" appears on the scene), the text will change to "1. Build a radar. COMPLETED"
Do you know a script like that or you know how to write it? Thanks, Tomasz.
Answer by MagicoCreator · Dec 30, 2013 at 01:29 PM
i think you should change your approach of this problem:
make your building so that if important events happen to them they send a message to an object tracker script (like OnBuildingAttacked , OnBuildingBuilt , ...) and your tracker should register the events you need (play a sound if attacked, or increase the amount of buildings you have, if your objective is to build 10 buildings for example), this way you can set objectives which wouldn't require a certain gameobject to be present, but amounts of it, or various other things
for tracking the objectives you can just increment/decrement some values based on what do you need and check if they reached a certain amount
Answer by inkspot · Dec 30, 2013 at 01:47 PM
For example you have a 'manager script' (which also holds the gui/text, and a script that spawns/make the object appear in the scene(or even let this manager script spawn), you can use this condition to check which item was spawned and match it with the current objective something like this:
var currentobjective : GameObject;
function created_item(item : transform) {
if(item.name == currentobjectiveobject.name) {
Debug.Log("You created the right item!");
// change gui text
// get next objective
}}