#is it like for example public string

1 messages · Page 1 of 1 (latest)

frank zephyr
#

her we go

analog yacht
frank zephyr
analog yacht
frank zephyr
#

i don't know if i wrote right,

analog yacht
#

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

frank zephyr
analog yacht
#

Like I said at the beginning of all this

frank zephyr
#

yeah, there's even instance

#

but how can it tell that while these two are the only ones with TotalMuonsPerLevel and CurrentmuonsPerLevel?

analog yacht
frank zephyr
# analog yacht 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

analog yacht
frank zephyr
#

what?

analog yacht
#

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

frank zephyr
#

what do you mean by that?

analog yacht
#

I mean... exactly what I said

frank zephyr
analog yacht
#

whenever you collide with a muon
you would reference this object
and change the count of current muons on it

analog yacht
frank zephyr
analog yacht
frank zephyr
#

the counter doesn't go up when i touched a muon object in the stage level

analog yacht
#

Okay

#

and am I just supposed to fire up the NSA spy satellite to see how you implemented that

frank zephyr
#

what?

frank zephyr
frank zephyr
# analog yacht Okay

I mean like how can TotalMuonPerLevel and CurrentMuonsPerLevel texts can tell with only just that?

frank zephyr
#

ok so i have added in instance = this? is there something more needed for it to work, when you exit the game?

void adder
frank zephyr
#

oh?

#

is it bad if that happens?

#

also, where and i adding in the MuonCounter.Instance.UpdateText()?

void adder
void adder
frank zephyr
frank zephyr
void adder
void adder
frank zephyr
void adder
#

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

void adder
#

MuonCounter.Instance._allMuons

frank zephyr
void adder
#

What?
I said:

I have still never seen where you call LoadData

frank zephyr
#

it wokrs for the coin counts

frank zephyr
frank zephyr
frank zephyr
void adder
void adder
# frank zephyr

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

frank zephyr
void adder
sharp smelt
# frank zephyr

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.

void adder
#

It was an example for what you can do, not something you were supposed to randomly enter for no fucking reason linedol 😸

sharp smelt
#

The error states that you must do something with it (assign something to/from it, increment, decrement etc)

frank zephyr
#

MuonCounter.Instance._allMuons = .....

void adder
#

There you go

#

That's using that brain. Good work

frank zephyr
#

thanks...

#

and i am supposed to put them somewhere?

void adder
sharp smelt
#

You might want to provide where it could be placed if you want a proper suggestion - assuming code hasn't been shown yet.

frank zephyr
sharp smelt
#

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

void adder
#

Use the same name you wrote there....

#

Also, thing = GetInt

#

Not just GetInt on its own of course

#

_allMuons = GetInt("AllMuons") or something

frank zephyr
#

is it SetInti instead?

void adder
frank zephyr
void adder
#

SetInt saves
GetInt loads

frank zephyr
#

oh

frank zephyr
void adder
frank zephyr
void adder
#

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

frank zephyr
#

does it need something in the ()?

covert kraken
#

Look at the docs. Read what the set method does and what parameters it takes

void adder
covert kraken
#

Don't let people spoon feed you more then they already do.

frank zephyr
#

i am

void adder
#

It tells you exactly what you need to do

frank zephyr
void adder
#

Yep, see how it says exactly what to do.

frank zephyr
#

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

void adder
#

No code is ever really supposed to be copy pasted. You need to THINK about what you are supposed to change it to

frank zephyr
void adder
#

There you go

#

Done

frank zephyr
#

but... even i would write data, it still wouldn't work

#

or other way around like the coin one?

void adder
#

Where do you call LoadData
This has been the question I've asked over and over for like hours now

frank zephyr
void adder
#

You MUST call LoadData to load your data though

#

So until you figure it out, you will not load the data

frank zephyr
#

i cannot figure this out if i don't know where since before that it worked for the coin counting without calling it anywhere

void adder
frank zephyr
void adder
frank zephyr
#

Goal object

void adder
frank zephyr
#

Does the numbers change up though line you touch 3 objects and the number changes to 3?

frank zephyr
void adder
#

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

frank zephyr
void adder
#

Alright. Well showing screenshots is a terrible way to share code for just this reason. How could I have known that?

void adder
#

Show the one with load and save

frank zephyr
#

counter is the script with load and save

void adder
#

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

frank zephyr
#

wait what?

void adder
#

You are passing in new GameData() when loading. So that will have default values not related to anything

#

What do you mean what?

frank zephyr
#

it works for the coin counter though

#

so i am not getting rid of any data classes

void adder
#

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()

frank zephyr
#

I am supposed to call LoadData somewhere don't I?

void adder
#

If you want to load data you need to call LoadData

frank zephyr
#

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?

void adder
#

You seem to be ignoring what I am saying.
The issue is writing new GameData() there

frank zephyr
#

what about it?

void adder
#

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

frank zephyr
#

but that's like on e of the things i can only write in the goal script

void adder
#

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

frank zephyr
#

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...

frank zephyr
frank zephyr
#

and please asnwer...

frank zephyr
#

imma go and take a shower

frank zephyr
#

back

covert kraken
#

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)

sudden willow
#

i agree.. lot of questions i have to think about for a second before i can make sense of them..

covert kraken
#

At this point I don't even understand what the question or the issue is and where you are at fixing it.

frank zephyr
#

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

sudden willow
#

-> 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

frank zephyr
sudden willow
#

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?)

frank zephyr
sudden willow
#

share any errors u have.. in the Console as well

#

that'd give us a good start to helping

frank zephyr
#

well.. the thhing is, I don't have any errors in the console

sudden willow
frank zephyr
#

and at first the counter script was used for the coin counts

void adder
frank zephyr
#

well when i debugged it, twice, it didn't go up as no debug about it in the console

void adder
sudden willow
#

yup, i was gonna ask about those debugs u added

void adder
#

PickedUp is not being called or muonTags does not contain that string

sudden willow
#

thats why u dont have any errors.. its not broken.. it just isnt being called

frank zephyr
#

then where can i call it then? what should i change abotu the string?

sudden willow
#

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.

void adder
void adder
#

You would have to show where you called PickedUp for those images to be useful

sudden willow
#

what do i see at the very bottom of this?

#

thats not a collider is it?

void adder
#

Also, you have two methods called PickedUp.
One in Counter and one in MuonCounter. My assumption is you are calling the wrong one

frank zephyr
sudden willow
#

well its disabled.. 🤔 u know that right?

#

and secondly you said u didnt have errors

frank zephyr
sudden willow
#

theres an error right here

void adder
#

MuonController is also disabled

frank zephyr
#

those aren't errors, those are warnings

sudden willow
#

same thing..

#

when we ask for errors thats what we mean.

frank zephyr
#

yet htey have nothing to do with the counter

sudden willow
#

okay..

frank zephyr
void adder
#

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

void adder
sudden willow
#

👀

frank zephyr
#

am i supposed to put MuonCounter.Instance.PickedUp(); somewhere in the counter?

void adder
#

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

frank zephyr
#

how can i show where i call pickedUp if it's nowehre to be shown at all? like PickedUp();

void adder
#

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....

frank zephyr
sudden willow
#

how else would the code run?

frank zephyr
#

ami supposed to call it from void update?

sudden willow
#

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..

void adder
frank zephyr
#

isn't ontriggerenter something when the player object touch a gameobject?

sudden willow
#

not unless u go back and practice fundamentals some more.. you've skipped a great deal

sudden willow
#

w/e that is

sudden willow
#

soo when u touch one of those.. u should probably call a function that adds to the counter.. 😐

frank zephyr
#

yet even if i do that, it still doesn't work

void adder
#

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

frank zephyr
frank zephyr
void adder
#

Ok, so counter is null. Did you make that a singleton. I think I remember Navarone saying to do so

frank zephyr
#

yeah i did

void adder
#

Then use the singleton

#

Remove the null check, and use Counter.Instance instead of counter (lowercase)

frank zephyr
#

ok

#

this is the muon object script

void adder
#

So instead of doing what I said, you removed the counter.SaveData call

frank zephyr
#

nononono, that was on the goal script

void adder
#

Ok. It is so convoluted. Hard to keep track

frank zephyr
#

i accidentally picked the wrong one

void adder
#

Ok.... well add debugs to the muon script

#

And see if they show

frank zephyr
#

i still get the nullreference even thought with Counter.Instance.LoadData(new GameData());

#

wrote a debug

void adder
void adder
frank zephyr
void adder
frank zephyr
void adder
frank zephyr
frank zephyr
covert kraken
void adder
# frank zephyr

You have not set Instance anywhere here, as I guessed
So Instance is null

covert kraken
#

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.

frank zephyr
void adder
#

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

frank zephyr
void adder
#

There you go, the absolute bare minimum.
That is an assignment

frank zephyr
void adder
sudden willow
#

Yup.. good luck on ur development..

frank zephyr
void adder
#

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

frank zephyr
#

while i only know a few things...

covert kraken
#

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.

frank zephyr
#

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

covert kraken
#

Read my message. I explained why you forget things.

frank zephyr
#

I know what you said, but i still always forget things like that

covert kraken
#

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.

covert kraken
frank zephyr
#

like this instance assigning

covert kraken
#

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

frank zephyr
#

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, 😢

covert kraken
#

Then hire someone to do the coding for you. We can't help you if you don't understand our help.

void adder
frank zephyr
#

i just wanted it to be fixed... but I don't know how i did eveything that like the instance, playerprefs...

frank zephyr
#

and I just can't let it go until it's fixed...

frank zephyr
#

😢

frank zephyr
#

I don't know what to do... should i really need to get help from someone else?

sharp smelt
#

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.

frank zephyr
#

ok... I can try

frank zephyr
#

If anyone notice

sharp smelt
#

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.

frank zephyr
#

but I don't have any errors showing

void adder
frank zephyr
void adder
# frank zephyr 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

frank zephyr
#

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"

void adder
#

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]

frank zephyr
#

all the 3 codes from stack overlfow?

void adder
#

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

frank zephyr
#

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?

void adder
frank zephyr
#

huh, this is my first time there

frank zephyr
# void adder Stack overflow is for general help. There are literally places on stack exchange...
void adder
#

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

frank zephyr
#

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

void adder
frank zephyr
# void adder I don't know why you didn't just edit the first one But either way, good luck!
sharp smelt
covert kraken
#

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.

frank zephyr