#💻┃code-beginner

1 messages · Page 503 of 1

hollow slate
#

okay so, you're changing the camera's rect, and you want objects to scale based on it?

snow warren
#

just the camera view

#

like lets suppose

hollow slate
#

okay, so let's say you set the rect H to 0.5
You still want the camera to take up the entire view?

snow warren
#

i put the width and height of the camera viewport rect as 0.5 and 0.5

#

now whenever the size of the display changes like from 1920x1080 to 1200 x 600

#

i want the rect to change its size to match the change in display

#

much like how UI does it

snow warren
hollow slate
#

so, if I have a 1080p screen, but set the res to 720p, you want the width and height to become smaller?

hollow slate
#

this should be really easy with some simple math no?

Let's presume 1920x1080

we then go to

1200 x 600

Let's presume 0x0 would mean 0 width and 0 height.
Let's also presume 1920x1080 is the max resolution.

We just take
height = 1200 / 1920 = 0.625
width = 600 / 1080 = 0.555...

We then get the ratio of the new resolution.
This should scale it accordingly.

snow warren
#

thanks for help

#

i failed in maths

hollow slate
#

hahah, alrighty. Good luck with your stuff.

snow warren
#

also one more crucial stuff to ask

#

the width reduces itself to the left and the height reduces itself to the bottom

#

so whenever i will reduce the width and height it will be reduced towards the down left corner of the screen

hollow slate
#

you want to centre it?

snow warren
#

is there a way to do it in the centre

snow warren
hollow slate
#

yeah, sure. I messed around with it now and found:

(1 - (multiplier))/2

steep rose
snow warren
#

sadly i failed in maths

hollow slate
hollow slate
#

hahah

steep rose
#

school

snow warren
hollow slate
#

well - doing lots of small math stuff in Unity.

hollow slate
stray zodiac
#

Uhh anybody know the best place to get started with C#?

#

I have unity installed and everything

snow warren
#

tho learning C# in itself is way more easier than C++
but if you wanna learn Unity API then it might take you some time to get there

steep rose
eternal falconBOT
#

:teacher: Unity Learn ↗

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

stray zodiac
#

Ok thanks!

hollow slate
#

you'll also learn that there are many different ways to achieve something, and many tutorials are different in their approach. You'll learn your preferred approach, it's drawbacks and when not to use it.

#

TLDR; if you have something you want to make, start making it.

#

@chilly vigil "right" for what?

#

what's your desired behaviour?

chilly vigil
hollow slate
#

did you write this code?

chilly vigil
#

yeah following an photon battle roayale course

hollow slate
#

okay

#

and is the code doing what you want it to do?

chilly vigil
#

i got 7 errors from it.

steep rose
#

and what were those errors

chilly vigil
# steep rose and what were those errors

"Assets\Scripts\DeathCamera.cs(54,43): error CS0117: 'Transform' does not contain a definition for 'Right'
Assets\Scripts\DeathCamera.cs(54,51): error CS0103: The name 'x' does not exist in the current context
Assets\Scripts\DeathCamera.cs(54,55): error CS0120: An object reference is required for the non-static field, method, or property 'Transform.up'
Assets\Scripts\DeathCamera.cs(54,70): error CS0103: The name 'y' does not exist in the current context
Assets\Scripts\DeathCamera.cs(54,84): error CS0117: 'Transform' does not contain a definition for 'Forward'
Assets\Scripts\DeathCamera.cs(54,104): error CS0117: 'Transform' does not contain a definition for 'Position'
Assets\Scripts\DeathCamera.cs(45,19): warning CS0219: The variable 'Y' is assigned but its value is never used
Assets\Scripts\DeathCamera.cs(54,116): error CS0165: Use of unassigned local variable 'Direction' " these i forget to refine some stuff

steep rose
#

well you are not using X Z or Y, you need to use them and assign them at the top of your script, so your script can actually see it

#

and you capitilized the T in transform

#

you should configure your !ide

eternal falconBOT
shy flame
#

Hey everyone!

I’m having a problem with my Unity3D game. The game view shows up completely white before I click "Play." Also, I can’t set up the UI properly since everything appears white in the editor too.

Does anyone know how to fix this? Thanks!

#

All UI prefabs are white.

short hazel
#

A UI element might be covering the entirety of the viewport here

#

Make sure you positioned them correctly (the Canvas is huge compared to your world objects - 1 unit = 1 pixel)

shy flame
#

All of my UI prefabs are white, but they render correctly only after I click 'Play.

short hazel
#

Disable all objects except the Camera and play. Then, enable them one by one until your view goes white again. The object you just enabled is the one causing it

shy flame
#

Thanks for the help!

queen adder
#

hey! ive got a quick question whats the easiest way to make something change when we increase the float ex. position

#

so when we increase the float the position is changed by 1

polar acorn
queen adder
#

thanks ill check it out

weary egret
#

Quick question for a scrollview - I have a bunch of objects inside a scroll view, and it works with the mask np, but as soon as I add an on click event to the objects, it no longer scrolls. What is the way to allow for interaction with the objects, but with the scrollview still working?

queen adder
wintry quarry
weary egret
wild tartan
#

I NEED HELP when i code on like the text tht sould have collors dont have and its just text

steep rose
eternal falconBOT
steep rose
#

if your ide is not autocompleting or underlining errors, configure it

#

we would need more context but this is what im suggesting from what you are saying

mild hound
#

Guys i need help, i'm making a mobile game but the Drag Controller doesn't work really fine, it does what it's supposed to do (so aiming) but it's ambiguous. Can someone help me solve my problem if i share a clip and the code?

steep rose
#

we would need that to help

mild hound
#

Yes u right but sometimes no one response even if i submit a video and code

#

I send you the vid

wild tartan
#

well this isnt the same as the other one

steep rose
wild tartan
#

wait i think i got it

steep rose
# wild tartan

you didnt say anything about visual scripting and im not sure that link would fix it, it might but have no idea

wild tartan
#

when i instaled i didnt choose the unit stuff

mild hound
#

This is the game, basically what i want the "drag-line" to do, is that: 1. Stay stick in the player view without going out the scene when the player's moving, 2. The movement of the player while aiming doesn't affect the aiming direction of the drag-line

#

I hope i've been claire

#

It's been a while that i'm trying to fix this now i send the PlayerController script

steep rose
#

!code

eternal falconBOT
wild tartan
#

ITS WORKINGGGGGGGGGGGGGGG

#

YESSSSSSSSS

#

NOW I JUST NEED TO WATCH THIS 8H TUTORIAL OF PROGRAM

mild hound
#

@steep rose

hollow slate
mild hound
#

Ok now i try

steep rose
mild hound
#

Vector3 MousePosition { get { Vector3 pos = mainCamera.**ScreenToWorldPoint**(Input.mousePosition); pos.z = 0; return pos; } }

#

I need to change ScreenToWorldPoint?

mild hound
#

With the second point it's more complicate to explain what the problem is, but basically i don't want that the player movement affects the modifiyng of the drag line points position

steep rose
#

from what im seeing in the video, I dont see that happening it looks normal to me

boreal vine
#

what chat to do i go to for unity cloud help? I don't want to accidentally speak in the wrong chat

mild hound
mild hound
hollow slate
steep rose
mild hound
#

OK 👍

void fable
#

this is the link for the code: https://hastebin.com/share/ozorizijeh.csharp so I added the appear and move and disappear thing (picture).. But I think it might have gone wrong there because I tried to change it, but still nothing😭 @hexed terrace

tender stag
#

how can i make Time.timeScale = 0; run instantly

#

cause it runs after the next frame

polar acorn
#

It does run instantly. Time.deltaTime has already been computed

tender stag
#

alright bun this

#

my pause menu isnt gonna freeze the time

eternal needle
#

Could you not just check if the timescale is 0 in that coroutine?

#

And use WaitUntil

tender stag
#

its fine

#

it matches the game style

#

not freezing it

patent imp
#

!lean

#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

tender stag
#

my problem is that when my inventory is open and i press escape

#

it closes the inventory and opens the pause menu straight away

#

the CloseInventory sets the isOpen = false;

#

how do i make it so that the menu doesnt open straight away?

#

that would be the script execution order right?

#

u can see at the end when i have my inventory open and press escape to close it

#

the pause menu opens straight after closing the inventory

#

i guess the pause menu script runs after the inventory manager

nocturne kayak
#

Is there a way to get which object triggered a function through an event wrapper?

slender sinew
bold plover
#

Sometimes you just need to go back to an older version and rebuild what you were trying to do. Still I'm a bit frustrated coming back to a project and still somehow struggling with a state machine. This being despite a lot of research on getting it to work.

#

Like I'm wondering if I just build it from scratch? The state machine itself hasn't been the problem but rather implementing it with the player script I have.

#

No questions for now mostly just blabbing.

slender sinew
#

rebuilding features from scratch is a large part of learning quickly

prime cobalt
#

Can you make gravity go around a certain point? Like a ring but while walking around the edge you're pulled down by the same amount.

wintry quarry
wintry quarry
polar acorn
tender stag
#

i switched from GetAxisRaw to having each key for different direction

#

the GetAxisRaw was canceling the input if both keys were pressed

worldly mural
#

Does anyone know why "Pluto_Hit" isn't transitioning back to "Pluto_Idle" immediately after finishing? It doesn't play through the animation either it just continuously replays it as long as the bool "IsHit" is active and I don't know how to change that since making it false would immediately set it to "Pluto_Idle"

tender stag
#

for example if u were walking left and right
it would be 0
but with how i did it it doesnt do that, any way to make it cancel each other out?

frozen plaza
#

hey guys!

can someone tell me why my vehicle seemingly casts an enormous round shadow? and why its topside is not lit?

#

even a cube is casting this shadow

verbal dome
#

Hard to tell what's going on from these screenshots

tender stag
#

i mean it works

#

but im not sure this is the most efficient way of doing this

slender sinew
#
y = 0f;
if (upPressed)
  y += 1f;
if (downPressed)
  y -= 1f;
#

if both are pressed, they will cancel out

tender stag
#

alright

#

when my inventory is open, and i press escape it closes the inventory and immediately opens the pause menu

Inventory.cs if(Input.GetKeyDown(KeyCode.Escape) && isOpen) { isOpen = false; }
Menu.cs if(Input.GetKeyDown(KeyCode.Escape) && !Inventory.Instance.isOpen) { gamePaused = true }

#

is that because of the order of execution?

#

the menu script running after inventory

tender stag
#

its not the same script

#

its two different

spare mountain
#

then put it in the same script

tender stag
tender stag
#

that doesnt make any sense

#

its already over 800 lines

#

jumbling more shit together will fix it but complicate everything further

tender stag
# tender stag

in the video u can see i had my inventory open and then pressed escape

#

and it closed the inventory and opened the pause menu straight away

#

which isnt what i want

spare mountain
#

not the whole menu logic

slender sinew
tender stag
#

some people told me the order of execution should be the last thing to do

slender sinew
#

you can if you want, the pause menu would need to run first

slender sinew
#

yeah generally people don't like it because it's not obvious

spare mountain
tender stag
#

im not mixing these two

#

its gonna get too confusing later on

slender sinew
# tender stag some people told me the order of execution should be the last thing to do

you should probably instead make a new script that manages the opening and closing of GUI, or create a system for handling how your inputs are received. For example, Unity does something for their GUI where they "consume" events. So, you could do something similar and have an "escape pressed" boolean somewhere in a script that gets set to true when you press escape, then when the inventory closing checks that boolean and decides to close, it would "consume" the event and set the boolean to false so that the pause menu can't use it

tender stag
# tender stag

and this is old code dont ask why im checking else if(isOpen)

#

cause it doesnt make sense lmao

spare mountain
# tender stag

no I'm saying set isOpen and gamePaused in the same script

tender stag
#

i just slapped it there

#

in the long run i will probably look into it

#

making a seperate script to handle it

#

but for now it works

queen adder
#

How do i learn things? Im gettting to a point where I dont know what I dont know how do I learn things? Also whats the best way to refrence a component on a prefab in a script on the same prefab

steep rose
#

whats hard about learning?

teal viper
steep rose
#

i mean getcomponent can do that but i wouldnt for something as simple as such

steep rose
#

does anything like Toint exist in C#? im making another variable for vector3.distance every time i want to convert it's float to an int, unless thats the only way

wintry quarry
steep rose
wintry quarry
#

A* doesn't require conversion to int.

I assume you mean for the heuristic function?

#

The heuristic score can be a float

steep rose
#

oh it can?

#

i guess i dont need to then

wintry quarry
#

But are you sure you want to use the "as the crow flies" distance for a*?

#

You should probably be using Manhattan distance

#

Depending on how your thing moves

#

If it can't move diagonally, you want Manhattan distance

hot lantern
#

Anyone knows why GetMouseButtonDown(1) wont work when i press right click? When i try it with (0) it does with the left one

steep rose
#

its in 3d which is a little harder

wintry quarry
#

And you should be using a Vector2Int for the coordinates anyway

wintry quarry
#

Just use Vector3Int coordinates

steep rose
#

i would use manhattan distance but i dont currently have a procedural grid 😅

wintry quarry
#

And 3D Manhattan distance

steep rose
#

im currently using placed points

#

which sucks

wintry quarry
#

Is it grid based or not

steep rose
#

yes

wintry quarry
#

So then you have a grid

#

And should be using grid coordinates

#

As for conversion to/from world space position, use Unity's built in Grid component

#

It has everything you need

hot lantern
wintry quarry
#

1 is right click

swift elbow
wintry quarry
# hot lantern void OnMouseDown()

You could use IPointerDownHandler. It includes the mouse button that was used in the parameter instead of doing extra update checks

steep rose
#

instead of just measuring distance using vector3.distance

wintry quarry
#

You get the distance between two grid coordinates using Manhattan distance

#

Taxicab geometry or Manhattan geometry is geometry where the familiar Euclidean distance is ignored, and the distance between two points is instead defined to be the sum of the absolute differences of their respective Cartesian coordinates, a distance function (or metric) called the taxicab distance, Manhattan distance, or city block distance. T...

queen adder
steep rose
#

depends on what you need to learn, imo it looks like you are burnt out

#

been there done that

queen adder
steep rose
queen adder
queen adder
steep rose
teal viper
steep rose
#

to help people

queen adder
steep rose
#

i wouldnt say your relying on us, what i would say is you gaining more knowledge and wisdom for coding than you would by yourself

#

this is exactly why teachers exist, to teach others so they can be comfortable and know the current subject

#

and so that their students can pass on that wisdom to others, and so on and so fourth

faint osprey
#
            {
                /*foreach (Scene S in destroyQueue)
                {
                    SceneManager.UnloadSceneAsync(S);
                }
                destroyQueue.Clear();*/
                SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(player.GetComponent<CharacterMovement>().currentScene - 1));
                GH.Solidify();
            }```

ignore the commented code but im using this function to unload loaded scenes however when i get to the 2nd scene and unload the first one it works good but then when i get to the 3rd scene and try to unload the 2nd it doesnt work because it tries to unload scene 1 and not scene 0 however in my build manager that scene is set at scene 1 so I dont really understand why that wouldnt work
teal viper
faint osprey
#

so unless it works as the number relative to how many scenes are actually loaded

#

but i feel like it shouldnt

faint osprey
#

so then whats the point of the number in build profile

#

public static AsyncOperation UnloadSceneAsync(int sceneBuildIndex);

#

yeah look this says it shod be

#

oh wait

#

its cause im using get scene at

#

isnt it

teal viper
#

Yes

waxen adder
#

I want to make a helper class. It would contain data structures and functions I find myself using a lot in the project. However, these data structures and functions use some of Unity's own data structures and functions that come from monobehaviour. If I make the class extend monobehaviour, don't I need this helper class be a component on a game object in order for it to do anything? I'd rather not have it like that. I'd rather it act more more like how a public static class that doesn't extend monobehaviour acts, in that you don't need it to be a component on anything. Any ideas?

eternal needle
rich adder
#

you have many functions in unity that are static, they can be used outside of MBs

#

as long as they are kept on the main thread

waxen adder
eternal needle
#

start and update are functions called on your components by unity. they arent a c# feature

rich adder
loud python
loud python
eternal needle
waxen adder
#

I made a custom grid, however I want the grid to automatically be created/updated in a similar vein as the built in unity grid. So, in other words, as values are changed, I want to create the grid and draw the gizmos needed to represent the grid, all in editor. Do I use OnValidate for that or something else?

languid lake
#
{
    comboNum = 1;
    
} else
{
    comboNum++;
    comboResetTime = Time.deltaTime + 2.5f / 3f;
}``` 

Hey I wrote this code for a combo system for pretty much if too much time has passed itll reset the combo number back to 1 or if its at 5 hit already but im actually really confused on how it works if smb can explain in like simple terms 😭
polar acorn
# languid lake ```if (Time.time - comboResetTime > nextAttackTime || comboNum == 5 ) { comb...

Code runs top to bottom, one line at a time. An if statement checks if the thing inside of it evaluates to true. If it does, it runs the code inside the condition. Otherwise, it runs the code inside the else condition.

|| means OR. It will return true if either side is true. So, if Time.time - comboResetTime > nextAttackTime, or if comboNum is 5, it will set comboNum to 1. Otherwise, it'll add one to comboNum and set comboResetTime to a new value. Time.deltaTime is the amount of time in seconds since the last frame ran (it is basically "Seconds per frame"), plus the constant 2.5 / 3 (which is roughly 0.8333.

languid lake
polar acorn
kind heron
#

hello guys im doing roll a ball tutorial rn to familarize myself with unity. im on the part where you add the enemy to chase player using nav mesh but for some reason, the enemy player just circles around the player and has some irregular movement, and only moves when the player moves

languid lake
polar acorn
#

Nothing here changes nextAttackTime, and there's no information as to what that is

#

so that's all I can say about it

ivory bobcat
#

You probably want to check the elapsed time instead cs var current = Time.time - previous; if (current > reset) { ... previous = Time.time; }

languid lake
languid lake
polar acorn
languid lake
polar acorn
#

Time.time, comboResetTime, and nextAttackTime

ivory bobcat
#

comboResetTime = Time.deltaTime + 2.5f / 3f doesn't feel right as it's some tiny delta whereas Time.time would be the total play time thereon and subtracting it by the reset time would just yield an infinitely growing value.

languid lake
# polar acorn Try logging all of the relevant values

Alright so I figured it out after logging their was code later in the function that was for something else that added the delay that made nextAttackTime == time.time but + 1 pretty much so everytime it checked it made sure you waited 1 extra second before resetting the comboNum = 1

languid lake
near wadi
#

I'd throw in a few more Debugs, like an Awake Done to make sure that Awake is not finishing. It Should be finishing before the other stages (unless i got my order confused) -- Oh, i see what you are saying now.. Ok, i will leave it to those who know more than me

carmine lagoon
#

may I ask, since im planning to make an array that lists all the detected viruses. I am planning to make a sorter for the tower that makes them choose between the viruses, like the one with the lowest health, the nearest, the one with the highest health and the furthest away.

#

since this only list one virus/enemy, it's not really efficient as a player to only target one virus

near wadi
#

Which version of the engine are you on?

#

shoot. so not some odd 6 bug.

#

Why don't you share your code again here, so others can see. (this is beyond my understanding as to why)

#

Cool., that should be enough for someone who understands it to help

nocturne kayak
#

Hey

#

Anyone knows how do i get a variable value from script A to script B through an event?

#
    public static event Action<string> OnAxisClicked;
    // Start is called before the first frame update
    public string gameObjectName;
    private void Awake()
    {
        gameObjectName = gameObject.name;
    }


    public void SelectAxis()
    {
        OnAxisClicked?.Invoke(gameObjectName);
    }
}

^ i have this code on what i want to trigger the event

#

    private void Awake()
    {
        PositionAxisHandle.OnAxisClicked += SelectAxis();
    }

    private void SelectAxis()
    {
        Debug.Log("CLICKED THIS BULLSHIT:" + gameObjectNameShouldGoHere);
    }
}
#

and this on the object i want to print the name from

#

but i don't know how i'd go about sending gameObjectName from the first script to the second

ivory bobcat
#
    private void SelectAxis(string gameObjectNameShouldGoHere)
    {
        Debug.Log("CLICKED THIS BULLSHIT:" + gameObjectNameShouldGoHere);
    }```
nocturne kayak
#

That works

#

Just so i understand

#

That mean that when i call a method through an event

#

That method's arguments are going to be automatically taken from the event dispatcher?

#

What if i have, let's say, one string argument and one int argument on the event but the function i'm trying to trigger only takes a string argument?

ivory bobcat
#

Your action expects a function with a parameter of type string event Action<string> OnAxisClicked thus your function should have a parameter of type string void SelectAxis(string gameObjectNameShouldGoHere)

nocturne kayak
#

That definetly works

#

As in, wrapping my head around the concept

nocturne kayak
#

While on the topic of events,

#

Is there an event listener of some kind?

#

Let's say i wanna figure out what's triggering and being triggered from a specific script

#

is there a way to do that besides going through god knows how many scripts?

ivory bobcat
#

Events are pretty nasty when it come to debugging tbh

teal viper
nocturne kayak
#

well

#

it's meta's code so

#

I'm not entirely sure where to begin

teal viper
#

At least the relevant one to your issue.

wanton iron
#

guys, someone worked with unity photon?

#

photon pun*

#

just..i need help

kind heron
nova wagon
#

hey, sorry im quite new to unity so...
i downloaded Assets from the unity Store but when the show up in my Projekt they are just pink

swift elbow
nova wagon
#

sorry my bad

full coral
#

Is there a way for the game to differentiate a tap and a hold on the ui canvas? I am using 2022.3.37 and i was thinking abot checking duration to do it but its not working in this version. Is there an easier way I overlooked?

teal viper
full coral
teal viper
full coral
teal viper
#

The logic of the tap vs hold is up to you.

full coral
teal viper
#

*Method btw. In C# it's it's methods, not functions.

frozen plaza
#

is my x positive on the right or the left here?

#

the right is X+, no? it's odd.. in blender I have the arrow point to X+ but in unity it's inverted appearently?

frozen plaza
#

and also, I'm absolutely freaking out with the controls in this.. when I hold RMB to fly around the scene, the X control is inverted but Y is not.. can I change this? I always look the wrong direction, it's frying my brain

sterile sable
#

someone has a project that when you click a button it will play an ad?

sonic igloo
frozen plaza
sonic igloo
#

np!

frozen plaza
#

I have another question: out of curiosity I wanted to look at visual scripting and now it's giving me errors and I think I enabled something I don't really need. can I completely turn that off?

languid spire
frozen plaza
sonic igloo
languid spire
frozen plaza
#

thanks to both of you though, I removed it

frozen plaza
#

Debug.DrawRay(ray.origin, ray.direction * 100, Color.red);
why can't I see this one?

sonic igloo
sterile sable
#

every time i try to make this project it show me this error Assets\NewBehaviourScript.cs(5,106): error CS0535: 'NewBehaviourScript' does not implement interface member 'IUnityAdsShowListener.OnUnityAdsShowClick(string)'

sonic igloo
frozen plaza
sonic igloo
#

it should work in both modes, as long as the gizmos view is enabled

frozen plaza
#

ah, it's a different button when play is active, now I see it, thanks!

sonic igloo
frozen plaza
#

right, thanks

#

I appreciate the help

sonic igloo
#

👍

sterile slate
#

hi! could anyone tell me what Debug.log() is used for?

languid spire
sterile slate
#

oh ok and could you tell me what the following errors mean?

burnt vapor
eternal falconBOT
burnt vapor
#

Your syntax is wrong, that's all that can be said

languid spire
#

those mean you have syntax errors in your code. your ide should be highlighting them if not configure it using !ide

eternal falconBOT
sterile slate
#

i know but every tutorial has a different looking visual studio

languid spire
formal sable
#

Hey guys! What's going on?

Where can I ask about textures for materials?

sonic igloo
sterile sable
#

I am trying to make a simple unity ads project and i keep getting this error Assets\AdManager.cs(5,41): error CS0246: The type or namespace name 'IUnityAdsListener' could not be found (are you missing a using directive or an assembly reference?)

formal sable
languid spire
cunning locust
#

how to compile c# code in vsc ?

rocky canyon
#

like to compile and run standalone c#?

cunning locust
#

yeah

#

I figured it out tho, had to install .net SDK

carmine lagoon
#

@rocky canyon are you free?

#

I have a question

burnt vapor
carmine lagoon
#

can I make the target an array instead of a single value and the turrets to have a sorter to differentiate which target to shoot first

rocky canyon
#

you can do anything u can imagine

rocky canyon
#

using for loops to loop thru and do comparisons or w/e

carmine lagoon
#

You guys watch me take three days to read the documentation and come back here asking again HAHAHAHAHAHA

#

anyways thanks guys

burnt vapor
amber nimbus
#

Hello, currently working on an inventory system for my game. The approach I am thinking about going for is having an object the item data of a some container (for example a chest) aswell as the size of the inventory grid. What I am not sure is how to go about generating the actual UI. As I heard that working with UI is pretty slow. My idea was to generate the grid and the items inside the container whenever the player opened the chest. But I was also thinking if I should rather make a prefab for the UI that is just spawned and then the items are added. (this would mean I dont have to generate the grid each time I open the container)

rocky canyon
#

then when u instantiate ur actual object.. use its data (via a scriptable object or however u decide) and populate those variables

carmine lagoon
#

since I'm planning to use this same block of codes, how can I apply it to instantiated game objects?

rocky canyon
#
    public void SpawnAlpha()
    {
        currentTank = Instantiate(typeAlpha[Random.Range(0, typeAlpha.Length)], transform.position, Quaternion.identity).GetComponent<Tank>();

        DoSomethingToPrefab(currentTank); // <-- like here
    }

    void DoSomethingToPrefab(Tank tankToUse)
    {
        tankToUse.DoSomething();
    }```
#

unless im confusing what ur trying to do

#

which i probably am.. as i dont have much details to go off of (haven't been following the conversation)

#

i mean whats wrong with this?

carmine lagoon
#

Where can I share my screen lol

rocky canyon
#

not in this server unfortunately..

carmine lagoon
#

oof

rocky canyon
#

record a video short

carmine lagoon
#

okay i'll try

rocky canyon
#

ShareX

#

i use that program to make nice little filesizes

fervent abyss
full coral
#

idk one of my programmers said that the duration method of differentiating is iffy in the unity version

steep rose
#

nvm

#

that works

remote steppe
#

Amigos

#

Haven't unityied in like a year until recently out of being forced. (School) only unreal. Question regarding unity asset creation. In unreal for "prefabs" I can make my c++ class (essentially game object class or component), and then create BP (prefab) from class, which automatically sets up all the components of the prefab, etc to expedite the creation. What I've seen so far is in unity you don't use constructors, have to make a game object in world, set it up manually, and then create prefab. Is that true?

#

Tldr lol

frosty hound
#

That's the typical workflow, yep

remote steppe
#

Unfortunate

#

Manual labor

frosty hound
#

I'm not sure it's faster not to be able to visually see what you're setting up before creating a prefab. 🤷‍♂️

remote steppe
#

Let code do it for me.

steep rose
#

you can add components using code but thats more labor then just setting it up

#

i see no issue with setting it up manually

frosty hound
#

What's your actual usecase in Unity?

remote steppe
#

Oh it was just for setting up objects. Was curious of workflow. Like I said. Unreal I do this

#

So before I even get in client everything is setup lol

frosty hound
#

Right, I suppose that's one way to do it

remote steppe
#

And can adjust base class

#

Does none of unity use constructors? Or just monobehaviors

#

Well.. I guess mono is main world object lmak

frosty hound
#

Monobehaviours don't use constructors no. Only plain C# scripts.

remote steppe
#

Ahh

#

Okay so tldr is, unity is setup object manually.

#

Minus script that can add vars/affect components

frosty hound
#

Unless you want to do it all at runtime, but then you lose the benefit of actually visualizing your work / quick tweaking in editor.

remote steppe
#

Which still needs script machine manually added

#

Ah so that just creates it in world?

#

Not actual prefab asset

frosty hound
#

Yep

#

If you want to create a class that creates an object, dresses it up and initializes it, kind of what you're doing in your Unreal example.

#

But that's going to not be any faster, that's for sure.

remote steppe
#

Tyvm

#

My hero for quick answer

blazing crater
#

can anyone help me fix my code?

short hazel
eternal falconBOT
blazing crater
#

Ok Im trying to make it so when you click left mouse button your ability will shoot the way your facing. Then go on cooldown for how ever much attack speed is, which at base is 3. I got everything working except cooldown How do i fix it!

short hazel
#

When you shoot, record the time with Time.time and add your cooldown seconds, into a variable. Then add a condition to that outer if statement that checks that Time.time > _timeAfterCooldown

steep rose
#

or you can invoke a function or use a coroutine

blazing crater
#

ok so how could i do that. give an example.

blazing crater
steep rose
short hazel
#

_timeAfterCooldown = Time.time;

#

Field needs to be declared in your class

blazing crater
short hazel
#

Coroutines are more complex and would require a bunch of changes in your current code

#

Adding a variable and a condition is better in your context

blazing crater
#

where would I put the cooldown time?

#

where WaitForSeconds is?

short hazel
#

As soon as you shoot, so in there yes

#

new WaitForSeconds() does nothing if not in a coroutine

blazing crater
#

ok

steep rose
blazing crater
#

so i would do Time.time = attackspeed?

steep rose
#

and or use them

short hazel
short hazel
#

You cannot assign a value to Time.time, it's read-only. It gives you the time in seconds since the game started

blazing crater
#

so I make a float. like, publice float timeaftercooldown = 3f; ?

short hazel
#

Yes but you don't store 3 in it. That field represents the time at which you'll be able to shoot again

#

Put the actual cooldown delay in another variable

blazing crater
#

can you give an example?

#

Im sorry if im annoying you Im new to C#.

short hazel
#
private float _timeAfterCooldown;
public float _cooldown; // set to 3 in the Inspector
blazing crater
#

ok.

#

done now what?

#

I added the floats and the time.time

short hazel
#

When you shoot put the result of Time.time + _cooldown inside _timeAfterCooldown

blazing crater
#

like this? _timeaftercd = Time.time + _cooldown;

short hazel
#

Correct

blazing crater
#

and it should work?

short hazel
#

Not until you add the part in the if statement that actually compares the variable with Time.time again, to check whether time has moved on enough for it to be greater than your variable

blazing crater
#

well how would i do that?

short hazel
#

I told you, in text form

#

Translate to code

#

You can combine two conditions in the if statement with && to make the if statement run only if both conditions are truthy

weak cedar
#

Which one is a better idea: changing the sprite of an image or having image childrens and setting them active/inactive? (For only 2 sprites, therefore only 2 children)

blazing crater
#

I would put the conditions at the end of the shoot

short hazel
#

No in the if at the top

blazing crater
#

which one?

short hazel
#

"If I left click AND that time has advanced enough for me to shoot"

short hazel
blazing crater
#

so like this?

short hazel
#

The script can be made more versatile by using an array instead of multiple fields

short hazel
blazing crater
short hazel
#

if (... && Time.time > _timeAftercd)

blazing crater
#

Its saying error

short hazel
#

Post said error

steep rose
blazing crater
#

it has error lines on the dots and &&

short hazel
#

You're taking things way too literally lol

#

The dots mean "the left mouse input detection that was there before"

blazing crater
frozen plaza
#

when modeling something for unity in blender, how do I work this x/y/z thing?
should I model it so that X is the front of my tank for example?

then how do I export/import it so that it fits in unity?

blazing crater
#

It works!

short hazel
frozen plaza
#

where should I ask and what do I set in the export setting exactly?

short hazel
blazing crater
#

on that same code.. I have it so the abilty clones the game object that is the ablity. but I want them to despawn after 3 seconds. how could I do that?

wind raptor
#

Is there a way to access an event parameter within the AddListener function?

    int MyInt;
    UnityEvent MyEvent;

    MyEvent.AddListener(delegate { MyInt = [intValueHere?]; });
short hazel
blazing crater
short hazel
#

You'll be able to set the integer you want to pass from the Inspector.

#

Or, when invoking it from code!

short hazel
#

You also need the object to destroy in a variable (denoted by the obj here)

blazing crater
#

yea i did

short hazel
#

Do not give it skillg! It's the original. Get the clone from Instantiate:

GameObject clone = Instantiate(skillg, ...);
#

Instantiate returns the object it just created

blazing crater
#

ok

sterile sable
#

Hi i am trying to make a simple unity ads project and i keep getting this error Assets\AdManager.cs(5,41): error CS0246: The type or namespace name 'IUnityAdsListener' could not be found (are you missing a using directive or an assembly reference?)

short hazel
#

Have you imported the package and added the required using directives at the top?

rich adder
sterile sable
#

i dont know

short hazel
#

Head to the Package Manager to find out!

sterile sable
#

what now?

short hazel
#

Ensure that the ads package is installed

blazing crater
#

is it ok if i send a video of what is happening?

sterile sable
#

i have Advertisement Legacy installd

blazing crater
#

The gameobject got destroyed but it was still there.

#

Im so confused

short hazel
#

Legacy denotes an older package that's probably deprecated

sterile sable
#

where i can find the Advertisement package?

short hazel
#

In the Package Manager

sterile sable
#

i dont see it

short hazel
#

If it's not listed, click the "In Project" dropdown at the top and switch to the "Repository" section

sterile sable
#

i dont have it

short hazel
#

Unity Registry

#

Trying things out won't break anything!

sterile sable
#

i still dont find the Advertisement

short hazel
#

Which Unity version are you on?

sterile sable
#

2022.3.11f1

short hazel
#

That might be why. Keep the legacy one and make sure you have using UnityEngine.Advertisements; at the top of the script you need to import the ads stuff

sterile sable
#

i have using UnityEngine.Advertisements; in my script

blazing crater
#

How do I fix this issue now?

#

The code

hexed terrace
#

What issue?

blazing crater
#

when the code clones when I click the sprite is not there. It enabled and on the clonede object

hexed terrace
#

it's Z pos is a minus, it's probably behind everything. Don't give it a minus Z pos.

blazing crater
#

how?

terse plume
#

unity doesn't have a global Y kill plane, right? I must check the Y of the object during Update? 🤔

hexed terrace
# blazing crater how?

What is skill1g.transform.position .. as that is where it's getting the position from. Either change that position in the inspector, or set the Z pos to 0 in code before instantiation

blazing crater
#

ok

blazing crater
sterile sable
hexed terrace
short hazel
sterile sable
#

OK

blazing crater
#

It will not work i tried moving the object, and tried clone.transform.position.z = -1; but it does not work what do i do

sterile sable
#

could someone help me?

full coral
polar acorn
#

If you're just relaying someone's question, maybe they should come ask it so they can actually provide context

polar acorn
oak kelp
#

when i use Debug.Log it doesnt log anything to the console is there away to fix this?

polar acorn
oak kelp
polar acorn
#

If you want the code to run it does need to exist

oak kelp
#

i have it made just nothing pops up in the console

polar acorn
#

What function is the log in

oak kelp
#
 // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("Jump");
        }
    }
}
polar acorn
river garnet
#

Hi, really need help with my project. Im trying to get an objec to collide with the ground but when trying to add a "Ground" layer to my platforms, I am given an empty window. I cannot add a layer

oak kelp
polar acorn
oak kelp
polar acorn
# river garnet

Something's gone wrong with the internal editor code.

First step, try window -> reset layout. If that doesn't work, restart unity. If that doesn't work, close unity, delete your Library folder and re-open. If that doesn'twork, reinstall this version of Unity.

polar acorn
# oak kelp

Show the inspector of the Player component on this object

river garnet
#

Ill try deleting the library folder

idle burrow
# river garnet

You don't seem to have instantiated the Player object within the code that is responsible for collision

oak kelp
polar acorn
river garnet
idle burrow
#

That or you're just referencing the object oddly

river garnet
polar acorn
polar acorn
#

It's some sort of editor corruption if the library clear didn't fix it. Might need to reinstall

river garnet
#

It gives me that error every time I try to add a layer

river garnet
#

My object moves, it just falls right through my platform since I havent added a grounded layer which I cant do

idle burrow
#

The compiler is not happy with what you wrote

polar acorn
eternal falconBOT
river garnet
#

Do you want me to show you my code?

polar acorn
polar acorn
#
  1. It's not a compile error
  2. It's not in any of the code they wrote, it's in Unity's rendering script
river garnet
#

My code runs fine for the record - as I said, it falls through my platforms as I cant add a ground layer. I have no compiler issues

oak kelp
# polar acorn Show the full !code of the player script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("Jump");
        }
    }
}

polar acorn
polar acorn
river garnet
#

Im just adding basic player movement

#

The only thing that is wrong to my knowledge is just letting me add a ground layer

#

I just get an empty window

polar acorn
#

Yeah, runtime code wouldn't affect the rendering of any editor windows. Unless you've written editor scripts that override this function, or have a plugin/asset that does, it's probably a corrupt install

river garnet
#

Hmm okay, Ive restarted, deleted the library folder, and reset my windows

#

I suppose all thats left is reinstalling unity?

polar acorn
#

If you don't want to reinstall yet, make a new project with nothing in it and see if you can add a layer there

river garnet
#

Sure ill give that a shot

polar acorn
#

If it's working there, then you might have a plugin or asset causing problems

#

if it's still broken, reinstall would probably be the fix

river garnet
#

I havent imported any assets or plugins. Ive only used built in functions and 2d objects like squares

#

Yes it works on another plugin

#

very strange

oak kelp
idle burrow
river garnet
#

Another project, I meant

idle burrow
#

This is the important bit

river garnet
#

It worked on another unity project

polar acorn
river garnet
#

Adding a layer, I mean

lofty sequoia
#

what algorithm does the Unity auto sprite slicer use?

polar acorn
#

Unless they wrote that GetMaxRenderingLayersFromSettings function in the UnityEditor.Rendering.RenderPipelineEditorUtility, this has nothing to do with their code

idle burrow
#

A null reference does not come from a corrupt unity install

polar acorn
#

and it does

#

when it is in Unity's code

river garnet
#

It just worked on another project in the same unity install, so I dont think my install is corrupt

#

Somethings wrong with this specific project

#

I have no idea what

quaint wadi
#

Does anyone know how to fix tools window not pooping up when i add my editor script 😭
I've used this before multiple times and now it just doesn't pop up

polar acorn
idle burrow
#

or configs

river garnet
#

I dont know what that means to be honest, how do I find out?

#

pretty new to this

polar acorn
river garnet
#

That error only shows up when I click the "Add Layer" button for the record

polar acorn
polar acorn
#

but it really isn't. The error is unambiguously clear about that.

idle burrow
river garnet
polar acorn
#

Show the !code where you're defining the toolbar and the function to run

eternal falconBOT
river garnet
river garnet
#

As in? my template?

#

Im not sure what URP or built-in is

polar acorn
#

If it's URP, maybe you need to update the render pipeline package, or remove and re-add it

polar acorn
idle burrow
river garnet
#

Hmm I see, this one is 2D Universal I believe

#

Not Built-in render pipeline

polar acorn
river garnet
#

Yes that one

#

Unfamiliar with the terms, sorry

polar acorn
#

Window -> Packages, find your URP package, and update it if it has one, otherwise remove and reinstall it

river garnet
#

Where do I find the package?

polar acorn
river garnet
#

Im using Unity 6

polar acorn
# river garnet

Check under "In Project", find something with a name along the line of "rendering" or "universal"

river garnet
#

Theres nothing under Update, and under In Project I just have Multiplayer Center and 2D Sprite

#

I found Universal RP under Unity Registry, should I install that?

rich adder
polar acorn
river garnet
#

Beats me

#

as to why

#

I assume I should probably install it then

polar acorn
#

I haven't actually installed Unity 6 yet, but I'd assume the template named "Universal" came with URP

#

Give it a shot, if things break you can always remove it

river garnet
#

Sure thing

#

Im not sure how to remove it but ill cross that bridge when I come to it

#

Yup that did it

polar acorn
river garnet
#

How strange. I wouldve assumed that would come preinstalled with the template

polar acorn
river garnet
#

Yes, im able to add a layer now

#

Thank you very much

#

Confused how that wasnt already there, but nevertheless glad its fixed

polar acorn
#

Okay cool.

Gonna chalk that up to pre release quirks

river garnet
#

Most likely

rich adder
polar acorn
#

Yeah. Seems like a kind of important package to have in the template

river garnet
#

Not sure what BIRP stands for, but Im 99% sure I clicked the "2D Universal" template

rich adder
#

BuiltInRendererPipeline

river garnet
#

Ah, no, I didnt use that one

rich adder
#

but yeah if you clicked Universal must be something they def need to fix lol

river garnet
#

I think it may be a release issue, I definitely used 2d universal

rich adder
#

yeah might be that specific version of the template maybe

river garnet
#

My PC still falls through my platforms unfortunately.. not sure whats wrong there

river garnet
#

Yeah it doesnt collide with my platforms

rich adder
#

you have colliders on both?

polar acorn
#

Player character presumably. Computers don't tend to phase through desks Kappa

river garnet
#

Believe so

rich adder
#

also how are you moving the said object

river garnet
#

Yes PC is player character, sorry

river garnet
rich adder
#

oh lol yeah are you moving transforms maybe

quaint wadi
rich adder
river garnet
#

Oops they dont have box colliders

#

hang on

polar acorn
river garnet
#

Okay yeah it colldies now but doesnt move left to right

rich adder
#

going to have to at least send code / show setup

river garnet
#

What else do you need me to show?

quaint wadi
rich adder
wheat rune
#

!ide

eternal falconBOT
river garnet
rich adder
#

Debug.Log(horizontal)

river garnet
#

Speed variable, no I have not. Didnt know there was one

#

Oh a debug log, I see

rich adder
#

Ahh well its initialized with 0

#

therefore its 0 unless it was changed in inspector / code

river garnet
#

Which component is that under

rich adder
river garnet
#

Ah in my code, right

rich adder
#

expose it in the inspector to change it there with

#

[SerializeField] attribute (exposes private fields in the inspector)

river garnet
#

Add that line?

rich adder
#

only public fields are serialized by default in the inspector

river garnet
#

I got a compiler error, it says invalid token 'void' in class, record, struct, or interface member declaration

#

when I added that

rich adder
river garnet
#

Under the other seralizefields

rich adder
#

the attribute goes above or beside the field declared

river garnet
#

So I should put it in front of my privte float = speed line?

#

Sorry, im really new to this

river garnet
#

Like this?

rich adder
river garnet
#

You said [SerializeField] attribute

rich adder
#

but I only put the inline code on the attribute 😉

river garnet
#

Oh perhaps I took it too literally

rich adder
#

yes lol

#

look the links I sent

#

it should help

river garnet
#

so the line should be: [SerializeField] private float speed = 6f;

patent imp
#

i have 2 tile maps children of a grid. one is for the background the other is for on top of it. then i change the palette on one it also changes the other is that normal?

rich adder
#

thats how you wrote the others, yes 🙂 @river garnet

#

also your IDE does not look configured

#

it should've underlined red what you wrote before

river garnet
#

How do I configure it properly?

river garnet
#

I dont see it showing up in the inspector either, the speed variable I mean

rich adder
rich adder
eternal falconBOT
river garnet
#

Yeah no compiler errors and saved

rich adder
river garnet
#

Okay yeah I have all the IDE stuff right

#

Its at the top

#

Is it in the wrong spot

rich adder
#

make sure UNITY console doesn't have compile errors

river garnet
#

Nope no compiler issues

#

Just something about Render Graph API, but its not an error

rich adder
#

are your errors collapsed maybe

#

screenshot console window

#

try adding the script onto the gameobject again

river garnet
#

This is the console

#

Sure ill remove it and readd it

#

Ah yeah there it is

rich adder
#

ahh gotta love unity 6 bugs

river garnet
#

now ive lost my jump function hahaha

rich adder
#

make sure the layers are correct for the IsGrounded method

river garnet
#

I fixed it

rich adder
#

also do get your IDE configured

river garnet
#

It is

rich adder
#

its not

river garnet
#

Well I followed that link and I have everything it does

rich adder
#

it should not look like that, and it should say Assembly-CSharp at the top

#

instead of Miscellaneous

#

when you wrote [SerializeField] attribute private . should've underlined red

river garnet
#

I have the Game Development with Unity installed in VS

rich adder
river garnet
#

and my preferences tools have VS as my external script editor

rich adder
river garnet
#

Where do I find that

silk verge
#

supp can anyone help pls? looks like unity dont want to find my serializefield or smthing

rich adder
river garnet
#

I only see Reset Argument

rich adder
rich adder
silk verge
#

was screenshoting mbmb

river garnet
rich adder
rich adder
#

should be only a few steps

river garnet
#

Installed VS through unity hub? I didnt do that

#

I installed VS manually and installed unity hub seperate

rich adder
#

make sure you do that part via Visual Studio Installer

river garnet
#

I dont see that option on the installer, just the game dev with unity

#

which I already have installed

rich adder
river garnet
#

Yeah I did it manually when I first installed visual studio

#

figured id need it

rich adder
#

yup

#

okay go back to unity Preferences External tools, click the dropdown, show all the options

#

make sure you see the Visual Studio with the version number

river garnet
#

yeah the one that shows up is Microsoft Visual Studio 2022 (internal)

rich adder
#

I think it shows the actual version

river garnet
#

Well then how do I fix it?

rich adder
#

make sure Visual Studio Editor package is there

river garnet
#

No I dont see it in packages

hearty apex
#

Hey @river garnet , just a quick recommendation, it's just my opinion so you don't have to comply ,I strongly recommend you to learn c# without unity first , just learn the basics and stuff , once you get the hang of core functionality, it's going to be super easy for you to learn unity API. If you need some resources do let us (or me ) know.

river garnet
rich adder
# river garnet

thats a problem then
you need the Visual Studio Editor package installed

river garnet
#

Im normally a level designer

river garnet
#

I installed it

rich adder
#

normally it comes with the template idk what hapened there

river garnet
#

Well same reason I didnt have the URP either I assume

rich adder
#

yeah something went funky with your manifest.json lol

river garnet
#

Yes it says Assembly-CSharp now

#

Amazing. Thank you

rich adder
#

woo!

river garnet
#

I thought something was amiss cause it was white code instead of coloured

#

usually everything has a colour

rich adder
#

yeah usually thats a tell tale sign

full coral
river garnet
#

Chalked it up to just vs being weird though

#

Thanks again! You guys are life savers

hearty apex
#

And of course there's still the " but " factor

river garnet
hearty apex
#

One other thing you can do is have a complete goal of what type of game do you want to make, once you have a clear vision of requirement, learn specific things you need for it , and again only if you are limited by time.

river garnet
#

Its a bit trail by fire but I dont have much of a choice

#

Yeah thats what im doing, Im going basic 2d platformer for now, so I was trying to get player WASD controls and basic jump functions

#

Which are working now, so thats nice

hearty apex
river garnet
hearty apex
hearty apex
river garnet
#

Definitely. I tried finding everything on google but my errors were a bit hyperspecific and I didnt really understand

#

So this is a great resource

#

Especially considering my universal packages werent installed for whatever reason

full coral
# polar acorn If you're just relaying someone's question, maybe _they_ should come ask it so t...

im sorry i know its not as effective, since its not my question and im merely relaying, "Idk I was trying to make it check how long it's being held down using hold duration but when calling the input using On Input System Event and click Hold on the drop down it fires instantly. I'm not sure how to check the duration or make it wait the duration before registering. Right now it counts as held down instantly, even though the hold duration is set to 1 second by default."

he said this, for context, we are just truggling through unity and dont know the best way to do things, so this methodology might seem convoluted and overly complicated. idk what to do. all we are trying to do is differentiate bwtween a press and drag, and a tap

slender nymph
#

if you're having trouble with the input system, then check out the documentation pinned in #🖱️┃input-system to learn how it works

river garnet
#

Does anyone know how I get text to display on screen in my scene? I have made a timer and im trying to put it in the top right corner

#

Or how to move it to the right spot rather

languid spire
fair steeple
river garnet
#

I have this

languid spire
#

so, no canvas

slender nymph
#

this is not a code question. but you can clearly see that it is in the bottom left of the canvas

river garnet
#

My bad then ill just google it

slender nymph
#

consider looking at the documentation pinned in #📲┃ui-ux to learn how the canvas and your ui objects work

#

but this is literally just a matter of "move it to the top right of the canvas instead of the bottom left"

fair steeple
#

How can I make CharacterController.SimpleMove() move relative to the Self space instead of World?

#

It's for a first person controller

slender nymph
#

pass the direction to Transform.TransformDirection and use the return value of that

river garnet
#

Its okay, wrong channel anyway so its my fault. Ill keep searching

slender nymph
fair steeple
#

The canvas is kinda confusing

slender nymph
#

you see that big white rectangle that your text object originally started in the center of and now has its bottom left corner near the center of your screenshot? that is the canvas

river garnet
#

a little bit yeah

#

I see

fair steeple
#

Are you watching a youtube tutorial? I feel like this is better if you see how it's done

river garnet
#

Yeah I am

#

I just dont really get it, when they put in the text on the tutorial it immediately just appears on screen

#

mine isnt doing that

slender nymph
#

double click the canvas in your hierarchy so you can see it. that represents the entire screen view for the UI

languid spire
#

because you do not have your canvas object selected and focused in the scene view

slender nymph
#

and, again, check the docs in #📲┃ui-ux to learn how to use the canvas

languid spire
#

wdym, Unity should just automatically know what I am doing and what I want to do

river garnet
#

Alright no need for the condescending remarks, it was just a question. Ill figure it out

rocky canyon
#

no clue what Records are.. but all that other stuff yea

queen adder
fair steeple
lone barn
#

Is there a consensus on how you should move a 2d rigidbody player ?
Should I use AddForce, MovePosition with a kinetic body, velocity, position ?

rich adder
somber nimbus
#

Hello everyone! I'm an absolute beginner to C# in Unity and I'm following a tutorial by a YouTube Channel named Zigurous on how to make a Flappy Bird. For some reason, I can't get my prefab for the pipes to actually create new pipes despite having the code written and done without no errors. Can somebody help me? (Btw, timestamp for the tutorial is 37:04 if you need any reference)

slender nymph
#

okay now show the code that creates new pipes

somber nimbus
#

VS is saying that the code that is crossed out is obsolete, does it have to do with that?

#

The tutorial is kinda old, it's using Unity 2019

slender nymph
#

why did you mark the Spawn method as obsolete?

somber nimbus
#

VS marked it on its own 😭

slender nymph
#

no it didn't

somber nimbus
#

How do I unmark it then? I closed the editor, reopened the script and I just saw it like that

slender nymph
#

read your code

echo cloak
#

it says "System.Obsolete"

somber nimbus
#

Where and what do I do with it?

echo cloak
#

You should probably remove the attribute, if you don't want the method to be obsolete

somber nimbus
#

Oh okay

#

It still doesn't work, the spawning of the pipes I mean

#

In my case, they're the stalagmites

#

I deleted the system obsolete btw

slender nymph
#

show the spawner object

somber nimbus
slender nymph
#

and what enables it

somber nimbus
#

you mean the script?

slender nymph
#

yes

somber nimbus
#

OH MY GOODNESS THANK YOU

#

I'm so sorry, I'm very new to this 😭

#

That fixed it

oak kelp
#

for some reason when i put code in void Update() nothing works?

devout flower
#

If you put a debug statement in it, does it work

#

Also show where the script is attached

oak kelp
slender nymph
#

did you actually put a log inside of Update?

oak kelp
steep rose
#

so update does work, what do you mean by nothing else works, have you tried debugging?

oak kelp
#

i tryed logging keypresses like spacebar and none of it gets loggedf

languid spire
eternal falconBOT
steep rose
#

dont you need an eventsystem in your project for things to work?

#

im pretty sure you do iirc

languid spire
#

only for canvas

steep rose
languid spire
oak kelp
#

what do you mean?

languid spire
#

exactly that

oak kelp
#

i dont get what you mean sorry

languid spire
oak kelp
#

mine doesnt look like that

steep rose
#

make sure you are not in preferences

oak kelp
#

im in project settings