#A few different issues

1 messages · Page 1 of 1 (latest)

hardy python
#

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
livid oak
#

Woops, said exactly what spawn already said. Yeah, check inspector lol

hardy python
#

^ firstly..

#

its all down hill from there

#

lol

#

@vocal fog

vocal fog
#

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.

hardy python
#

did u untick during the play?

vocal fog
hardy python
#

any changes u make while the game is playing will revert back

#

make the change b4 u press play

livid oak
vocal fog
vocal fog
hardy python
#

is it a prefab like aeth

vocal fog
#

in the first place

hardy python
#

mentioned

vocal fog
vocal fog
hardy python
#

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

vocal fog
#

ahhhh im sorry for such complications im like super new beginner in coding and development so i understand like 1.99% so far

hardy python
hardy python
hardy python
#

no.. i mean u want the Pause() function

vocal fog
hardy python
#

but it shouldn't be running for no reason

vocal fog
hardy python
#

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

vocal fog
vocal fog
hardy python
#

ok.. think about this.. in that script, how does the game get paused

vocal fog
#

when i press the pause button on the ui screen or when i press Escape key

hardy python
#

alrighty... so when the game starts.. how could that Pause() function even be called?

vocal fog
#

so should i write the "input.getkey" inside the pause method?

hardy python
#

no no no..

vocal fog
livid oak
#

I would change the pause variable to:

private bool pause;

Juuuuuuuust in case some other code tries to change it

hardy python
#

yes, only when you press a key

hardy python
#

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

livid oak
#

Yeah, don't even need the [serializefield]

vocal fog
#

ooohhh, i will be honest i still havent studied what [SerializeField] does

livid oak
#

Just remove all outside vectors of change

hardy python
#

it exposes the variable in the inspector

#

private variables are hidden normally..

vocal fog
hardy python
#

[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

vocal fog
#

okay thank you~

hardy python
#

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

livid oak
#

Also, I didn't see if this was answered, does the debug for "Game Paused" run when the game starts?

hardy python
#

unless something else is causing it to fire.. or ur setting timescale somewhere else

vocal fog
#

it still starts paused...

vocal fog
hardy python
#

answer this

#

does it debug.log that message when u start the game..

hardy python
#

i dont see where it could in the first place

vocal fog
hardy python
#

ok..

#

that means the scripts working like normal

#

but SOMETHING ELSE

#

is pausing it

livid oak
vocal fog
#

thats the thing, i dont know how either

livid oak
#

Yeah, and there is other code doing this

hardy python
#

now it makes sense

vocal fog
livid oak
#

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

vocal fog
vocal fog
#

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

hardy python
#

that should not be happening

#

u mean the time inside the settings?

#

is being changed

vocal fog
#

ill try show it to you

hardy python
#

👀 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

vocal fog
#

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

livid oak
#

You said you set it, but I didn't know if you meant in code

vocal fog
livid oak
#

Both in the pausing script?

#

Weiiiiird

vocal fog
#

yes

hardy python
#

do u have two pause scripts in ur scene? with 1 set to 0

vocal fog
#

welp, can i get some kind of prize for absolutely destroying unity in noone-even-knows-what-way? xdd

livid oak
#

In your hierarchy, type t:PauseScript

Lol, me and spawn are thinking at the exact same pace today

vocal fog
hardy python
#

should and do are diffn

vocal fog
#

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?

hardy python
#

disable that toggle

#

get rid of and test

vocal fog
#

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

hardy python
#

u got ghosts..

#

make a new scene and press play

vocal fog
hardy python
#

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

vocal fog
hardy python
#

alright. now test the pause script

vocal fog
#

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

hardy python
#

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

vocal fog
vocal fog
#

im a super newbie

#

wow

hardy python
#

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

vocal fog
#

so now it stays at time scale 1 even though i didn't do anything

hardy python
#

which is where ur ghost is

vocal fog
hardy python
#

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?

vocal fog
#

i kind of had the feeling, but as i say, i still dont understand like 98% of everything xd

hardy python
#

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

vocal fog
#

which is exactly what we just fixed right now

vocal fog
hardy python
#

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

vocal fog
#

i come from the art background, so for me if the layer is on top, it is the first thing you see

hardy python
#

yea its opposite of what u would think like in photoshop..

hardy python
#

np

vocal fog
hardy python
#

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)

vocal fog
#

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

hardy python
#

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

vocal fog
#

OH yes it works thank god xddd