#A few different issues
1 messages · Page 1 of 1 (latest)
https://gdl.space/civinufova.cpp
his pause script and his original question
Hi there, I'm just learning how to code and I need a lot of help here. I'm trying to recreate a mini game (endless runner) from honkai impact and i have quite a lot of issues there. First I have the issue that when I start the game, it starts paused (though i have [pause = false] in my code). Second, when the player collides with the barrel, it just goes through (even though before it was functioning properly). And the last issue for now, when i press the pause button or the "escape" key (which pauses the game), a panel appears IN FRONT of the pause button and I can't click it anymore, even though I've positioned the button in front of the panel.
I hope I've explained my errors clearly enough so that someone could help me out. I would really appreciate someone's help and thank you
Woops, said exactly what spawn already said. Yeah, check inspector lol
so uhm, the box for bool pause in the inspector is ticked, but when i untick it and enter the play mode, the game starts paused anyway and when i exit the play mode, it is ticked.
did u untick during the play?
my whole life is basically doenhill xdd
any changes u make while the game is playing will revert back
make the change b4 u press play
Are you ticking it on the instance, or a prefab?
i tried it as well, and it stilll stays ticked
thats what i did
is it a prefab like aeth
in the first place
mentioned
you mean the pause button?
oh, the instance
does this debug get called at the beginning?
it shouldn't theres no reason that method would run unless u press esc, or call it elsewhere
ahhhh im sorry for such complications im like super new beginner in coding and development so i understand like 1.99% so far
u need to make sure the prefab is correct...
no problem, thats how we all start
should i just get rid of it?
no.. i mean u want the Pause() function
so, should i make a prefab out of the button? or the whole canvas? or what exaclty?
but it shouldn't be running for no reason
yeah, i sometimes want to destroy my laptop, other times i want to destroy myself xddd
no, he was just mentioning the prefab.. b/c if its a prefab and ur changing it in the scene after u drag it in its not really changing the prefab.. just the instance of it.. so ud want to check if ur prefab object itself.. has that bool turned off
if its not a prefab.. dont worry about any of that
okay im super confused now. what whould i do whit that piece of code then?
okay, thank you
ok.. think about this.. in that script, how does the game get paused
when i press the pause button on the ui screen or when i press Escape key
alrighty... so when the game starts.. how could that Pause() function even be called?
so should i write the "input.getkey" inside the pause method?
no no no..
uhmmm... only when i press the pause button or escape key?
I would change the pause variable to:
private bool pause;
Juuuuuuuust in case some other code tries to change it
yes, only when you press a key
i was gonna mention this exact thing too
since u shouldnt even be modifying the boolean of pause in the inspector at all
hide it so u dont have a chance to accidently change it
Yeah, don't even need the [serializefield]
ooohhh, i will be honest i still havent studied what [SerializeField] does
Just remove all outside vectors of change
omygod im so stupid 
[serializefield] makes em visible basically
in ur case private bool pause = false
would be the only thing i would use
the script needs to know about pause but nothing else does
so it can be private for now
okay thank you~
and if u save that and restart
it should begin paused turned off
(im not even sure how it pauses to begin with)
bc ur logic doesnt run unless u press esc
Also, I didn't see if this was answered, does the debug for "Game Paused" run when the game starts?
unless something else is causing it to fire.. or ur setting timescale somewhere else
it still starts paused...
me neither((
how could the game even start being paused?
i dont see where it could in the first place
OH GEEZ i just checked it and when i start the game, it still starts paused but the debug doesn't run for it, when i click "Escape" it stays paused and the debug runs for it, and when i click "Escape" the second time it resumed
ok..
that means the scripts working like normal
but SOMETHING ELSE
is pausing it
Change all methods to private for one
thats the thing, i dont know how either
Yeah, and there is other code doing this
well now that u answered the question thats a big giveaway
now it makes sense
will do
You can view references to Time.timeScale, see if anything else in your game sets this
Right click it and in the list click find all references or whatever it says
changed them to private, still the same
waitttt
uhm okay so i set the tiime scale to 1 (for whatever reason it was set to 0 even though i've never changed it from 1) and when i enterd the play mode, it started unpaused but the panel was covering the screen, but when i exited the play mode and checked the Time it was set to 0 again
as if there is a poltergeist in my laptop i swear
that should not be happening
u mean the time inside the settings?
is being changed
👀 thats an odd thing to be happening
when a script runs it could modify the timescale to be 0.. but when u stop playing it should be set back to w/e it was (before) u pressed play..
scripts can't change data like that unless its an Editor script or something.. Editor scripts can do things like run code directly inside the editor and change stuff w/o the game running
but anything changed during the game should always be set back.. unless its being changed when the game isn't running
thats what im kind of saying as well... i know for sure i havent changed anything in the Editor script simply because i dont have one (from what i understand)
i just feel like im cursed or something
also, the necessary things weren't recorder for whatever reason, so i cant really you what's hapening exactly
Did you do this?
#1140781651966824468 message
You said you set it, but I didn't know if you meant in code
yes, i have only two Time.scaleTime references
yes
do u have two pause scripts in ur scene? with 1 set to 0
welp, can i get some kind of prize for absolutely destroying unity in noone-even-knows-what-way? xdd
In your hierarchy, type t:PauseScript
Lol, me and spawn are thinking at the exact same pace today
huh, i should have only one
should and do are diffn
okay so, i DO have only one PauseScript, but the pause button is a toggle button and i have the pause script attached to it twice (i still didn't really grasp the toggle button stuff). might this be the root to this issue?
i've disabled it and it still has the same main issue: the time keeps changing itself to 0
yep, i've changed it to 1 before testing, and it's back to 0 after testing
i think so too
maybe time to search google.. with what u know
disable the pause script and test
if it doesn't happen when u disable the script then u have ghosts
but my guess is something else is changing it
the new scene doesn't change time to 0
alright. now test the pause script
i definetly got ghosts xddd
the time changes back to 0 even with PauseScript disabled xddd
omygawd what did i do to who in my past life???
welp, unless u get that fixed not sure what good the other issues are atm
i have no clue wat it could be. u gotta find it.. theres something setting the timescale to 0 or some issue ud have to saerch google or ask the chat again for
why dont u just try to restart
it maybe a unity bug..
loading in a new scene and it working as expected leads to me think its not tho
change this drop down to say Runtime only
why in the heck do u have editor selected there
@vocal fog
i've posted this timescale problem to unity forum, ill see what happens
same
oh yeah because i dont really know what difference it does
im a super newbie
wow
ur not that newbie.. check em out..
Runtime.. <-- thats the one u want..
Editor means when ur editing the game.. the editor.
u had it set.. so that toggle/ button w/e was allowing the code to change the code in the editor
so now it stays at time scale 1 even though i didn't do anything
which is where ur ghost is
yup, got it
uhhhpppp yep im dumb sorry
thats ur pause menu issue fixed.. but leads to another issue.. why was the button pressed / toggled or w/e as soon as the game started?
i kind of had the feeling, but as i say, i still dont understand like 98% of everything xd
if u ignore that.. u jst got sorting issues left.. just make sure the stuff is in order..
The Canvas
- The Canvas Background
-- The Text On Top
the higher the stuff in the heirarchy the lower it is.. so think of it.. like as u go down the projects gameobjects they get drawn on top of the others..
maybe because the toggle button was affecting the editor since it was set to editor and runtime
which is exactly what we just fixed right now
ahhh right yeah, that's what i struggle with as well
so keep that order in mind.. and if that doesnt work theres always sorting layers.. u can also make things not detect raycasts, things like text, and images, if they're on top and u need to click thru it u can just mark it as Raycast Target to false in the inspector
i come from the art background, so for me if the layer is on top, it is the first thing you see
yea its opposite of what u would think like in photoshop..
thanks a lot~
np
though if you use sorting layers, then the one which is on top is the one which appears on top, right?
if ur using sorting layers it doesnt matter..
the order can be anyway.. and its just 0, 1, 2, 3 like normal
drawing 0 first, and 3 last (on top)
ooh i seee
oh, also
i hope it's just a small and quick problem to fix, but when i start the game, the panel is active, but i want it to be disabled. i want it to appear only during when the game is paused
though, when i pause and then resume the game, the panel dissapears as it should
i think there might be something in the inspector that doesn't diasble the panel when i start the game?
i dont know, should i just set panel to SetActive(false) in the void Start()?
u can just disable the tickbox in the inspector if it should start disabled
u can still reference and enable a disabled gameobject.. so thats how most of my systems work
unless the logc that disables it is on the object itself.. which wouldnt make sense anyway.. u wouldn't be able to enable it b/c the code would be disabled
OH yes it works thank god xddd