I’m trying to set up a tech tree with values so that the once the button is clicked, it will take so many turns that it will take the amount of turns before the changes take effect.
I think there are a couple of ways you can do this. For both, I would recommend creating a general turn counter that all your systems can reference.
-
If your tech growth rate is a static amount of turns, then I would just reference the turn counter to determine when the tech is completed… On turn 1 you start learning alphabet, which takes 5 turns. Then set “Current Tech Turn Counter” variable to 6 and when “Current Tech Turn Counter” = “Current Turn” variable then learn Alphabet.
-
If you want effects that speed up or slow down research rate in variable ways, create a bucket that fills up over time based on how much research per turn you are earning. If Alphabet takes 500 and Current Research >= 500, then learn tech. So if Alphabet needs 500 research to learn, and you get 100 per turn, then it would be 5 turns. If you want to increase the research speed 20% then you do the math and the tech finishes in 4 turns.
It basically boils down to variable management. What is the current variable and is it >/<= the reference? If True execute A. If False, execute B.
Are you able to maybe provide an example of option one?
Still having trouble with make the values change on the turn its supposed to. I used an if else statement and still having issues.
Hello,
When you start a research, you set a variable with the amount of turns needed. Then when you click your “end turn” you add to your system a check to your researches : If none, nothing, if one or more : first check if variable = 0 then research ended : set research done. If variable higher then do variable = variable - 1.
You set tech counter = total turn + 5 in techpressed1 and then you check if there are =. They never can.
Edit : I try to do something and post when i can.
I would greatly appreciate it! I changed to to a <= one, but it starts it after one turn. Ill work on something else until you are able to help me. Thanks!
Here is the idea i followed : I changed a bit from what i wrote at start to have it working. It is ok for one research only, if you have more than one running at same time, some modifications will be needed. Turns was set to 5 and Count to 0 in editor :
Edit : Print string research done is where you link your function research done.
Edit 2 : If you want to decrease at variable rate, replace “- 1 " by " - a variable” you’ll can change when you’ll need. I didn’t add print string to show but if you want you can add a turn print then player can see how much turns are needed to finish and a research print saying finish current research before start a new one, for example. (using text or umg instead of print if you want to be used by player )
Edit 3 (lol ) : a better solution : if you set count = count - 1 beetwen branch (research) and branch (count = 1) you can check count = 0 instead of 1 and print the true number of turns needed. which was wrong with this setting.
Thank you so much!! This helped a lot. This is what I have so far and it is working so far. Now I just need to make it for then one tech.
Please add anything you this would make it better please.
Happy that helped you ^^ What do you mean by “I just need to make it for then one tech”
I meant make it so that it works with the other technologies. Making it universal so to say.
For this use arrays, making it in code not as data in arrays will cause hell later on.
You need just few arrays:
- how long it takes to develop tech
- what character ID this tech has.
- which ones are needed to unlock, this one can be encoded as string/text, for eg each character represents one tech, A- writing, B - mining, etc.
Then you need to hold some text variable that keeps discovered techs
From it you can create string for what is unlocked.
This way you have one function for all techs, much less headache when fixing bugs.
Thanks. I will post what I come up with when I get it all together.
Ok ! Here the modification i wrote :
How does the player select the research ? If there are different keys, use the “m” line for each key with each turn value. If this one key, then it needs to have an input with turn value in from the selection and set turn / count with it. If you only have 5 tech that would be ok, but would need more if you have more.