#is it like for example public string
1 messages · Page 1 of 1 (latest)
What does this have to do with a dictionary
what? i just searched up what dictionary is
and there are examples even like Dictionary<strong, int> GetState()
And now that you know what one is you can implement this:
#💻┃code-beginner message
i don't know if i wrote right,
Okay good. Now you can store the total and current for each level. Then you can access these dictionaries from anywhere to change the number when you collide with one, or to display as text
can i access them from anywhere? even though it doesn't show in the inspector? or does it have to be string, int?
You made it a Singleton right
Like I said at the beginning of all this
yeah, there's even instance
but how can it tell that while these two are the only ones with TotalMuonsPerLevel and CurrentmuonsPerLevel?
I have no idea what you mean by this sentence
i mean like how can these two tell the total of muons per level and the ucrrent muons per level? since nothing is happening, even if when i touch a muon gameobject and finish the level, the number on the counter on the level select didn't go up
You would access this object and change the values on it whenever you collide with one
what?
Whenever you collide with a muon
you would reference this object
and change the count of current muons on it
likewise, you could set the total per level on startup or even hard code it if you want
what do you mean by that?
I mean... exactly what I said
how do i do that? the three different objects in the different scenes have different tag names like "Muon1" "Muon2" and "Muon3"
whenever you collide with a muon
you would reference this object
and change the count of current muons on it
Okay? I don't know what this has to do with anything I just said
i tried that witht he current script, but nothing happens with the counter
Show it
This shows me absolutely nothing relevant
the counter doesn't go up when i touched a muon object in the stage level
Okay
and am I just supposed to fire up the NSA spy satellite to see how you implemented that
what?
even with
Dictionary<string, int> TotalMuonsPerLevel = new Dictionary<string, int>();
Dictionary<string, int> CurrentMuonsPerLevel = new Dictionary<string, int>();
it doesn't any thing much from it because nothing happens that the number doesn't go up when touching a muon object
I mean like how can TotalMuonPerLevel and CurrentMuonsPerLevel texts can tell with only just that?
ok so i have added in instance = this? is there something more needed for it to work, when you exit the game?
Well that was just because it was clearly in error. You had the static reference but had not set it.
Now you can write MuonCounter.Instance and access it from anywhere
Perhaps MuonCounter.Instance.UpdateText() or something.
I just realized you make _allMuons and _amountMuons static, which is bad practice, but I was gonna say you could change those via the Instance variable as well
oh?
is it bad if that happens?
also, where and i adding in the MuonCounter.Instance.UpdateText()?
Bad if what happens?
Wherever you want. If you want.
It was an example of what you COULD do
well i tried saveData and loadData, but it didn't work when i exit runtime
about when you said which is bad practice
I have still never seen where you call LoadData
Yeah it is bad practice. You should not abuse the static keyword like that.
then what can i do there?
Not make it static 🤷♂️
Only have Instance be static
That is the whole point of having the Instance variable
But that is really not important or relevant to your issue. Just to be clear
THIS is important to your issue
I have still never seen where you call LoadData
but then the numbers won't work
Yes they will
MuonCounter.Instance._allMuons
loaddata or savedata?
What?
I said:
I have still never seen where you call LoadData
it wokrs for the coin counts
then that would be an error line
where am i supposed to call LoadData while it is works with jsut the coin counts?
You are saving it to playerprefs. Have you looked at the documentation for PlayerPrefs.GetInt ?
You want to load it from the file.... so load it
Yes, that makes no sense at all
The error is not with what I wrote, but where you put it
What is that line supposed to DO?
If the line doesn't DO anything, then it will throw an error obviously.
I showed you how to access the value, and you just access it and throw it away
i think you wrote it wrong
You are incorrect
You can't just write cs transform.position;//errorYou must actually do something with the membercs transform.position = other.position;//worksThese are examples but would be the same relative to your calling of allmuons but not doing anything with it.
It was an example for what you can do, not something you were supposed to randomly enter for no fucking reason linedol 😸
The error states that you must do something with it (assign something to/from it, increment, decrement etc)
PlayerPrefs.GetInt("something");?
MuonCounter.Instance._allMuons = .....
If you want to load data..... then yes of course
You might want to provide where it could be placed if you want a proper suggestion - assuming code hasn't been shown yet.
So you need to complete those statements else it'll assume you're assigning all muons the value of amount muons, amount picked up, coin count etc.
a = b = c = d;```
Where in your case, it's currently cs a = b = c = d;which is the same as the above statement
Remember where you wrote PlayerPrefs.SetInt?
Use the same name you wrote there....
Also, thing = GetInt
Not just GetInt on its own of course
_allMuons = GetInt("AllMuons") or something
is it SetInti instead?
No
i know it, i was jsut showing the progress
SetInt saves
GetInt loads
oh
how's this?
Do you have a SetInt("AllMuons") anywhere?
well not finished
Look up the docs. You have to of course pass a value being saved into it. But yeah. As long as you use the EXACT same name for Set and Get, it should work
does it need something in the ()?
Look at the docs. Read what the set method does and what parameters it takes
Look up the docs. You have to of course pass a value being saved into it
#1265813900037853255 message
Don't let people spoon feed you more then they already do.
i am
Then don't ask us if you have to pass something in. Just... LOOK at the docs
It tells you exactly what you need to do
Yep, see how it says exactly what to do.
well yeah, but idk what to put on the second one, even if i try with int Value, it wouldn't work because of red underline
What value do you want to save. Just think for a minute
No code is ever really supposed to be copy pasted. You need to THINK about what you are supposed to change it to
well i want to save _allMuons and _amountMuons
but... even i would write data, it still wouldn't work
or other way around like the coin one?
Where do you call LoadData
This has been the question I've asked over and over for like hours now
and I have also asked where am I supposed to call LoadData even though this worked for the coins but not for the MuonCounter for a long time? it''s not like i can put LoadData(); anywhere
I cannot possibly know that. You need to figure it out on your own
You MUST call LoadData to load your data though
So until you figure it out, you will not load the data
i cannot figure this out if i don't know where since before that it worked for the coin counting without calling it anywhere
Think for a few seconds. WHEN do you want to load data? Call it then.
Generally it happens when the game starts, or the scene starts.
No one can tell you when you want it done, because it is just that, when you want it.
So yes, you absolutely can figure it out, and you have to
how am i supposed to know, when the game starts since like for example when you exit the game, and when you want to play agian and select a save file, you continue form with the same amount from before
So.... perhaps when you select a save file? You would want to probably load data at that point right?
Yeah... While I have the save files scene, I haven't coded how the save files works yet, but maybe the same as the buttons, but I would also load it when you select a stage, and when you went to the goal, that's when you save the numbers of the text there
Goal object
There you go. You just said where you want to load it. Perfect!
Does the numbers change up though line you touch 3 objects and the number changes to 3?
idk if I'm doing right, because the number in the text is still not going up
That is not where you would want to load.
And where do you increase the number? I don't see it anywhere in the code you're showing
In your previous code you called PickedUp()
But you seem to have replaced that with load.
That.... makes no sense. Put it back how it was
that was on the ocunter, not the goal script
Alright. Well showing screenshots is a terrible way to share code for just this reason. How could I have known that?
https://gdl.space/umoyixupan.cs Muoncounter
https://gdl.space/busavaheri.cs counter
https://gdl.space/qabatuhigi.cs goal script
Show the one with load and save
The script you called counter was muoncounter. The one you called muoncounter was muoncontroller
So you did not share counter
You should get rid of this GameData class or struct and use playerprefs as you are for the rest. Just save the picked yo muons just like you save allmuons
wait what?
You are passing in new GameData() when loading. So that will have default values not related to anything
What do you mean what?
Do you call it with new GameData() ?
Well, if you want to stay with the GameData class, you need to figure out how to pass the one with actual data in it, not a default one with new()
I am supposed to call LoadData somewhere don't I?
If you want to load data you need to call LoadData
that is what I'm doing
how am i supposed to call load data somewhere if I don't knwo where I am suppose to put if it's not like that and not putting it somewhere in the goal script?
You seem to be ignoring what I am saying.
The issue is writing new GameData() there
what about it?
You are creating a new one with no data and loading a value from it....
Think about that for a second. It should be very obvious why that is not what you want to do
but that's like on e of the things i can only write in the goal script
Then the architecture is broken
And you need to figure out a different way.
I suggest leaning into playerprefs, but you refused. So... gotta figure out something else
I gotta go. Good luck with it all
i know about PLayerPrefs since i wrote it in the Counter script
at times liek this, it makes me sensitivly sad on i don't what i am supposed to write there, and it hurts...
i only just.... wnated it to be fixed....😢
and please asnwer...
imma go and take a shower
back
If you really need help, you need to start making sensible questions. As well as go over the C# basics. As well as make sure that your intention is clear to the other person(use a translator if you're not confident in your English)
i agree.. lot of questions i have to think about for a second before i can make sense of them..
At this point I don't even understand what the question or the issue is and where you are at fixing it.
well, i need help with the scripts to make sure that the ui text in the level select scene can be changed up to a number based on how many muon objects you have touched from another scene in a gameplay scene, and i also wanted to save the number so you don't have to start all over again when you exit the game
-> OnTriggerEnter or something like that
-> A Script that keeps track of the score.. (it doesn't even need to be a static class or anything) ** you can just use a DontDestroyOnLoad() instead and that will carry it from one scene to another
yourValue++; is an instruction <-- adding 1
you still debug just the value Debug.Log(yourValue); @frank zephyr
I do have DontDestroyOnLoad in MuonCounter script and ontriggerenter is when the player object touches the gameobject
one more thing.. whats wrong with it? whats not working.. u explained what u want to do.. but not really what ur stuck on
and is everything working up to that point (is ur trigger and score counter working?)
https://gdl.space/ebulipubok.cs it worked before witht he counting, but ever since with the isntance, it is not working anymore...
https://gdl.space/opareqoheh.cpp even no matter how many tries i tried to do
what is not working is the ui number is not going up when i touched a muon object in the other scenes
share any errors u have.. in the Console as well
that'd give us a good start to helping
well.. the thhing is, I don't have any errors in the console
does the ui number go up at all? (on the first scene for example)
well it supposed to, but when i touched a muon object in the gameplay scene, and when i went back to the world select scene, the number isn't going up
and at first the counter script was used for the coin counts
And when you debugged the muonCount did THAT go up?
well when i debugged it, twice, it didn't go up as no debug about it in the console
Then that line of code is not even being called
yup, i was gonna ask about those debugs u added
PickedUp is not being called or muonTags does not contain that string
thats why u dont have any errors.. its not broken.. it just isnt being called
then where can i call it then? what should i change abotu the string?
just make sure its correct.. make sure what u have in the script is the exact same as what u have in the Hierarchy (and the tag is on the object w/ the collider)
and if thats correct.. then u could probably assume that something else is happening and PickedUp isn't being called at all.
When you pick up a muon call PickUp
That should absolutely not be something you have to ask
Not sure even why you have a string like that, so I dunno. I would remove it and just not check tags
You would have to show where you called PickedUp for those images to be useful
Also, you have two methods called PickedUp.
One in Counter and one in MuonCounter. My assumption is you are calling the wrong one
it is a collider
well its disabled.. 🤔 u know that right?
and secondly you said u didnt have errors
it is not, it's just that the down below covers much
theres an error right here
MuonController is also disabled
those aren't errors, those are warnings
yet htey have nothing to do with the counter
okay..
it is not disabled
Ah, you are right. Didn't zoom in enough
Can you show what was asked for now?
You would have to show where you called PickedUp for those images to be useful
Also make sure you saw this
Also, you have two methods called PickedUp.
One in Counter and one in MuonCounter. My assumption is you are calling the wrong one
https://gdl.space/umuqabecuy.cpp
https://gdl.space/ebulipubok.cs the pickups method are called differently
Neither of these scripts have a PickedUp call
👀
am i supposed to put MuonCounter.Instance.PickedUp(); somewhere in the counter?
I don't think so. That doesn't make sense to me
Just show WHERE YOU CALL PICKEDUP
Either one. The counter one or muon counter one
Show it, do not ask more questions. This is not a test. Just show it
how can i show where i call pickedUp if it's nowehre to be shown at all? like PickedUp();
Well then that is the issue. If you do not call it, it does not execute. As you have been told countless times now
You keep showing us PickedUp as if that is the issue....
i know what you told me, that is what i meant if i should call PickedUp somewhere
how else would the code run?
ami supposed to call it from void update?
that would make it run every frame..
u need to think about when it should run..
you've already been talkin about the method it should be inside of..
this stuff is never gonna make sense to you though..
And YOU should know that. You call it when you pick them up. Just think for the two seconds required to know where to call it.
We are not going to write your entire game for you. Just the near 50% we have so far
isn't ontriggerenter something when the player object touch a gameobject?
not unless u go back and practice fundamentals some more.. you've skipped a great deal
yea.. like a coin.. or a Muon*
w/e that is
Like a muon.....
😭
soo when u touch one of those.. u should probably call a function that adds to the counter.. 😐
yet even if i do that, it still doesn't work
Do either of those debugs show up?
And how about for now you stop saying the words "it doesn't work" they are useless and unhelpful
coutner not found do show up, but only when i touched the goal
Ok, so counter is null. Did you make that a singleton. I think I remember Navarone saying to do so
yeah i did
Then use the singleton
Remove the null check, and use Counter.Instance instead of counter (lowercase)
So instead of doing what I said, you removed the counter.SaveData call
nononono, that was on the goal script
Ok. It is so convoluted. Hard to keep track
So when we talked about needing to do it on the muon object, why did you show the goal script?
#1265813900037853255 message
i accidentally picked the wrong one
i still get the nullreference even thought with Counter.Instance.LoadData(new GameData());
wrote a debug
Then you did not assign Instance
No need to show me this at all
Just say "yes the log showed in the console" or "no, the log did not show"
but i did
Show it
Sigh.... show where you set instance
the log did shwoed up when i interact with the muon object
I don't see you assigning the instance here.
You have not set Instance anywhere here, as I guessed
So Instance is null
It's one of the basic things that you didn't learn that's biting you: declaration vs assignment
Go and learn the basics properly already.
public static Counter INstance, it's right htere
That. Is. Not. A. Fucking. Assignment
We have been over this countless times
My mind is rotting over this lol
You just absolutely refuse to even try it feels like.
Please please please do the basics courses I have linked like 30 times over the last however many months
Where do you write Instance =
With an EQUALS SIGN
There you go, the absolute bare minimum.
That is an assignment
Now stop and do this
https://www.w3schools.com/cs/index.php
And then
https://learn.unity.com/pathways
the debug do call when i touch the muon object
Respect
Good.
Do not ignore what I just said
Yup.. good luck on ur development..
i did not ignore it
You did not respond to it. That is by definition ignoring it
Go do AT LEAST the first link before coming back
At this point though, I refuse to help until you prove you have.
I wish you the best of luck, whatever you choose to do
it's just that I did done that a long time ago, but yet no matter how many times i do, all i do is forget and forget, and I cannot remember everything i've did, and it's something I cannot overcome and it hurts so much for me, I hate myself
while i only know a few things...
I'd just say that you didn't do proper learning. You probably read through without proper understanding and didn't bother researching it further or asking for help, until you have a correct understanding. Obviously, if it doesn't make sense in your head, you wouldn't remember anything.
If it does, then it's like riding a bicycle - you can't really forget it.
I still won't remember all of this, only a few things because no matter how much i do, i always tend to forget things like that, I just want this to be fixed
Read my message. I explained why you forget things.
I know what you said, but i still always forget things like that
Then go do proper learning and don't just skip things you don't understand. Ask in the community if needed.
Otherwise it's gonna be a torture both for you and whoever ends up helping you.
Like this excuse doesn't even make sense. What exactly did you forget? Can you even name it?
like this instance assigning
It's assignment in general and there's no way you can forget about it. It's like 50% of code.
Saying you forget it is like saying that you basically don't know how to code
i just want it to be fixed that the number can go up when i touch a muon object
i jsut want this to be fixed... I am not doing well in tests like in "F"s and "E"s, i cannot take care of myself, I've been in the coding school for 3 years yet i always forgot how it works, I am just more used to designing... I am just dumb, 😢
Then hire someone to do the coding for you. We can't help you if you don't understand our help.
I'm really sorry, but it sounds like emotional distress and perhaps something you should seek psychiatric help for.
I have been through that.
To get real, i got some diagnoses, some medication, and am seeing a therapist.
You need to take care of yourself first.
Tying your self-worth to education success or completing challenges is a horrific way to live. It will make it so much harder.
https://gdl.space/zuvedeyedo.cs
not only that, i do have ADHD and Autism which very much hard for me which is why i tend to forget things. and you, you're right, i tend to get very much sensitive when things doesn't work or that i don't understand why it is not working...
like that counter thing, it worked before but not anymore every since the instance coding...
i just wanted it to be fixed... but I don't know how i did eveything that like the instance, playerprefs...
and I just can't let it go until it's fixed...
😢
I don't know what to do... should i really need to get help from someone else?
You'd need to provide the current error. I'm assuming you've resolved the nre ( #1265813900037853255 message )
You should post your new/current issue to #💻┃code-beginner with a link to this thread, if necessary, so that folks are aware of what's been resolved and not when they attempt to further assist you - assuming the previous nre had been resolved.
ok... I can try
If anyone notice
Maybe you ought to try again but explain a bit more thoroughly. Make sure to break the problem down and explain exactly which parts work and don't work. Show any and all errors.
but I don't have any errors showing
That was the final sentence, don't ignore the previous ones.
I'm not ingoring
You literally did not even respond to it at all.
As I said earlier, that is what ignoring means. You only responded to the last sentence and didn't do anything else suggested
I did in #💻┃code-beginner "what doesn't is the number counter not going up when i touched a game object from other scenes, since I don't know how to make it persistent"
That is... not very great honestly. But ok. It is better than previously
How about this:
I am working on persistence and have an issue where a counter is not persisting across scenes and runtimes. I have a counter, and it goes up in on scene, but does not show changes when going to other scenes. I am using DontDestroyOnLoad and PlayerPrefs
[Put code here]
all the 3 codes from stack overlfow?
I dunno. The one where you try to save the values and load them. The one with DDOL.
By the way, stack overflow is not a good place to ask questions about specific unity dev issues
There is a Unity stack and a Game Dev stack
well the coutner script, and odn't forget that this ui text about the number are supposed to be only be seen in the stage selection scene
unity stack and a game dev stack? what's wrong with stack overflow?
Stack overflow is for general help. There are literally places on stack exchange SPECIFICALLY for unity and game dev. Use those
https://gamedev.stackexchange.com/?tags=unity
Hmm, I do not see a unity one. Misremembered.
But yeah, game dev is what you want
huh, this is my first time there
Woah. Ok, so you didn't really take any of the notes I said into mind.
No need for the "muon counter "0/15"" part at all, things like that just makes things so confusing.
Also, the script formatting is completely messed up
I recommend deleting all your explanation and just copy this
#1265813900037853255 message
And then use paste site links for the code
ok, made a new one but the message "You can only post once every 40 minutes" so i will have to wait to post it
I don't know why you didn't just edit the first one
But either way, good luck!
i have deleted it so... there https://gamedev.stackexchange.com/questions/211548/how-can-i-increase-my-counter-and-have-it-persist-across-scenes-and-runtime
The Singleton pattern: https://unity.huh.how/references/singletons
I can't believe you're still stuck on the same simple issue. It just shows how you didn't make any attempts to learn, or debug and fix the issue. This would only make people want to help you less. You need to show some initiative.
i've been continuing on it on another thread