#💻┃code-beginner

1 messages · Page 403 of 1

swift crag
#

Scripts are not "on objects". Scripts are files that contain text.

#

Do you have a BorderController component attached to anything?

polar acorn
#

So then why did you say that you had no instances

swift crag
#

borderController is the name of a field. Are you talking about that field?

wooden socket
#

theres 2 scripts

late burrow
#

implicit conversion is amazing i can use one type for everything

wooden socket
#

borderController and transitionController

#

I want to pass the lives value from borderController into transitionController

#

because I have this

polar acorn
wooden socket
swift crag
#

borderController is not "A script"

shell sorrel
wooden socket
#

yea its a class

swift crag
#

borderController is a field -- a variable -- on your TransitionController class

polar acorn
# wooden socket

Which instance of BorderController do you want your variable borderController to hold

swift crag
#

Its type is BorderController

wooden socket
#

okay wait its clicking a bit

swift crag
#
public Foo bar;

I have to actually put a Foo in this field, or else it's just going to be null

shell sorrel
#

fields and variables that are not primitive types or structs are just a slot you can plug a isntance of that thing into

wooden socket
#

okay so I would type public borderController collisionCollider;

swift crag
#

No, because there is no such thing as borderController

#

BorderController certainly exists

#

A field declaration needs a type -- the kind of thing it holds -- and a name -- how you'll refer to that field

#

The name can be whatever you want

#
public BorderController florp;
#

This would be perfectly legal.

wooden socket
#

okay I think I fixed it

swift crag
#

public bordercontorller florp;

This would be a compile error, because there is no such thing as bordercontroller

wooden socket
#

okay well I got the same error in unity but VScode doesnt

polar acorn
# wooden socket okay wait its clicking a bit

Allow me to explain classes and variables using "The Cat Metaphor".

Imagine you are a mad scientist with a cloning machine. You can 3D Print any animal by running their genome sequence through your Animalizer 3000™️. You have the full DNA sequence of a cat on a big sheet of paper. This sheet of paper is not a cat. It is, in essence, how to cat. You cannot feed the paper catnip. You cannot flip the paper over and pet its belly until it bites you. It's a piece of paper.

Now, when you run that paper through the Animalizer 3000™️, you can make a cat out of it. The window pops open and you've got a black cat, and you give it the name ollie. you now have a variable of type Cat that is named ollie. public Cat ollie. This is an instance of Cat. This one can eat catnip and get belly rubs, but you can't fit it in the paper slot of your Animalizer 3000™️. It is not a genome, it's a Cat. It is no longer a script, this Cat is a Cat.

You can then feed that sheet of paper into the machine again, and the door pops open, this time, a gray cat. You can name him junior. If you want to call ollie, you'd use his name. If you wanted to call junior, you'd use his name. If your friend came to your house and you told him "Watch out my cat bites", they would probably ask you "Which one?". You'd need to tell him which cat is the one that bites. He could then store that in his brain as public Cat thatOneThatBites. Now, public Cat ollie and public Cat thatOneThatBites both refer to the first black cat, but each person has their own variable that holds it.

If you then told your friend "Watch out, because my Tapir also bites." they'd probably be confused. You don't have a Tapir. You have two Cats. There's no Tapirs in this house! Why would they tell you the Tapir bites if there is none? They are confused and angry. They start smashing stuff in frustration. This is a NullReferenceException. Their variable public Tapir thatTapirThatBites contains no Tapirs because there aren't any. If you want them to know that there is a Tapir that bites, you'd need to actually have a Tapir to tell them about.

#

Now, your file, BorderController.cs is the genome of your script. Have you ever "turned on the machine" by attaching that script to an object anywhere?

wooden socket
#

i just did

#

i have 2 files named the same thing for some reason

wooden socket
#

i now perfectly understand

daring tiger
#

can anyone help with a player movment issue

verbal dome
#

Why private? Better chance of getting help if you ask here

naive pawn
#

no thanks, just ask here

#

more people to check your issue and answer

polar acorn
swift crag
#

allowing you to pirate your cat by creating new cats based on its reverse-engineered blueprint

polar acorn
naive pawn
swift crag
#

Here's my pet System.Object

polar acorn
swift crag
#

actually, that is a very accurate description of one, haha

shell sorrel
#

also about the above, anyone new should just forget what reflection is and never use it till you are experienced

swift crag
#

actually reflection is COOL and we're just gatekeeping you from it because it's so fun and epic

wooden socket
#

okay well

swift crag
zenith cypress
remote osprey
#

has anyone done a "click on specific gameobject" event?

#

I have something I know I can make

#

but just writing the code feels daunting

wooden socket
#

okay so problem

shell sorrel
wooden socket
#

when I press space it does the transition but NOT when collisionCounter is 4

polar acorn
remote osprey
#

Could you show me ropes?

shell sorrel
remote osprey
#

3d

naive pawn
remote osprey
#

it's just that the z values will be different for reasons

shell sorrel
remote osprey
#

3d

wooden socket
shell sorrel
#

so make sure you got a PhysicsRaycaster component on your camera

polar acorn
wooden socket
#

when its 4

shell sorrel
#

where it implements the IPointerClickHandler interface

daring tiger
#

when i press start from my main menu i cant look or move

wooden socket
#

the space thing is for another scene

shell sorrel
#

and does the logic you wnat to happen in the OnPointClick method, then put this component on the object you want to respond to clicks

polar acorn
wooden socket
#

yea

#

so im saying

polar acorn
#

If either condition is true, it runs that function

wooden socket
#

OH

#

well no

wooden socket
#

bcs im saying when its 4 it doesnt do it

verbal dome
wooden socket
#

it just goes straigh to the next scen

#

scene

polar acorn
shell sorrel
# remote osprey Ok, done!

yeah so that OnPointerClick method, will execute anytime you click a object that has a collider that you put this script on

wooden socket
#

theres also this

shell sorrel
#

also make sure your scene has a EventSystem

wooden socket
#

unassigned reference erroir

daring tiger
verbal dome
#

I assume that loads a new scene?

daring tiger
remote osprey
#

Then all I have to do is call the object's TargetType.HandleBeingClicked()

polar acorn
remote osprey
#

And implement a HandleBeingClicked() for eevery object

remote osprey
#

Thank you very much, @shell sorrel !

wooden socket
#

heres a problem

shell sorrel
remote osprey
wooden socket
#

i took the obect called transStart off Trans Start just before to test

shell sorrel
#

way i showed you is most ideal if you want logic to run on 1 object when its clicked, if you want it for any object without having to add a script to each one there are other ways. Like getting your mouses position then using ScreenPointToRay on the camera then using the returned ray to raycast

remote osprey
#

so something like

public abstract ClickHandler : MonoBehaviour, IPointerClickHandler
{
 public bool CheckIfClicked();
}

Should do what I want just cleanly 😄

remote osprey
#

It's cause what I want to do is complex

shell sorrel
#

is what you need for the signature

#

not CheckIfClicked

remote osprey
#

Oh, I see

verbal dome
#

Also missing class

remote osprey
#

I want to be able to initiate a click event, also

#

So the next click is gonna determine the outcome of the event

slender nymph
#

seems like you're just recreating the EventTrigger component, but worse

remote osprey
#

IF it hits a target object type, then it returns that target Object type sas the target

#

else, it stops the event and doesnt do anything

noble reef
#

is this in the correct order, if im trying to make a script to make text pop up when the mouse hovers over the cube

shell sorrel
#

@remote osprey also if you dont want to call logic in this script like @slender nymph suggested, the EventTrigger component will letyou call a function on a other object when this object is clicked

remote osprey
#

Oh is see

slender nymph
noble reef
remote osprey
shell sorrel
#

Add Component -> EventTrigger

wooden socket
#

man idk what to do

slender nymph
shell sorrel
#

then in there you can listen for multiple types of events to execute a function on, works smilar to how Button does in UI

noble reef
slender nymph
#

if it is not a world space canvas, then no. if it is a world space canvas, then sure. but does it need to be a world space canvas

remote osprey
#

I put a mesh inside my canvas xD

#

Then inside the mesh there are UI gameObjects

#

It was working fine, tho :p

polar acorn
noble reef
#

wait im confused now

#

for my purpose do i need a world space canvas?

daring tiger
slender nymph
rich adder
wooden socket
noble reef
#

im not tryna make it have a position in the world, im tryna make the text appear on the screen

wooden socket
#

wait i can fix the bottom one

slender nymph
# wooden socket

The variable transStart of TransitionController has not been assigned. You probably need to assign the transStart variable of the TransitionController script in the inspector.

polar acorn
# wooden socket

Looks like the variable transStart of TransitionController has not been assigned. You probably need to assign the transStart variable of the TransitionController script in the inspector.

wooden socket
#

it is assigned

polar acorn
wooden socket
#

okay then I should assign it

polar acorn
#

You should try to find the one that doesn't have that field assigned

#

Hint: you can search your hierarchy for instances of a script by typing t: Script Name in the search bar

daring tiger
verbal dome
#

Isn't that... Unreal Engine?

daring tiger
#

oh

#

im fucking stupid

polar acorn
#

GET HIM

wooden socket
#

wait wrong worfd

#

@polar acorn i literally cannot find where it isnt assigned

polar acorn
slender nymph
#

put a log on the line right before the error that prints the object it is null on

wooden socket
#

search doesnt work

polar acorn
#

Show your search

wooden socket
polar acorn
wooden socket
#

yup

polar acorn
wooden socket
#

oh

polar acorn
wooden socket
#

wait is it because

#

i have the keyInput set to none

polar acorn
#

What

#

You need to spell your class's name right in the search

#

that's it

wooden socket
#

okay

#

well yea idk what to do

#

everything is assigned in inspector

slender nymph
wooden socket
#

ill do that

polar acorn
wooden socket
#

wait

#

is it bcs I have the same code in 2 scripts

slender nymph
#

no, but also why do you have the same code in two scripts

wooden socket
#

i just realized yea ikd

slender nymph
#

that's not even the same code

wooden socket
#

ok

#

yea idk whats going on

polar acorn
#

Show the search results

wooden socket
#

the objects collide with the object

#

ok

slender nymph
#

now show the TransitionController component on each of those two objects

polar acorn
wooden socket
#

found it, but now I get a COMPLETELY different error

polar acorn
#

Do they all have the variable set

loud patio
#

!docs

eternal falconBOT
wooden socket
polar acorn
wooden socket
#

found something weird too

polar acorn
#

If the stack trace doesn't mention a script you wrote, clear and see if it goes away

wooden socket
#

this object didnt exist until now

#

and I cant put anything in the collision counting

teal viper
#

You can probably put a BorderControl instance in it.

wooden socket
#

okay I just put it on

#

yup, that temporary object appears and then i cant edit it

loud patio
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

polar acorn
wooden socket
#

lemme check my scripts, idk if I even did that

#

Yea I didn’t

stuck palm
#

is there a way to do Directory.GetFiles asynchronously?

#

nvm found a solution

wooden socket
#

i didnt make a temp object and it still made one

#

yea the error is from the temp variable what the hell can I do @polar acorn

polar acorn
#

for that matter, what is the error

wooden socket
#

lemme sss it

#

it makes an object called "transition" and THATS where this error comes from

#

I cant put the script in the slot its supposed to

wooden socket
#

this script

long furnace
wooden socket
#

i dont want to delete it right?

polar acorn
wooden socket
polar acorn
#

And did you check to make sure you don't have another copy of TransitionController?

wooden socket
#

lemme check

#

i have a script called transitionController

polar acorn
#

And is it on any other objects

wooden socket
polar acorn
# wooden socket

Two questions:

  1. do either of them have a variable missing
  2. why is there another instance of this script on another object
stuck palm
#

is there a way to force framerate other than Application.targetframerate

polar acorn
#

Should there be two? If so, you need to assign the variable on both

wooden socket
#

ill disable it on border

polar acorn
#

is it supposed to be there

wooden socket
#

okay yea same error

#

let me try and disable it on the other one

verbal dome
stuck palm
#

cus idk how i would set it to 60 right as the application started

verbal dome
#

From Awake in a script in your first scene

wooden socket
#

@polar acorn yea the error is this temporary object that goes away when it iisnt running

#

is it the coroutine?

#

IT IS

#

how do I set the collisionCounting in here now

#

YUP

#

still not working

carmine sierra
#

startcoroutine() is the only way to call another method within a method?

verbal dome
#

No, that starts a coroutine

rocky canyon
#

no?

verbal dome
#

Or what exactly do you mean with "method within a method"?

stuck palm
#

@swift crag might just have to force 60fps on the game which is annoying cus i wanted it to be smoother, but most dont have a monitor above that value anyway so

polar acorn
#

If you don't want to spawn it, don't

wooden socket
polar acorn
#

You wrote the code, where are you spawning an object that has this script on it

verbal dome
wooden socket
#

but it makes an object ive never made

polar acorn
#

You're making one somewhere

#

either with Instantiate or new GameObject

wooden socket
#

IT WAS IN ANOTHER SCENE

#

SHIT

#

aaand I still cant assign it

stuck palm
polar acorn
#

whether it be a prefab or in a different scene

wooden socket
#

okay well

#

now im in the other scene

#

i cant put ANYTHING into collision counting

#

okay well now theres an even BIGGER PROBLEM

#

THE SCORE KEEPS STAYING AND WONT RESET WHEN YOU RESTART THE GAME SCENE

#

im dealing with the transition stuff later

#

this is more pressing

verbal dome
wooden socket
#

guys I seriously need help

#

this is a core part of my game

#

I cant have this be messed up

#

i need the score to reset every time the player enters a scene

#

lemme do some resarcg

stuck palm
polar acorn
wooden socket
#

idk

polar acorn
#

Just have something in the new scene reset it on Start or something

wooden socket
#

okay how do I do that

polar acorn
#

You remember how you accessed the score to display it

#

Do that, but set it to 0 instead

wooden socket
#

so in start I just do

dim yew
#

0 idea why this is happening, just copied the code from another one of my games

#

i am on a slightly newer version of unity so maybe that's why?

wooden socket
#

what the hell

#

idk what to do man

frosty hound
polar acorn
wooden socket
wooden socket
ivory bobcat
#

You'd assign it the score value as a string from the instance of the score manager.

polar acorn
wooden socket
#

scoreManager

polar acorn
wooden socket
#

so then I should put start in there right

polar acorn
wooden socket
#

this object goes into which scene

#

okay i think i figured it out. let me test

polar acorn
#

Start runs on the first frame an object exists for. If it's on any object in a scene, it'll run when that scene loads

stuck palm
#

I'm convinced this system I've made is vulnerable to even a sneeze and it all topples over

#

Because why does a replay work flawlessly one time and fail the next time

#

Would frame dips mess anything up?

wooden socket
#

@polar acorn ur not gonna believe this

#

i think I fixed both issues

teal viper
dense plume
loud patio
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

wooden socket
#

okay so

#

is this the way to reset the score?

stuck palm
stuck palm
# teal viper Debug it to figure it out.

I've been keeping recordings of the game state which has player locations and velocities. They are very similar mostly, and sometimes identical, but most of the time they're off by about a tenth of a unit, which could be the problem.

ivory bobcat
wooden socket
#

different issue

summer stump
# wooden socket

If by resetting it you mean setting it to 0 when start runs, then sure.

Have you tried it? Because this is extremely easy to just run and see what it does

wooden socket
#

i mean when you re enter the scene

summer stump
wooden socket
#

yea it keeps being added

#

i put it in scoreManager

summer stump
#

I assume that by "it" you mean the score, and "keeps being added" you mean from the value it was before the scene reset.

Is scoreManager in DontDestroyOnLoad? If so, Start will not run

wooden socket
#

oh shoot

summer stump
#

Please try to be a bit more descriptive too. Because that was very confusing

wooden socket
#

lemme get rid of this right?

summer stump
#

If it is in DDOL, then you can do a few things

#

Either register to the onSceneChanged event, or just set it to 0 where you load the scene

summer stump
wooden socket
#

ok

dense plume
wooden socket
#

could I do this just by saying like

#

man idk

ember tangle
#

I cannot for the life of me understand why this does not work when the queue is larger than 2: public void ClearFormationQueue() { for (int index = 0; index < nextPosition.Count; index++) { GameObject destroyMe = nextPosition.Dequeue(); Destroy(destroyMe); } Debug.Log($"position queue cleared, new size is {nextPosition.Count}"); }

wintry quarry
#

your code doesn't make sense. Think about this example with 5 elements in it:

index  count
0      5
1      4
2      3
3      2 << your code will stop with 2 left.```
ember tangle
#

Hmm y'know that makes a lot of sense

#

I guess a for loop would never work for clearing a queue then?

wintry quarry
#

if you really wanted to use a for loop it should look this way:

int count = nextPosition.Count;
for (int i = 0; i < count; i++) {
  GameObject destroyMe = nextPosition.Dequeue();
  Destroy(destroyMe);
}```
#

just reading the count once at the start

wooden socket
#

im very confused

ember tangle
summer stump
wooden socket
#

ah true

#

lemme find it

#

man

#

@summer stump i cant do it

summer stump
wooden socket
#

i cant find it

#

like check this out

#

wait

#

should I just make a new script

#

I FIXED IT

#

YEAA

#

nvm

#

i didng

frosty hound
#

Can you stop spamming?

wooden socket
#

okay im sorry

frosty hound
#

And stop bothering people, if they want to take a break from doing this dance again, let them.

wooden socket
#

okay, im sorry

rocky canyon
#

dance he said lol

summer stump
wooden socket
#

wait i think I found it out. I put the line of code when the scene changes to the leaderboard, not when the leaderboard changes to the gamae

candid walrus
#

!code

eternal falconBOT
teal viper
#

And be running the same logic during a replay as during an actual game, but providing inputs from your replay data instead of the player controller

#

That's how some AAA fighting games handle replays

candid walrus
#

Hello, I am a beginner at c#/unity. Can somebody tell me how I should create a building/hammering animation. Should I use code to transform the object or should I make an animation?

teal viper
candid walrus
#

Which way would be easier if I will use the animation very often?

teal viper
#

Implementation?

candid walrus
#

Yes

teal viper
#

Well, depends on how sophisticated you need it to be. If it's just a building rising from the ground like some strategy games do, it would probably be easier to just code it.

#

If you want a unique animation for each building with walls and other parts rising and what not, it's gonna be pretty difficult to do via code.

candid walrus
#

OK, thanks

potent raft
#

What is the preferred setup for C# code editing on mac with unity

#

is it vs code? or visual studio for mac? because i've heard bad things about visual studio for mac

potent raft
#

i've never even heard of that

wintry quarry
#

It's the best one

#

It's just... not free unless you're a student

potent raft
#

ok, i'll check it out!

summer stump
potent raft
#

added a property and it compiled when i went back to unity. very similar to godot

rich adder
magic panther
#

neither hatebin or hastebin are working. Any other alternatives recommanded?

slender nymph
magic panther
#

!code

eternal falconBOT
magic panther
#

I don't know if this is more suited for #archived-code-general, but I have a big problem here and need the function to have a very precise functionality.

Function -> https://gdl.space/nucilatawi.cs

Fragments are parts of Pieces. At some point in the code, a Piece will call the function on each Fragment it consists of twice. Once with Vector2(0f, 1f) passed, once with Vector2(1f, 0f), so, vertical and horizontal.

The function is supposed to check both ways if the fragment exists in a position where it's in a horizontal or vertical line between two Walls, with at least one Fragment (including itself) and at least one BrittleWall with it inside the line. If yes, set itself and everything between these two Walls as marked. Later on, marked objects will be deleted. If there is air or anything unwanted detected, the function automatically fails. So no air or players.

There is a problem with this, where stuff just isn't properly recognized. In the formation on the screenshot, selected Fragment(1) is somehow telling me that it encountered a wall, when there is no wall it could access.

If anyone has any idea on how to fix this, I'd greatly appreciate it.

#

I think it's working

#

but I'm not sure

wheat rune
#

would netcode for entities or something like Mirror be better for a base building strategy game with multiple worlds

slender nymph
#

you also need to research the available networking solutions to find out which fits your needs best. there is never a "one size fits all" answer to something like that

chrome shadow
#

what is a good way to break of out update loops?

slender nymph
#

can you be more specific about what you mean by that

cosmic dagger
chrome shadow
#

im not sure if this is the correct way to do it

#

i want to activate the function A when isDone is true

rich adder
chrome shadow
#

i just wanted to know if there are other methods of breaking out of update loops

wooden socket
#

my animation wont work in one scene but it works in every other scene 😭

#

this is rlly strange

rich adder
chrome shadow
#

oh alr thx

slender nymph
#

Update is not a loop. it is a regular method that just happens to be called every frame. the only time Update is not called is when the component is disabled or the object it is attached to is inactive

chrome shadow
#

ah i guess i misunderstood its function, thanks a lot

wheat wave
#

!ide

eternal falconBOT
slender nymph
wheat wave
#

all the text appeared white 😭

wooden socket
#

okay so for some reason I have an animation that plays in EVERY other scene BUT this one

#

i think its a code thing

slender nymph
wooden socket
#

isnt this a help channel

slender nymph
#

i'm guessing you didn't bother actually reading the channel i suggested you read

ivory bobcat
#

You might want to provide the necessary data like code, what you've tried, what's happening and not happening, etc

wooden socket
#

ahh

#

okay fair

#

okay let me explain

slender nymph
#

please finish a thought before pressing enter again

wooden socket
#

so I have scripts in other scenes that have an animation play when a button is pressed, however, in the actual scene of the game, I have it configured to play the animation when an object collides with another object 10 times

#

lemme send my code

slender nymph
#

!collab 👇

eternal falconBOT
severe sluice
#

my bad bro

ivory bobcat
wooden socket
#

the scene still changes when it collides 10 times though

#

the animation just doesnt plau

ivory bobcat
#

So the coroutines fires and code works?

wooden socket
#

mhm

#

the only problem is the animation

ivory bobcat
#

So this isn't a code question but rather an animation setup problem?

wooden socket
#

seems like it

ivory bobcat
#

Make sure to provide the necessary like animator controller and whatnot

burnt vapor
#

Best thing is a state variable that determines how far it is and to see if it should run from there

#

Consider putting your code in a separate method and then write a check as a guard clause google so it's not in the way of anything else using the Update method

raw sigil
#

Hi! How can I add a collaborator to my unity project on the free plan? (we're both on the free plan and I've watched tuts but nothing actually tells me how?) Sorry if this is the wrong place to ask! I hope it isnt haha I thought it would be the right place since I'm a newbie coder trying to collaborate with another newbie coder

eternal falconBOT
#
Using version control in Unity

Unity Version Control

git Git

Get the latest .gitignore file from here. It should be placed at the root of your Unity project directory.

raw sigil
#

thank youuu I really appreciate it

eternal needle
#

git is also pretty much the best option if you arent so deep into learning unitys vc. Used in every other aspect of computer science as well

serene sedge
#

!bug

eternal falconBOT
#

🪲 To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.

📝 If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click ‘Report a problem on this page’!

💡If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.

For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting

serene sedge
eternal falconBOT
magic panther
#

For the last 5 hours of my life I've been trying to fix this one script from freaking out randomly. I tried so many changes I don't even remember what I was doing, but every FIX resulted in another BREAK. Something is always broken. This is the state at which I noticed the error. Tell me what to fix here, PLEASE. The script is supposed to mark the fragment and any line of brittleWalls and Fragments including it on any axis between two Walls with nothing else inbetween. These would then break, which you can see working in the video above, EXCEPT THIS ONE CIRCUMSTANCE which rips horizontally. I don't know what's causing this shit to freak out this bad, but I'd be eternally thankful if anyone manages to tell me what will fix this function.

It used to be a very clean, short piece of code, but now it's a screen sized mess of useless crap I tried to use as band-aids just to be done with this.

I'll stay here until someone maybe asks a followup, which I'll do my best answering and guiding

Function --> https://gdl.space/izalohejim.cs

#

I don't want to give up on this project because of a little shit like this

#

I suspect it's with the order of checking stuff

#

but I can't think anymore

#

my brain's a soup after all the attempts at fixing this

#

I'd even go in a call and stream all the scripts to test whatever you need but there's no vc here

ivory bobcat
#

I'm not on an appropriate device to be debugging based on videos but I'm assuming the issue is with the last detection where it had destroyed two separate segments from that three piece (4x4).
Although you're able to visually inspect what's wrong, log those pieces and verify why the first portion of your code added them to the list to be marked for destruction. According to the code, hit count was greater than 2, fragment count was greater than 0 and brittle was above 0 - obviously we're in disagreement with what had occurred so we'll need to figure out which of these were wrongfully added.

magic panther
#

btw no need to worry about when this occurs. All marking functions are executed on all pieces, on all fragments, all at once before proceeding with destroying the marked ones

#

also pieces move, not fragments, so it's not like the function was run before the rest moved

#

what do you need to know/confirm from me?

#

we'll try to do this

#

if you want ofc

#

As a last resort I could just rewrite the function from scratch

ivory bobcat
#

I'm assuming this line was true when it wasn't meant to be

if (hitWalls >= 2 && hitFragments.Count > 0 && hitBrittleWalls.Count > 0)```
magic panther
#

unsure how to confirm that

#

obviously it runs

#

as we see

#

but if that was the case, why did it shift over 1 full length

mental aspen
#

Whenever I switch to Android/Windows and create a build I suddenly have changes in these files.
I wonder if I should commit these changes?

#

Oh I also have changes in sln.DotSettings

ivory bobcat
#

You'd first just log the hit fragments and brittle wall elements to see which pieces were found. Then go in reverse and figure out why they were added to the lists.

magic panther
#

tried that

#

genuinely couldn't tell why they got added

ivory bobcat
#

So which pieces were in the lists?

magic panther
#

the ones deleted. The walls above the top fragment and ones below the right fragment, including the fragments

#

So everything that's in the lists, including the fragment executing the marking will be deleted as stated in this area

ivory bobcat
#

So you'd want to validate each of the three expressions:

  • what was the actual number of walls hit?
  • which part of the code added the fragment elements for this specific case?
  • which part of the code added the brittle elements for this specific case?
magic panther
#

we can add a counter that increases every time I add something to the lists

ivory bobcat
#

Just printing the number of hit walls would be a start

magic panther
#

you mean the ones stuff should be between?

ivory bobcat
#

I'd like to know what the hit walls value was before the unwanted behavior

magic panther
#

if it was more than 2 it'd say "between 3 walls"

#

it's logged right here, just before marking everything in both lists including the fragment itself.

ivory bobcat
#

I cannot see the logs from the video but that's good to know - mobile device portrait mode resolution.

magic panther
#

the values are correct. That part works as desired, it's the actual detection messing up

ivory bobcat
#

Now which of the if statements between lines 27 to 75 added the objects?

#

You can probably verify this by adding some unique statement prior to adding to the lists

magic panther
#

At this point I think even if we fix this issue the function will be cluttered as hell. I might as well just rewrite it to save us time.

ivory bobcat
#

Figure out which statements are misfiring.

magic panther
#

tho it's weird it only happens in this exact scenario. For example when I did this (screenshot), it just stayed like that

#

there is some obscure shit happening. I really need to rewrite this

#

Thanks for help anyway mate

#

I think if I think and ponder a bit I'll get it right

#

after this mechanic an even worse one needs to be added

late burrow
#

can i use implicit conversion for predefined classes too?

naive tundra
#

this code crashes unity, and i have no idea why. if someone smart could explain why it crashes, and how would i make it do the thing it's supossed to? (move the platform with the boxcollider2d, platform on the screenshot, and code snippet below)

using System.Collections.Generic;
using UnityEngine;

public class movetheplatform : MonoBehaviour
{
    private BoxCollider2D BoxCollider;
    // Start is called before the first frame update
    void Start()
    {
        BoxCollider = GetComponent<BoxCollider2D>();
        
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Vector3 newPosition = BoxCollider.transform.position;
        if (collision.gameObject.layer == 6)
        {
            while(newPosition.x < 3)
            Invoke("TheMovement", 2);
        }
    }
    private void TheMovement()
    {
        Vector3 newPosition = BoxCollider.transform.position;
        newPosition.x += 0.5f;
        BoxCollider.transform.position = newPosition;
    }
}
#

layer 6 is the layer called "player", and the player gameobject is set to it, the BoxCollider is the box collider 2d of the platform

polar gulch
#

Hi everyone! New to coding and gamedev!

#

Any beginner for C# recommendations would be highly appreciated! 🙂

ivory bobcat
eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

ivory bobcat
#

It's a good means for getting familiar with Unity, how to approach the api and whatnot - you'll not be making cool special stuff but it goes through the basics and will not mislead you (it's the official source to learn from).

naive tundra
#

i LOVE unity learn, rlly a great resource

dusty shell
#

Anyone know how the brawhalle attack system works?

glad pawn
#

second, try renaming the BoxCollider variable to just boxCollider

#

it might be clashing with the class

chrome shadow
#

what did i do wrong? ;-;

cosmic dagger
glad pawn
#

not the class

swift crag
#

you have to read the error

chrome shadow
willow scroll
cosmic dagger
#

move the cursor to read what the error actually says . . .

swift crag
glad pawn
#

and you can't use it in the variable definition

naive tundra
chrome shadow
#

oh

glad pawn
#

it needs to be on start

swift crag
chrome shadow
#

ok

swift crag
#

you can't just see a red squiggle and immediately shut down

glad pawn
willow scroll
# chrome shadow

To do it this way, you have to either make your clip constant, or reference it in the method like Awake, Start, OnEnable etc.
Note that the 1st option does not make any sense.

glad pawn
glad pawn
#

(I believe)

swift crag
#

Unity freezes when that happens

willow scroll
# glad pawn (I believe)

Yeah, if you mean there is no WaitForSeconds in the loop, Unity is just going to execute the code non-stop until it freezes

glad pawn
#

btw, that movement code looks very strange

willow scroll
#

Since Vector2 is a struct, which, unlike a class, is a value-type, the once assigned value on this line is not going to be updated when changing the position of your BoxCollider

Vector3 newPosition = BoxCollider.transform.position;
#

The first thing you're going to do is reference the BoxCollider.transform.position.

#

You can save is as a class Transform, which is a reference-type, but not as a struct Vector3

#

Secondly, this is still going to freeze your Unity for at least 2 seconds until the position is assigned

mild lake
#

Does anyone know why my headers aren't showing up?

 [Header("Positioning")]
 public Vector3 originalPos;
 public Vector3 zoomPos;

 [Header("Stats")]
 [SerializeField] private float fireRate = 0.5f;
 [SerializeField] private int damage;
 private float nextTimeToFire = 0f;

 [Header("Graphics")]
 [SerializeField] private AudioClip shotSound;
 [SerializeField] private GameObject decalPrefab;
 [SerializeField] private Animator _animator;
swift crag
#

Do you have any compile errors?

#

Look at your console. There must be zero errors.

mild lake
#

Nope

cosmic dagger
swift crag
#

also ensure that you've saved the file, yes

mild lake
#

It's saved with no errors

swift crag
#

prove that it's working by adding a new field to the class

#

public int foo;

mild lake
#

Yup, i added a new varible to the weapon and still no headers

#

[SerializeField] private float gluff;

burnt vapor
mild lake
#

Where do i find that?

burnt vapor
#

click the More Items (⋮) button to open the context menu, and select Debug/Normal

wintry quarry
#

show screenshoits

mild lake
wintry quarry
#

or:

  • You didn't save your code
#

Or you're editing the wrong script

mild lake
#

Well because the new varible was added in the inspector, that rules out everything besides a custom editor

burnt vapor
#

Did you check for debug mode yet?

wintry quarry
#

It's definitely not in debug mode

#

we would see instance id

burnt vapor
#

I don't know how much debug mode lists

burnt vapor
#

I know it does remove headers

mild lake
#

Yeah not in dbug

burnt vapor
#

Alright

wintry quarry
#

Seeing a screenshot of your whoole console window would be great

#

for my peace of mind

mild lake
#
    [Header("Positioning")]
    //New varible
    [SerializeField] private float gluff;
    public Vector3 originalPos;
    public Vector3 zoomPos;

    [Header("Stats")]
    [SerializeField] private float fireRate = 0.5f;
    [SerializeField] private int damage;
    private float nextTimeToFire = 0f;

    [Header("Graphics")]
    [SerializeField] private AudioClip shotSound;
    [SerializeField] private GameObject decalPrefab;
    [SerializeField] private Animator _animator;
glad pawn
#

I meant in the screenshot

mild lake
#

Oh i removed it, i'll add it back

glad pawn
#

strange

wintry quarry
#

I see you're using FishNet

#

Maybe FishNet messes with things especially if this is a network component

mild lake
#

What's that quick pastebin people use here? i forgot the name

wintry quarry
#

!code

eternal falconBOT
burnt vapor
#

Just shooting in the dark here, I have no idea why it would not work

mild lake
#

Type or namespace couldn't be found

burnt vapor
#

I would guess it's otherwise somehow a custom editor interfering

swift crag
#

It has a custom editor

#

I remember this coming up before.

wintry quarry
#

Yeah I'm thinking this is a FishNet problem

mild lake
swift crag
#

IIRC it has a custom editor for Component?

wintry quarry
#

big if true

swift crag
wintry quarry
#

oof

mild lake
#

what's this mean?

swift crag
#

FishNet draws a custom editor for every single kind of unity object

#

If it doesn't respect the HeaderAttribute, then headers won't work

#

Perhaps someone should open an issue about it

#

I don't see anything on the github repo

mild lake
#

That's annoying, but sounds like we found the root of the problem

#

I'll ask in their server about it. Thanks!

wintry quarry
#

Yeah your exact code produces this in my project btw

#

so definitely fishnet

magic panther
#

apparently the loop label is wrong.

swift crag
#

pretty sure C#'s break doesn't work like that

magic panther
#

need the full function?

swift crag
#

you have to break out the epic gamer goto to jump to a label

magic panther
#

so break goto rayCheck or something

swift crag
#

no, it'd just be goto rayCheck;

#

but reconsider your design first (:

wintry quarry
#

^ that but the label should be in the place you want to go TO not before the loop

#

but really... avoid goto and labels if at all possible

magic panther
#

so how do I break out of both loops from inside the nested one

wintry quarry
#

can you show the full code in question?

#

the simple answer though is - put whatever you want to break out of in a function, and return; from the function

magic panther
#

!code

eternal falconBOT
magic panther
#

here

#

I need to break out of the loop, not the function

#

the loop is inside a function

wintry quarry
#

of course it is

#

put it inside another smaller function, and return from that

glad pawn
#

out of the second for, check if mishap is true and break

wintry quarry
#

but yeah that's possible too

magic panther
#

one sec

wintry quarry
#

why not just this:

for (int i = 0; i < 2 && !mishap; i++) {```
#

in the outer loop

#

that solves it all, no?

glad pawn
#

like ```csharp
for (...) {
...
for (...) {
...
mishap = true;
break;
}
if (mishap)
break;
}

magic panther
#

not really

wintry quarry
#

why not

magic panther
#

I need both iterations, just a cancel last second

#

there's some code ran after the for

wintry quarry
#

if you always need to iterate twice then you don't want to break out

#

ever

magic panther
#

I'll give it a go

wintry quarry
magic panther
#

so just remove breaks and add the extra condition?

wintry quarry
#

it doesn't affect anything outside the loop

wintry quarry
magic panther
#

but I need the breaks to not run the rest of the loop

wintry quarry
#

that's what break does, yes

#

it ends the loop

magic panther
#

actually a if (mishap) { break } below the first if could just do the job

wintry quarry
#

but really just putting this loop in a function would be so much cleaner

#

and using return;

#

you could even make it a local function and then you don't need to worry about passing local variables as parameters etc..

elder raptor
#

Any idea why this coroutine isn't working?

public IEnumerator StartOccupiedSequence()
{
    float occupiedTime = UnityEngine.Random.Range(minRoomOccupiedTime, maxRoomOccupiedTime + 1);
    Debug.Log("Will Wait for " + occupiedTime + " secs");
    yield return new WaitForSeconds(occupiedTime);
    Debug.Log("Done waiting!");
    SetRoomState(RoomState.NeedsCleaning);
}

I am starting the coroutine in another script like this: StartCoroutine(room.StartOccupiedSequence()); but for some reason, I get the first Debug "Will wait for X Secs" then nothing happens.

swift crag
#

Do you deactivate the game object of the component you started the coroutine from?

#

e.g.

#
StartCoroutine(...);
gameObject.SetActive(false);
cosmic dagger
ivory bobcat
#

Did you destroy the object?

wintry quarry
elder raptor
#

The object that started the Coroutine is destroyed yeah.

wintry quarry
#

then mystery solved

elder raptor
#

Time.timeScale is never 0

swift crag
#

it's gooooone

elder raptor
#

ohh, so it isn't supposed to be destroyed?

swift crag
#

StartCoroutine doesn't mean "run the coroutine out in the aether"

#

it's equivalent to this.StartCoroutine

#

you run the coroutine on a specific MonoBehaviour

wintry quarry
cosmic dagger
elder raptor
#

Ahh makes sense, I can destroy it after the coroutine then. Thanks!

cosmic dagger
#

you can run the coroutine on a separate MonoBehaviour class to avoid that, but may be more than needed for your situation . . .

magic panther
elder raptor
magic panther
#

or anyone

#

over 7 hours and this is still giving me a headache

swift crag
#

I find this very hard to parse.

magic panther
#

there's extra info in the convo below when Dalphat was trying to help

verbal dome
ivory bobcat
#

Put break points where you're adding to the lists and see which are misfiring.

magic panther
#

I'm sick today

#

my bad mate

ivory bobcat
#

It's not going to be a simple "you did this instead of this" solution without debugging.

magic panther
#

I'd also be steered away tbh

magic panther
ivory bobcat
magic panther
#

Problem being I have no damn idea what the edge case could be, both brittlewalls and fragments are treated the same way.

cosmic dagger
magic panther
#

I can try the same level but replace the brittlewalls for fragments

#

just to get the possibility of treating them differently out of my head

#

ok here it didn't work because there needs to be at least one brittlewall and at least one fragment to break

ivory bobcat
magic panther
#

My biggest question is why does it, like, shift to the side??

#

how does that even happen?

#

I think I could add a non-marker bool as a debugging thing and just check it on for the right fragment of the piece causing trouble

stuck palm
#

😭

private void OnEnable()
        {
            Application.logMessageReceived += ShowMessage;
            
            Application.targetFrameRate = 60;
            SendNotification(MessageType.Info, "GameManager Created, Set fps to 60");
#

why does it still say 165 fps

magic panther
#

this is what I meant btw

#

the function will not be run for this fragment

ivory bobcat
magic panther
#

idk what we'll get out of this

cosmic dagger
swift crag
stuck palm
magic panther
#

I disabled the bottom right, changed nothing

ivory bobcat
magic panther
#

turned the nonMarker bool on for the top one and it works as intended now.

#

so something's up with the top fragment

stuck palm
magic panther
#

to the sides it had nothing so the loop fails.

#

holy shit it might be it hold on

ivory bobcat
stuck palm
#

which is why i thought that

#

turns out turning off vsync fixed it lol

#

i can definitely feel the difference now

magic panther
verbal dome
#

Can you explain the problem in a couple of sentences?

cosmic dagger
#

if you change the nonMarker bool does it work?

#

i didn't understand the intent or design or your game, so i couldn't what or where smth was wrong . . .

magic panther
#

I'm trying to implement a mechanic where if 1+ fragments of a piece and 1+ brittle walls (grid things) are in a line which begins with a wall and ends with a wall and has no air and no other elements in it (I checked, the special floors don't break anything) the fragment and brittle walls in that line break, similar to tetris.
Here, as you can see, for some reason, this specific piece just breaks stuff diagonally.
I deleted it and placed a new piece of same exact shape, we'll see how that goes

#

wait

#

you're kidding

cosmic dagger
#

if you push a red piece with horizontal or vertical blocks touching opposite ends of this grid, they are all removed?

magic panther
#

no, because at least one brittle wall needs to be in the line as wall

swift crag
#

This is fully grid-based, correct?

If so, you should throw out the raycasting entirely and just work in grid-space

#

that would simplify your code quite a bit

magic panther
#

anyways, turns out I did everything right from the start and wasted yall time, because this specific block was just built different.

#

I deleted the old one and placed a new one of exact same shape and position

#

now everything works as it should

#

I mean I should get used to stuff this tiny messing up my entire day, happened three times in this project already

swift crag
#

sounds like a weird physics quirk caused by these raycasts on a grid (:

cosmic dagger
glad pawn
#

btw, very cool game!

magic panther
#

once was a misspell by capitalizing a letter on accident, another was assigning the Piece script instead of object to the room

verbal dome
#

Wouldn't it be cleaner to ditch the boxcolliders and raycasts and use a 2D array instead or something

wintry quarry
#

I wouldn't use physics for such a game in the first place

magic panther
#

Yes it's pirely grid based

wintry quarry
wintry quarry
#

2d array

swift crag
#

you can use Unity's Grid component

magic panther
#

so comparisons like this.x == me.x + 1 >> move?

swift crag
#

it converts between world-space and grid-space

wintry quarry
magic panther
#

It sounds like it's too late, but thank god this is just a test demo to see if people like the idea

wintry quarry
#

Very simple for loops etc

magic panther
#

in the actual project I'll ask some more questions on proper code stuff like the grid things.

swift crag
#

Raycasts make sense when you have irregularly shaped objects spaced far apart

#

They do not make sense for very rigid grid-based logic

magic panther
#

I mean I planned some off-grid mechanics, but that just sounds painful to work with so I scrapped the idea

magic panther
#

I don't take credit for it

#

Thanks to you all for the help

#

but now I need to make them split into individual pieces if a cut occurs in the middle of a piece

#

I won't whine like I did today when I mess it up tho

#

cyall

#

cya all

#

however you say that

#

dude

glad pawn
magic panther
#

nav I leave it to them

magic panther
#

is there another bug 🧌

magic panther
#

the given script is inside each fragment and it's called vertically and horizontally (Vector2(0f, 1f) and Vector2(1f, 0f) passed as the lookDir) in a LateUpdate, after everything happens in terms movement and so on. It works literally everywhere except this piece. I tried deleting it and placing a new one, still not working

#

like this it works

tender breach
magic panther
polar acorn
#

See what thing you're hitting and see if it matches any of your conditions

astral falcon
#

Might be a simple question and answer, but have you guys experienced switching a camera from base to overlay and back killing all values that have been there for physical camera for example?

mainCameraData.renderType = spectator ? CameraRenderType.Overlay : CameraRenderType.Base;
polar acorn
tender breach
#

It says Ninja which is supposed to happen when the gameobject tag = other falling 2.

polar acorn
astral falcon
magic panther
# magic panther

Alright I fixed it. I just forgot to add the fragment itself to the list. Again, I appreciate all the help and advice

polar acorn
tender breach
#

Ok

polar acorn
#

Why ask for help if you don't want it?

frosty hound
# tender breach I don't want to

If you're not going to actually do what people ask of you, please stop posting here. You have been a difficult user in the past to attempt to help. Consider this an official warning.

wooden socket
#

i need a bit of help with an animation playing, and th problem is the code. I want it to play when the collisionCount is equal to 10, and when I put it in Start() it plays, but not when the value is 10

#

lemme send my code

#

!code

eternal falconBOT
wooden socket
polar acorn
wooden socket
#

on Start yea, on collisionCount no

polar acorn
stuck palm
#

I have this graphic script that I found, but i've put it on canvas and im not getting the debug logs at the end.

public class UILineRenderer : Graphic
{
    public List<Vector2> Points = new List<Vector2>();
    public float lineThickness = 2f;
    
    protected override void Awake()
    {
        base.Awake();
        material = new Material(Shader.Find("UI/Default"));
    }
    
    protected override void Start()
    {
        base.Start();
        Debug.Log("UILineRenderer Start");
        SetVerticesDirty();
    }

    protected override void OnPopulateMesh(VertexHelper vh)
    {
        vh.Clear();
        Debug.Log("OnPopulateMesh called");
#

the Start one is being called

#

but not OnPopuklateMesyh

polar acorn
wooden socket
#

i know it isnt a problem with the ACTUAL animation

#

bcs it works on other scenes

polar acorn
glad pawn
#

I didn't know that

willow scroll
glad pawn
#

interesting

polar acorn
ivory bobcat
glad pawn
#

no, that's not what I meant

glad pawn
#

it's just I didn't know

willow scroll
#

Either of them or both should have a Rigidbody

glad pawn
#

I only thought both had to have colliders and at least one of them had to be a trigger

polar acorn
polar acorn
willow scroll
#

Both should have their Colliders, and either or both a Rigidbody

polar acorn
ivory bobcat
#

Wasn't there a rule for easy fast and free assets as well?

willow scroll
polar acorn
#

Now I have the reading comprehension shame cone 😔

polar acorn
willow scroll
wooden socket
ivory bobcat
#

Likely it's to do with your animator controller if the logs are printing

wooden socket
#

okay this may sound dumb but

#

if i copy the same controller

#

from another scene into this one, will that help?

willow scroll
#

Not sure with what it should help, haven't followed

wooden socket
#

aaand still didnt work

ivory bobcat
#

Maybe show your animator controller

wooden socket
#

kk

ivory bobcat
carmine sierra
#

any simple ways to prevent randomly spawned enemies from spawning within each other

#

is a placeholder needed to see if they will collide, before placing

wooden socket
frosty hound
#

Though you'll want to set a hard limit so you don't cause an infinite loop in situations where there might not be space. And just either cancel the spawning, or allow spawning wherever in those circumstances.

polar acorn
wooden socket
polar acorn
# wooden socket

Okay, that's all fine. I was suspecting Exit Time might have been enabled but this is all set up correctly.

#

Replace this log:

Debug.Log("Triggering the StartTransition animation.");

With this one, that gives a bit more info:

Debug.Log($"{gameObject.name} is Triggering the StartTransition animation on {transitionAnimator}", this);
wooden socket
#

will do

polar acorn
#

Also, quick sanity check: The birdTransition state does have an animation on it, right?

wooden socket
#

where would I find that

polar acorn
#

You'd click on it

wooden socket
#

like this?

polar acorn
#

No, the animation state

#

in the animator

wooden socket
#

ah

ivory bobcat
wooden socket
#

which node do I click

ivory bobcat
#

The bird transition state

wooden socket
#

OH nvm yea I see

polar acorn
#

Okay so it has a clip, that's good. Just wanted to make sure it wasn't an obvious problem. Back to the log then

wooden socket
#

ok

#

What’s especially weird is that

#

I literally copied tbe components

#

Should I just send screenshots of everything involved?

polar acorn
#

Let's start with just the results of that log

languid spire
ivory bobcat
sullen zealot
#

hello is EventTrigger.OnDrag called multiple times per frame?

polar acorn
# wooden socket

Okay, so, the border object is changing the animation on the transStart object. Can you show the full inspectors of both objects?

wooden socket
#

this is on border

polar acorn
#

Show the full inspectors of the objects, so I can get some context

wooden socket
#

kk

#

lemme see if I can get a full ss

polar acorn
#

That's good enough for border

#

I just needed to see the collision-y stuff since that's what's calling the function.

#

transStart next would be good

wooden socket
polar acorn
#

Okay, everything seems to be on the up-and-up. The only thing I can think is maybe the animation clip itself is incorrect?

wooden socket
#

lemme look into that

#

it would be in border right?

polar acorn
#

The best way would be to just change that state to be the "entry" state and see if it plays when you start the game

wooden socket
#

kk

#

wouldnt putting it in Start() do the same thing? just curious

#

bcs i did that and it played

polar acorn
wooden socket
#

ykw it may be

#

okay no its not what I thought it was

#

i disabled an object that included the script that was redundant and it still didnt change the outcome

ivory bobcat
#

If it works in start but not in the physics callback function then it's likely not being called or something has happened later (outside of start)

#

When playing at the start method, are you firing the same instructions - changing scenes and whatnot

wooden socket
#

in Start() all I did was use StartTransition()

#

wait hold up

#

something changed

#

okay so

#

the image im using to transition is BEHIND the background image

#

yea its behind the image but its in the highest part of the canvas

polar acorn
#

Okay, so it is animating, it's just behind everything?

wooden socket
#

yup

polar acorn
#

Canvases are drawn back to front in hierarchy order. So, transStart is rendered, then scoreText on top of it, and RawImage on top of that

wooden socket
#

OH

#

so its in reverse?

#

okay so it works, but now the transStart isnt on top of everything

polar acorn
#

Picture it as a physical drawing. Once you put something on paper, if you take a crayon to it after, it's going to end up in front of what's already on the paper

wooden socket
#

its just over the background

polar acorn
wooden socket
#

so im putting the canvas at the bottom?

#

of the hiearchy

#

no, right>

polar acorn
#

Where the canvas is in the hierarchy doesn't matter. The hierarchy determines order within the canvas

wooden socket
#

yea ik

#

wait lemme send a ss of what I mean

#

see how the small birds are above the big one?

polar acorn
#

Is the canvas an overlay canvas

wooden socket
#

it was a camera canvas

#

i jusut changed it, and the problem still stands

polar acorn
#

Okay, so, then you'd need to make sure the distance between the camera and the canvas is less than the distance between the camera and the stuff in the game world

wooden socket
#

wait but if I make the canvas overlay, it makes everything huge

polar acorn
wooden socket
#

but then I run the game and the other game objects are hidden

swift crag
wooden socket
#

lemme send a ss

polar acorn
# wooden socket

So, that bigger box is your screen. That's the stuff that is drawn on top of the game. Imagine it like a sticker inside of your computer monitor. It does not matter where it is or how big it is, it will be your screen

#

It's drawn over everything else

wooden socket
#

but then my game objects dont even

#

appear

polar acorn
#

Where are they on the canvas?

#

Or do you mean your non-UI stuff doesn't appear?

#

If it's the latter, that's probably because your canvas is covering them

wooden socket
#

all the way in this bottom corner

#

do I have to manually move them?

polar acorn
#

it literally does not matter where the canvas is

#

it can be anywhere

wooden socket
#

but when I run the game

#

its just the image

polar acorn
#

it's covering everything

wooden socket
#

ykw

polar acorn
#

Overlays are drawn on top of the game

wooden socket
#

oh wait I see

#

so do I have to manually move everything

#

or can I just make the image smaller

polar acorn
#

It does not matter where anything is

#

Your background shouldn't be a canvas

wooden socket
#

its not its an image

polar acorn
#

your canvas should contain UI that is drawn on top of things

wooden socket
#

OH

#

wait then how do I make the background an image

polar acorn
#

You don't. It should probably be either a sprite in world space, or a skybox texture

wooden socket
#

okay so ill make it a skybox texture

#

wait i can just use sorting layers

#

well

#

it works!1

still pond
#

Hey, I have an object in my hierarchy called "ScoreKeeper" and I can't reference to it in my code. For example if i try to declare the "ScoreKeeper scoreKeeper" it says that the type 'ScoreKeeper' can't be found. The object is enabled

raw token
#

In ScoreKeeper scorekeeper, ScoreKeeper is a C# type - it'd be referring to a class you've defined in a script, not a GameObject

still pond
#

And how should I refer to the game object "ScoreKeeper"