I just got your 2 asset and they look great , How do i Access, Display or Save WorldVariables (Health, Score etc) ,
for example using the new UI Text to display the values in C# in a different script ? I tried this bout was getting error " error CS0029: Cannot implicitly convert type `InGameWorldVariable' to `int' "
You're missing need a ".CurrentFloatValue" or ".CurrentIntValue", depending on variable type, like this:
textDisplay.text = "" + scoreVar.CurrentIntValue;
However, we've included scripts to do this automatically: WorldVariableListener.cs. Try those!
The ".CurrentFloatValue" or ".CurrentIntValue" don't work and found the WorldVariableListener.cs with the UI example scene but i still don't understand how to give score or experience from an achievement system, when a player picks up an item and also connecting it to an inventory system. And i also have a charater selection scene before the game starts. Do you have video i can look at please?
Sorry about this, am making a 3d adventure game and its first time trying to make a game so just try to understand all these.
I look at the example and i understand a bit more, but what i don't still understand is, in my game i have a script for a health bar how do i send information from the WorldVariable (Health) when the player get damage or gain health the health bar reduce or increase.
In the UI example you can gain XP, if i have a script that displays a XP bar how do i send the XP gained to that bar to add up.
I also got the Easy Save 2, if i can save the WorldVariable name and value from the WorldVariableListener that way i can call it in another script to add or subtract etc?
This asset its great but its not easy trying to get it to work with my project but will keep trying.
Post by DarkTonic Dev on Mar 28, 2015 17:55:17 GMT
1) A World Variable Listener script automatically gets notified when the World Variable value changes. So please use a World Variable Listener. Make a subclass if you need something like a health bar. 2) Normally you add to a World Variable by just using a Killable's "Death Variable World Modifier Scenarios" section (take a look at the enemies in Example Scene 2) or watch the videos on Youtube. So you can add to a variable when something dies or gets picked up. You can use "drops" that the player picks up to gain XP or another variable with 0 Attack Points and 1 Hit Point so they don't damage the player when they pick up. 3) If you want your player to use a World Variable for Hit Points, select "Variable" (blue dropdown) for its Start Hit Points, select the variable from the dropdown, then check the box for "Sync H.P. Variable". 4) If you want to modify a World Variable by script, use code like in the readme:
var variable = WorldVariableTracker.GetWorldVariable("yourVarName"); // add 100 variable.CurrentIntValue += 100; // or CurrentFloatValue for a float!
You'll be on your own for integrating with Easy Save 2. But yes that's totally doable.
I have another question how can i make the player level depend on the experience gain, e.g 100 xp = Lv 2 then for the next level, the current the next max xp to be gain is multiplied by 2 for the next xp to be gain and increase player level ? or do i have to do it separately ?
Post by DarkTonic Dev on Mar 29, 2015 21:13:35 GMT
Make a subclass of "WorldVariableListener" and hook it up to your Experience Points world variable (drag it to Listener field). Inside the UpdateValue method of the Listener, you can add code to increase the Level (World Variable) when certain Experience Points are passed (100, 300, etc).