#💻┃code-beginner

1 messages · Page 166 of 1

rare basin
#

i know you have IDE lol

thorn holly
#
  1. Configure your ide
  2. Do you know the basics of c#?
radiant glen
#

Sort of but really like this is my first game

thorn holly
#

Alr

#

Well I’d reccomend learning the basics, it makes writing your own code and debugging much easier

#

Also, instead of following an online tutorial, I’d reccomend using unity learn, cause in online tutorials you don’t really learn anything, cause ur just copying whoever’s in the video

#

That’s what I’d personally do but if an online tutorial works for you, than go ahead, do what’s right for you

radiant glen
#

Okay that makes sense I have been trying to use unity learn when possible but for specific things I have been using youtube

long scarab
#

I made it work by sort of hack

#

thanks for your help nonetheless

#

I shifted two vertices out of the plane and made the collider convex, resulting in unfortunately not precise collider mesh, since it overlaps in places, but at least the ray hits it.

#

Technically I made the mesh collider 3D

verbal dome
#

Hmm okay so it didn't like a flat mesh?

long scarab
#

If anyone would know a better way how to bypass this, please let me know, it would be greatly appreciated as the current sollution is kinda meh.

long scarab
verbal dome
#

Yeah that's what I mean

long scarab
#

then yes haha

verbal dome
#

It's not a problem with imported meshes but maybe there's something different when you generate it yourself

long scarab
#

yeah

#

I thought about using sprite

#

SVG or something

#

but then I want users to be able to draw two shapes, arrow and a complex line, and the sizing and stuff would be worse than generating it 😄

#

actually now I think about it and it sucks because the complex shape, when having convex collider, would occupy also the empty space 😐

faint sluice
#

Just a tip, in case you want to see in real time where your raycast is being blocked, you can see it in inspector of "Event System"

Helps me a lot when I feel like some raycast should detect an object but turns out something else was blocking the ray

#

It shows the name of object your mouse is hovering over (if it blocks raycast)

long scarab
#

yeah I used Debug.DrawRay instead

#

so I could see the direction etc

#

but great tip!

long scarab
#

cause I dont see the thing I hover over

faint sluice
#

Can't describe what it's called

#

And it shows up only in play mode

long scarab
#

ah yes

#

got it

#

niiice

pale jetty
#

Hi everyone, i wanted to know if any of you can see where the problem is, i want that when i click on the button, a panel close for another to open, so here is my code, but the problem is that when i click on the button nothing happen. You can see that the button named 'BoutonOutils' in the TableCraft GameObject don't work, normally when i do that, it should close the 'TableCraft' GameObject and open the 'OutilsCategory' GameObject'. Here is the code :

#
void Start()
    {
        isOpen = false;

        OutilsBouton = CraftingScreen.transform.Find("BoutonOutils").GetComponent<Button>();
        OutilsBouton.onClick.AddListener(delegate
        {
            OpenOutilsCategory();
        });

        //Hache
        HacheBesoin1 = OutilsScreen.transform.Find("Hache").transform.Find("besoin1").GetComponent<TextMeshProUGUI>();
        HacheBesoin2 = OutilsScreen.transform.Find("Hache").transform.Find("besoin2").GetComponent<TextMeshProUGUI>();

        HacheBouton = OutilsScreen.transform.Find("Hache").transform.Find("Construire").GetComponent<Button>();
        HacheBouton.onClick.AddListener(delegate
        {
            Construire(PlanHache);
        });
    }


    void OpenOutilsCategory()
    {
        CraftingScreen.SetActive(false);
        OutilsScreen.SetActive(true);
    }```
long scarab
#

Does it detect the button click at all? As in when you are debugging, via some Debug.Log or IDE debugging?

#

Also a hint, you you can nest hierarchy finds and use OutilsScreen.transform.Find("Hache/besoin1").GetComponent<TextMeshProUGUI>();

raven igloo
#

!code

eternal falconBOT
pale jetty
#

when i do this : void OpenOutilsCategory() { Debug.Log("Ouverture de la catégorie Outils"); CraftingScreen.SetActive(false); OutilsScreen.SetActive(true); } It doesn't detect the button and i don't know why

long scarab
#

So it does not output the log, correct?

pale jetty
#

yes

#

the message doesn't show up

long scarab
#

Can I see the button in the unity? Is it interactable and enabled?

#

Well I see its enabled

pale jetty
#

yes it's interactable

long scarab
#

And the rest of the inspector interface? 😄

raven igloo
#

Hello, my sprite is not flipping, the code and i dont know why but ive seen something a bit odd and i really dont know why, the sprite renderer in the scrip is not the same as the sprite renderer

long scarab
#

Also, are EventSystem and Input Modules present?

pale jetty
#

there is an evensystem

#

the rest of the inspector :

long scarab
#

I am afraid I have to leave the answering to others then

#

And you have Input Module correct?

pale jetty
#

are you talking about the input system ? if it's that then no:

long scarab
#

I mean the input module

wintry quarry
raven igloo
pale jetty
#

ah no i don't have this

raven igloo
polar acorn
# pale jetty there is an evensystem

If you open the event system while you're running the game, it'll tell you on the bottom window of it what object you're hovering over or interacting with. See what it says when you're trying to click the button, there might be something in front of it taking that click event before it can hit the button

long scarab
radiant glen
#

I am getting this error code for my code, any help would be amazing

pale jetty
#

when i click on it, the eligibleForClicl become true

raven igloo
long scarab
#

"Ouverture de la catégorie Outils"

wintry quarry
raven igloo
languid spire
raven igloo
languid spire
#

ah, yes, that's a no-no, only one Monobehaviour class per script but you can have other POCO's there as well

raven igloo
#

yes at least i will be more aware

#

first time codin in c#

languid spire
#

this is a Unity specific thing not C# in general

pale jetty
long scarab
#

Yeah, something must be off with the listeners or something else, unfortunately I am not sure what else I could do to help for now

raven igloo
pale jetty
#

thank you for your help

swift crag
pale jetty
#

i even desactivated the raycast of the image there was on the button but nothing change

swift crag
#

That's also why you can freely rename your class without breaking existing components -- as long as you don't rename the script file outside of unity

languid spire
swift crag
#

you can interpret it that way, if you'd like

languid spire
#

too many bad design decisions to take it any other way

swift crag
#

there's nothing special about script assets; they're just like any other kind of asset

long scarab
swift crag
#

you reference the asset, and the asset is identified by its GUID

long scarab
#

as in if nothing is null, sometimes when using Find and other hierarchy stuff I make the mistake of getting nulls

#

but that'd throw Null Pointer Exception anyway

languid spire
#

yep, the whole asset database concept is a pigs ear reminiscent of the windows registry

swift crag
#

when you enter debug mode, you can change which script asset a component references. you don't reference a C# class, just like you don't reference the literal data in a PNG or the literal audio data in a wave file

pale jetty
ashen coral
#

Guys, please help me find the error in the code (this code is needed to control the player’s movement using a controller)

long jacinth
swift crag
verbal dome
long jacinth
#

i swapped it

verbal dome
#

You didnt use the code example of DeltaAngle I gave you.

#

Im not saying to use -180 and 180 in your if-statement. It should be -90 and 90

amber nimbus
#

Hello, I was wondering If I call a Method inside a method like this:

  // some code here
  if (true) {
    DoThis();
  }
  // other code here
}```
Would the "other code here" run if there was actual code after `DoThis()` is done?
verbal dome
#

The angle you use in the if statement should be the one you get from DeltaAngle @long jacinth

wintry quarry
amber nimbus
#

Aight, thanks

ashen coral
wintry quarry
#

you are ignoring the filename and line number of the error

long jacinth
verbal dome
wintry quarry
verbal dome
#

Judging by the colors it is not configured

young smelt
#

https://paste.ofcode.org/34EQzyZPNQJsSfNxQiwkBun

Exception: Cannot add more triangles than the size of the triangles array.
MeshData.AddTriangle (System.Int32 a, System.Int32 b, System.Int32 c) (at Assets/Scripts/MapGeneration/MeshGenerator.cs:69)
MeshGenerator.GenerateTerrainMesh (System.Single[,] heightMap) (at Assets/Scripts/MapGeneration/MeshGenerator.cs:28)
MapGenerator.GenerateMap () (at Assets/Scripts/MapGeneration/MapGenerator.cs:57)
MapGeneratorEditor.OnInspectorGUI () (at Assets/Scripts/Editor/MapGeneratorEditor.cs:23)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass72_0.<CreateInspectorElementUsingIMGUI>b__0 () (at <97436df440ca462884c5332c1d8ebbe7>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

#

Saw a land mass generation video with indepth explanation and all but now I am getting this. when it comes to adding triangles to the mesh

wintry quarry
#

Yep seems pretty clear where things are going wrong:

    public void AddTriangle(int a, int b, int c)
    {
        if (triangleIndex >= triangles.Length)
        {
            throw new Exception("Cannot add more triangles than the size of the triangles array.");
        }```
young smelt
#

I added an exception to break it once it reaches the lmax length of the triangle

wintry quarry
#

yes and you have reached the limit

noble folio
#

hey im trying to make a ball shoot system like in mini soccer star but whitout the aiming arrow can someone help me make the script?

#

also its gonna be a mobile game so mobile input

young smelt
#

Oh it writes exceptions like errors.!!! I fucking forgot

wintry quarry
young smelt
#

Thought my code was wrong

wintry quarry
#

I'm pretty sure that array is at least 6x too small

verbal dome
wintry quarry
#

i think it should be new int[meshWidh*meshHeight*6]

#

since you need 3 spots per triangle and you're doing two triangles for every x/y

verbal dome
#

Each "pixel" in the heightmap has 2 triangles not 1

#

And each triangle is 3 ints

young smelt
#

Won't it be something like new int[(meshWidh-1)*(meshHeight-1)*6] then. So that it doesn't take count of the externalmost point

long jacinth
#

in the if statement i swapped out the eulerangles.z

wintry quarry
#

since you're only doing one check of if (x < width - 1)

#

so new int[(meshWidth - 1) * meshHeight * 6]

long jacinth
#

Operator '<' cannot be applied to operands of type 'method group' and 'int'

swift crag
tender hound
#

i started with entities so i created a new project downloaded entities package after this i create a sub scene and a cube but if i press play i dont see the cube at all in the game window do i need to change a setting in the camera or something?

swift crag
#

therefore, you're getting this error because you're trying to use the < operator with a method on the left side

verbal dome
wintry quarry
swift crag
#

I presume you wanted to just use your Angle variable.

#

(which shouldn't be capitalized, since it's a local variable)

verbal dome
#

if(Angle < -90 || Angle > 90)

#

Notice || instead of &&

#

Try to understand what you are doing

#

If you would use &&, it would have to be both <= -90 and >= 90 at the same time

#

That's not possible now is it

rare basin
young smelt
#

Fixed it changed this

if (x < width - 1 && y < height - 1)
{
meshData.AddTriangle(vertexIndex, vertexIndex + width + 1, vertexIndex + width);
meshData.AddTriangle(vertexIndex + width + 1, vertexIndex, vertexIndex + 1);
}

and this

triangles = new int[meshWidth * meshHeight * 6];

tnks

#

paetroblue and the gang. thnks

long jacinth
ashen coral
long jacinth
#

thank you guys for helping the gun rotation works perfectly now

#

i was stupid and didnt realize what i did wrong

verbal dome
#

Heres a bonus for you to make sense of the angles:

long jacinth
#

thanks so much

verbal dome
#

You are checking if the angle is in one of the bottom sectors in that image

#

Np

stark flint
#

Hello i am trying to make a script for OpenXR Unity game. How do i make it so if a specific game object is picked up then a different specific game object dissapeared. Also if the object is let go off the object that disappeared comes back.

languid spire
#

!code

eternal falconBOT
languid spire
stark flint
cinder spruce
#

how can i prevent all methods to be called at the same time inside the RandomlyChooseAttack function? Line 104

languid spire
languid spire
cinder spruce
languid spire
#

no you didn't you posted the original code back here

stark flint
languid spire
eternal falconBOT
#

:teacher: Unity Learn ↗

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

languid spire
#

Update -> EnemyLogic -> RandomlyChooseAttack
So once this has been done you need a bool or something to stop it until the next time you want to do it

grizzled pagoda
#

hi, im having trouble with a boolean not turning true when i want to ``` public bool ZombieStop = false;
public float speed = 10f;
public float HealthPoints = 5f;
private bool PlantCollide = false;
// Start is called before the first frame update
void Start()
{
}

// Update is called once per frame
void Update()
{
    if(ZombieStop == true){
        speed = 0f;
    }
    else{
        speed = 10f;
    }
    transform.Translate(Vector3.forward * Time.deltaTime * speed);
    if(HealthPoints <= 0){
        Destroy(gameObject);
    }
    if(HealthPoints <= 0){
        Destroy(gameObject);
    
    }
}
void OnCollisionStay(Collision other){
    Debug.Log(other.gameObject.layer);
    if(other.gameObject.layer == 7){
        HealthPoints = HealthPoints - 1;
        Debug.Log("Zombie HealthPoints: " + HealthPoints);
    }
    if(other.gameObject.layer == 6){
        ZombieStop = true;
        speed = 0f;
        Debug.Log("Zombie should stop");
    }
}
void OnCollisionExit(Collision other){
    ZombieStop = false;
}

}

cinder spruce
wind raptor
#

Coming back to this, is there a particular framework you'd recommend? If I'm just building a single, locally-hosted webpage would it be worth just skipping the framework?

Edit: and is there a framework that could provide a visual means of creating the UI, instead of having to hardcore everything?

tender hound
#

why canti see the cube in the game window?

wintry quarry
languid spire
tender hound
queen adder
wintry quarry
tender hound
wintry quarry
cinder spruce
#

@languid spire also it sets the attack animation bools to false otherwise animations get stuck

ionic zephyr
#

Hey guys, do kinematic objects interact or overlap one and other?

#

and static

#

or do only dynamic objects (rigidbody) collide with each other?

languid spire
#

so you're turning off the animation immediately

wintry quarry
#

they don't react to any other objects in the scene or forces at all

ionic zephyr
#

but they are overlaped by each other?

wintry quarry
#

they're overlapped if you place them in overlapping positions

#

not really sure how to answer that

#

they go wherever you tell them to go

ionic zephyr
#

okay, what about static?

cinder spruce
wintry quarry
ionic zephyr
#

so what is the point of placing a Rigidbody on them?

#

triggers maybe?

languid spire
wintry quarry
ionic zephyr
#

okay, thanks!

cinder spruce
swift crag
languid spire
cinder spruce
languid spire
#

you need to control that wilh another bool set to true in RandomlyChooseAttack and set to false in CoolDown when the timer expires

shell herald
#

still dont undestand why this code is not working. i have this script on my button prefab and want the sound to play every time the button is selected

#

am i not getting something here?

shell herald
#

i tried it with event trigger, but couldnt get it to work with mouse and controller input. do you perhaps mean the "Select(BaseEventData)"?

wintry quarry
#

also ISelectHandler will work exactly the same as EventTrigger btw

languid spire
rich adder
shell herald
#

yeah, now everything works

tawdry totem
#

i tryed to create a solution to weapons clipping thru wall and other objects, by rendering then on another camera, but that shows them thru wall as well, any idea how to fix this?

rare basin
#

that is a code related channel

tawdry totem
rare basin
#

so ask a code related question 🙂

rich adder
tawdry totem
rich adder
#

eg weapon is in Default layer and then on pickup you do weaponObj.gameObject.layer = LayerMask.NameToLayer("WeaponRenderer");

quick ruin
#

need to set it back to none is there a code

rich adder
icy quail
#

hi, can anyone tell me what is the difference between purple and pink filed in unity object explorer?

#

i hve to use that hff.... but the code doesnt see it, i can use other fields but not that one

rancid tinsel
#

what was the command for setting up vs studio with unity?

#

discord command i mean

languid spire
#

!ide

eternal falconBOT
rancid tinsel
#

thanks

#

@grizzled pagoda do the visual studio one

#

so you can see the errors

#

in visual studio while typing

short hazel
icy quail
#

as you can see i can select "fpvfieldofview"

polar acorn
# icy quail

Can you show the code for hffkblekiic (which is a mouthful by the way. Is there a reason these variables are keyboard mashes?)

smoky mauve
#

what does this error mean?
type is not a supported string value
UnityEditor.RetainedMode:UpdateSchedulers ()

polar acorn
languid spire
short hazel
icy quail
short hazel
#

You'll have to find the official discussion channel of the game, wherever it is

#

And yeah the garbled variable names is probably because of an obfuscator on the source code

terse raven
#

Can entities have colliders on them or would that decrease performance

cunning locust
#

Are while loops actually used by anyone? I mean i always use either if statements or for loops

rocky canyon
#

yes

cunning locust
#

is there an example where you must use a while loop instead of for or if?

languid spire
cunning locust
#

I've been programming for 2 years and i only tried to use it once, my game crashed, now i never use them and im okay

wintry quarry
cunning locust
#

Okay so while loop doesnt have special usage that a for loop cant do

rocky canyon
#
        if(drag)
        {
            //enable elsewhere
            lineSystem.SetActive(true);
            currentMousePosition = Input.mousePosition; // start updating currentPosition
            float dragDistance = Vector3.Distance(initialMousePosition,currentMousePosition);

            if(dragDistance > dragThreshold)
            {
                initialMousePosition = currentMousePosition; // reset new position for next drag check
            }

            if(Input.GetMouseButtonUp(0))
            {
                lineSystem.SetActive(false);
                drag = false;
                initialMousePosition = currentMousePosition;
            }
        }``` heres an example of one of my if loops
#

i have exit conditions like drag = false..

#

now if i was a better coder id use a while loop instead

cunning locust
#

this seems fine to me

languid spire
#

how is that a loop?

rocky canyon
#

it is acceptable but could be better

#

its in update

#

it loops while drag = true

cunning locust
rocky canyon
#

ya

languid spire
#

then the if is irrelevant, the Update is the loop

cunning locust
#

yes but the if breaks out of the loop.

rocky canyon
#

no.. its not irrelevant? i dont want it to loop unless the condition is true

#

🤔

languid spire
#

if is not a looping statement

rocky canyon
#

i mean the code in theory Loops

#

but its not a for loop

rare basin
#

you said one of my if loops

rocky canyon
#

okay steve

cunning locust
#

Anyway, just proving my point that while loops are not neccessary

rocky canyon
#

im pretty sure while drag = true it loops

#

pretty much every frame

languid spire
#

ok, try that in a Coroutine

rocky canyon
#

i could make it a coroutine 🤔

languid spire
#

go on then

cunning locust
#

What is a coroutine?

polar acorn
cunning locust
#

i dissagree

wintry quarry
#

while loops are just cleaner than for loops in some circumstances @cunning locust . For example:

Queue<int> queue = new() { 1, 3, 4, 5, 6 };

while (queue.Count > 0) {
  int next = queue.Dequeue();
  print(next);
}```

A for loop would be a but less elegant here...
```cs
for ( ; queue.Count > 0; ) {
  int next = queue.Dequeue();
  print(next);
}```
cunning locust
#

a for loop is extremely neccessary sometimes

wintry quarry
#

you can write any for loop as a while loop

#

including foreach loops

polar acorn
languid spire
polar acorn
#

They're tools to have in your toolbox, and discounting one because you can massage another into the same use case isn't relevant

#

You should still learn how to use them

wintry quarry
#
List<int> list = new() { 1, 2, 3, 4, 5 };

IEnumerator<int> enumerator = list.GetEnumerator();
while (enumerator.MoveNext()) {
  int current = enumerator.Current;
  print(current);
}```
^ Here's how to write `foreach` as a `while` loop
cunning locust
#

Does visual studio have a snippet shortcut?

#

Like when I press a shortcut key, it instantly pastes a for loop

#

or a switch

short hazel
#

They appear in the completion list as you type

short hazel
#

for, then Tab to complete

cunning locust
#

Not quite what im looking for

#

a switch statement doesnt autocomplete cases

short hazel
#

For enums, it does

languid spire
#

don't worry about using shortcuts, learn how to write code yourself

short hazel
#

Else, it cannot decide for you

cunning locust
cyan pollen
#

does system.random still work?

rocky canyon
#
public Update()
{
  if (Input.GetMouseButtonDown(0))
    {
        // Set drag to true when the mouse button is pressed
        drag = true;

        // Start the coroutine
        StartCoroutine(DragCoroutine());
    }

    if(Input.GetMouseButtonUp(0))
    {
        drag = false;
    }
}

IEnumerator DragCoroutine()
{
    // Enable the line system when starting the drag
    if (!lineSystem.activeSelf)
    {
        lineSystem.SetActive(true);
    }

    while (drag)
    {
        currentMousePosition = Input.mousePosition;
        float dragDistance = Vector3.Distance(initialMousePosition, currentMousePosition);

        if (dragDistance > dragThreshold)
        {
            // Update LineRenderer during drag
            UpdateLineRenderer();

            // Reset new position for the next drag check
            initialMousePosition = currentMousePosition;
        }

        yield return null;
    }

    // Disable the line system when releasing the mouse button
    lineSystem.SetActive(false);
    initialMousePosition = currentMousePosition;
}```
#

coroutine 🤔

cyan pollen
#

what happened to system.random?

cunning locust
languid spire
#

now you have a while

rocky canyon
#

i know that was the entire point!

#

i could make it a while if i wanted

short hazel
rare basin
languid spire
rocky canyon
#

but i dont want a coroutine.. so ill just use my if() conditionals until it isnt feasible

cyan pollen
rare basin
#

then you are using it wrong

cunning locust
rocky canyon
#

its debateable as noticeable

#

if you dont need to use a while loop, dont use one.
but they aren't unneeded in no form

dawn juniper
#

Hello, I'm making a 2d game and in a level I want to see nothing that everything looks black, all black and when the character puts a torch you can see around the torch, you can see what is the map, what I mean is that everything looks black and the light of the torch let you see the map, but I've been trying things and I can not do it, anyone knows how it could be done?

cunning locust
#

I mean.. you can make fortnite with 0 while loops

#

sounds unneeded to me

rocky canyon
#

you can make fortnite? 👀

wintry quarry
#

while is the most flexible type of loop. All the other loops are built on top of it

rocky canyon
#

this sounds accurate ^

wintry quarry
#

You can also write English sentences without the letter "e" but there's not good reason to do so.

rare basin
#

you can make fortnite without any for loop aswell

cunning locust
#

All im saying, if while loop wen't extinct, it wouldnt limit me in any way

languid spire
#

you can make anything without using any looping construct other than label: goto label. Should you? NO

rare basin
#

for you != useless

wintry quarry
#

You will look back at yourself saying this in 5 years and laugh

short hazel
#

Wrong, because most loops in C# compile to while loops

cunning locust
short hazel
#

Your code wouldn't compile at all lol

rocky canyon
#

not really.. u can emulate loops with if conditionals and booleans

rare basin
#

thinking in your logic

#

for sounds unneeded to me

cunning locust
#

i mean techinally.. ye

languid spire
#

As I said earlier, there are several well known languages which have no loop constructs at all

cunning locust
#

its one or the other.

#

A for loop automatically can set a limit to the loop

#

which while loop can't

#

i mean it can, but

rare basin
#

while loop can put a bool inside the brackets

languid spire
#

of course it can

rare basin
#

and for cannot

#

stupid debate

rocky canyon
#
  • i dont use while loops b/c im not good enough to use em yet *
#

i get tired of locking up my project

cunning locust
#

I think a for loop is more advanced than a while loop

polar acorn
rare basin
wintry quarry
cunning locust
rare basin
#

it looks more confusing to you = its more advanced?

cunning locust
rocky canyon
cunning locust
rocky canyon
#

i dont code outside of unity unfortunately

eternal needle
#

Yea I feel the same about multiplication, why is it so confusing. We should just use addition, remove multiplication since it is clearly bloat

wintry quarry
rare basin
languid spire
rocky canyon
#

facts! lol idk i just jumped in

rare basin
wintry quarry
polar acorn
cunning locust
languid spire
#

idiot

rare basin
#

he's trolling

rocky canyon
#

🤣 i cant

rare basin
#

at this point xd

eternal needle
#

This is clearly a kid

cunning locust
#

I was hoping to have a nice discusion over a topic, yalls reaction is not it.

#

I'm just debating.

rare basin
#

can't have a nice discusion if you are closed to answers

#

and can't take facts as a.. facts lol

rocky canyon
#

debates usually aren't hugs and kisses

#

this was still a debate

cunning locust
#

Well it was a calm friendly debate on my end.

rare basin
#

I would strongly disagree, i have years of experience in psychology

vapid vector
#

hey guys, I just started out with unity and I was following this udemy course I got, I'm trying to make one of these hyper casual games just to learn the basics, here's a tiny bit of the player animation code. It works fine between idle and running, but I wanted to also make the player walk based on the "intensity" of the joystick, based on how far off it is, if just a tiny bit, he'd walk. I did alter the code for that but the value I was checking wasn't perfectly consistent so most of the time he'd jigger between run and walk when just pulling the joystick to a half point, if I do an if for lets say magnite > 0.5, usually walking is 0 to 0.5 and running is 0.5 to 1, but there would be odd values in between, running could have a random .4 and walking could have a random .6
any advice on what value I should be checking (I'm starting to think the vector magnitude isnt the correct one xd) or how I can get the speed to do this?

languid spire
eternal needle
cunning locust
languid spire
polar acorn
cunning locust
#

little missunderstanding on my part

polar acorn
languid spire
cunning locust
#

That's why gamemaker shouldnt be a starting point in programming games, this type of information is extremely helpful now that i've moved to unity

#

Neved heard of goto before yesterday 🤣

languid spire
#

then your education has been sorely lacking

cunning locust
#

I agree

#

hopefully i'll learn more here

eternal needle
#

You dont really use goto directly yourself in c#

cunning locust
#

I mean when you learn programming, someone tells you the information that you want to learn

cunning locust
#

Thought it's commonly used by unity developers

eternal needle
#

You dont explicitly type goto in your code

rocky canyon
#

ive only ever seen Goto: logic in memes (relating to Unity)

frosty hound
#

Goto isn't commonly used at all in Unity

languid spire
#

one of the reasons that C# has so many different loop constructs is so that you dont need to use gotos yourself.
In fact if you follow strict OOP JSP principles goto should never be used by an application programmer

cunning locust
languid spire
#

the break statement is technically a goto

polar acorn
rocky canyon
#

complicated switch statements if its goto'ing around and about but yea, breaks, returns, etc

cunning locust
#

it just breaks out of the switch

short hazel
#

You can actually goto case n in switch statements

rocky canyon
#

thats why u structure ur logic in a coherent way

languid spire
#

the where is implicit. end of scope

rocky canyon
#

u shoudn't need to tell it specifically where to go

cunning locust
#

While i cannot imagine a case where this would be usefull for me, it sounds like a neat feature which might be usefull

rocky canyon
#

i need to write more switch statements.. my logic never gets that robust, hopefully someday ill transcend

languid spire
#

people dont realize. case is the same as label. that is why it terminats with a :

rocky canyon
#

even if u dont use it.. knowing something is available to u puts u ahead of the ones that dont

languid spire
#

absolutely, you dont need to know the exact signature of all API's you just need to know they exist

rocky canyon
#

imagine before the internet was what it is now.. u'd have to have a bookshelf at ur ready 😄

#

now u can just "beep: boop:" what ur hunting

languid spire
#

look at my bookshelfs

rocky canyon
#

i have 1 math book

#

for vectors if i remmeber

languid spire
#

I have hundreds of coding and sdk manuals

cunning locust
#

when people coded before internet their books were already read 100 times before

rocky canyon
#

any that u would swear by?

cunning locust
languid spire
#

today, no, much better info on the net if you know how to search

rocky canyon
#

im always on the lookout for an extra ebook i can store

languid spire
eternal needle
#

What a wild difference in times, during my time in university I seriously never bought a single textbook.

rocky canyon
#

👀 how? lol

#

i bought dozens of books, and sold them back at the end of the semester

cunning locust
#

cyber hacking

languid spire
#

yep and much much more

rocky canyon
#

pretty sure he can do it all

cunning locust
#

thats neat

#

Which one brings the most money?

rocky canyon
#

cyber security

languid spire
#

50 years is a long time to learn this shit

cunning locust
#

Oh no doubt

#

i envy you

languid spire
rocky canyon
#

selling ur soul

languid spire
#

it's also more fun than game dev

cunning locust
rocky canyon
#

Capitalism! Hoorah!

languid spire
rocky canyon
#

..and he's bilingual 👀

languid spire
#

multilingual if you please

rocky canyon
#

i knew it!

cunning locust
#

is Steve Smith Steve Jobs by any chance

languid spire
#

my mate Jobs is dead, I'm not

rocky canyon
#

if you say so

cunning locust
#

whatever you say Jobs..

void dawn
#

Does anyone have a hard time on YouTube tutorials

rocky canyon
#

very very rarely

languid spire
rocky canyon
#

if i do, the solution is in the comments

#

the trick to youtube tutorials is to follow it exactly pay attention to what they click (they might not narrate every click they make)

#

dont be afraid to pause, and rewatch

#

usually they wont post a video that doesnt work..

languid spire
#

no, the trick with YT tutorials is NOT TO WATCH YT TUTORIALS because most of them are crap

rocky canyon
#

true, but if you do..

#

lol

void dawn
languid spire
#

bet

rocky canyon
#

imo youtube tutorials are best at exposing you to ideas, mechanics, and etc

eternal needle
rocky canyon
#

its up to you to take those and research and fill in the blanks

languid spire
#

99% of YT turorials are made by people to make money or self promote, nothing else. They generally know nothing

rocky canyon
#

if u dont.. ur just copying what they make.

cunning locust
#

So what? Should i just read the whole c# manual to learn something?

languid spire
#

yes

#

and practice

rocky canyon
#

eventually yes, but thats an extreme..

#

no ones asking u to read the entire manual to figure out what a transform is

#

You dont get dropped off in mexico and learn the entire mexican language on the first encounter with a local..

cunning locust
#

What about the 10+ hour full course tutorials?

eternal needle
# void dawn You can't just generalize like that

The youtubers that actually know what they're talking about, dont really make step by step guides that you'll be able to learn from. They will briefly mention an entire concept, because they're just telling you how they implemented a feature. If you dont understand the existing tutorials you're looking at who show you the code line by line, you 100% will not understand the few good tutorials that exist

rocky canyon
#

same with learning a computer language..

rocky canyon
#

like Udemy courses?

cunning locust
#

Not necessarily, but sure. For example rn im watching a free one on youtube, 7 hours long full course

languid spire
#

Take Brackey, heralded as the king of Unity YT tutorials by many, his code is so full of errors it's untrue and what he 'teaches' is rubbish

rocky canyon
#

you'll still have to do some follow-up on ur own

cunning locust
#

To be fair, 4 hours in i just got over the loops, which are basically the same in any language

#

My bad, 2 hours in.

rocky canyon
#

basics aren't all that exciting

queen adder
#

where can i get help for scripting errors?

rocky canyon
cunning locust
#

I'm sure there's a debugger in unity

queen adder
hexed ginkgo
rocky canyon
#

absolutely correct.. you learn the most by doing

hexed ginkgo
#

like a lot of stuff just doesn't make sense if you don't do it yourself

cunning locust
#

I mean noone watches a tutorial without a project opened up

#

i hope.

rocky canyon
#

i never watch anything without a project opened up lol

hexed ginkgo
#

yeah but I mean

#

you don't learn stuff by blindly copying it

#

you learn it by applying it yourself

cunning locust
rocky canyon
cunning locust
#

When you are in school all you do is copy from the board.

rocky canyon
#

"eureka moments" is a better term

queen adder
#

i have like 2 scripts, one script checks if the player is touched and then uses the method of another script to show a game over ui
everytime i reference the method, i get this error: Object reference not set to an instance of an object

rocky canyon
#

gameManager is not assigned

queen adder
wintry quarry
#

it needs to be assigned in the inspector - or elsewhere

queen adder
#

oh damm

rocky canyon
#

u just told Unity that you have a GameManager class u want to be named gameManager.. but u never assigned it so unity doesn't know which one

hexed ginkgo
cunning locust
#

Yeah refferencing stuff was confusing to me at first for sure

hexed ginkgo
#

go to the player object

#

and drag the game manager object into the slot provided under your player script component

modest dust
queen adder
#

do i have to tie it with a script?

rocky canyon
queen adder
#

i mean game Object

hexed ginkgo
rocky canyon
#

yea u drag the gameobject containing the "GameManager" script

queen adder
#

so i just create a gameObject for the sole purpose of storing the script?

rocky canyon
#

it has to be in the scene to run properly since its a monobehaviour

queen adder
#

ok

rocky canyon
#

so ya, just make an empty gameobject name it something relateable, drop the gamemanager on it

#

and use that to get ur reference

queen adder
#

my KillBlock script is in a prefab tho

cunning locust
#

Does c# have variables with different scopes? Can i make an enum or a macro which could be accessed in any script for example?

rocky canyon
#

ya, public

#

private, static, etc

#

public is accessable anywhere

cunning locust
#

I thought public just means i can edit it via the unity editor

rocky canyon
cunning locust
#

the components tab

rocky canyon
queen adder
#

and the game Manager is inside the ui

rocky canyon
#

a private field can be shown in the inspector.. if u use
[SerializedField] private float myFloat;

cunning locust
#

Interesting, maybe i shouldnt overuse public variables then.

rocky canyon
cunning locust
#

that's usefull to know, thank you!

rocky canyon
#

if not and u still want to assign it via the inspctor use [SerializedField] private

cunning locust
#

On a different topic, im learning about coroutines and i dont see the difference between them and functions..

StartCoroutine(ExecuteSomething());

IEnumerator ExecuteSomething()
{
    yield return new WaitForSeconds(2f);
    print("Executed.");
}
rocky canyon
#

well for starters you can't Wait in a regular function

#

so that code would never work in a regular function

cunning locust
#

I see, alright, is there more to it?

queen adder
#

since my game manager and kill block scripts are both in parts, i can get the Game manager script from finding its path?
and how would i find this path?

rocky canyon
#

i only use them for Delays.. but theres alot more to them

cunning locust
#

it's kinda weird that you can't wait outside the coroutine.

cunning locust
#

Hmm so what about structs and arrays?

#

can I make a custom Wait() function by passing in a function as a parameter of a coroutine?

#
IEnumerator ExecuteSomething( int func, int time)
{
    yield return new WaitForSeconds(time);
    func();
}
rocky canyon
#

u can use a coroutine just like a function in the sense of passing in variables yea

#

yea u can do that, not sure about the func() part.. but i know u can pass in ints and stuff

wintry quarry
#

but func would need to be a delegate type

#

for example Action

queen adder
cunning locust
#

Yeah im particuraly interested in passing a function as an argument

scarlet skiff
#

if an animaiton has "loop" ticket off and has finished playing/is at last frame, would this method still return true?

rocky canyon
#

punctuation matters

queen adder
rocky canyon
#

u still need a reference to that tho.. u cant just type out the name's

cunning locust
rocky canyon
#

same as u did earlier.. u pass it into a variable.. but if ur gonna do that why wouldnt u just pass in the GameManager directly

wintry quarry
queen adder
#

like that?

wintry quarry
rocky canyon
wintry quarry
#

System.Action aka Action is a delegate type that returns void and takes no parameters

rocky canyon
#

if u call just GetComponent<> thats where its looking

#

ont eh same object

queen adder
#

do i need to do gameObject.Parent?

#

it that a thing?

rocky canyon
#

.parent is a thing yes

cunning locust
#

I thought i could just pass an array as an argument

#

to do the same

#

but i realised I can't even get arrays to work in c# 💀

#
 Array arr = [ 1, 2 ,3]

  struct struc {1 , 2 }
eternal needle
#

Well yea that's not the syntax, google it. It's all there on the docs

languid spire
#

that aint even close to c#

wintry quarry
#

I don't see how an array would do the same as a delegate though

cunning locust
languid spire
#

not even close

wintry quarry
#

Are you a Python user by chance?

north kiln
#

The collection initialiser may make confuse things if you looked it up

#

The array initialisation is honestly almost correct in modern c#

cunning locust
wintry quarry
#

it's almost correct except that the type is wrong

queen adder
#

i did this

cunning locust
#
public struct struc
{
  int i = 1;
}
eternal needle
#

Apparently gamemaker is like javascript and c? I was assuming C from how you tried to declare the struct

mild osprey
#

guys, how do I get the rb.velocity.magnitude in 3D? I was used to get this value on 2D but it is not working on 3D

queen adder
#

but i cant drag the gameObject to the script

meager steeple
#

would it be possible to include time.deltatime into this? or would it still run equally no matter the performance?

rancid tinsel
#

!code

eternal falconBOT
rancid tinsel
#

@grizzled pagoda

north kiln
hexed ginkgo
meager steeple
#

👍

hexed ginkgo
#

Mathf.Sin(Time.time)

eternal needle
cunning locust
mild osprey
#

but is returning zero

eternal needle
#

Then the value is 0

mild osprey
#

the obj is moving

north kiln
#

You don't need to abs a magnitude, it's always positive.

polar acorn
grizzled pagoda
mild osprey
#

I'm moving the transform

polar acorn
mild osprey
#

the rigidbody does not count this way?

polar acorn
#

you're teleporting

#

The velocity is 0

mild osprey
#

oh, that's the problem

north kiln
#

Also, please don't cross-post

mild osprey
#

I just wanted to quickly animate a little guy here

#

I will try to use a boolean then

queen adder
rocky canyon
#

sounds like ur getting it

calm coral
#

Hey I have this error when trying to build my game, no issues when running in edit mode

#

What does it mean it has a different serialization layout?

rare basin
#

that isn't a error when building a game

#

but more like error from builded game

calm coral
rare basin
#

what is Card

calm coral
rare basin
#

well, as the pre-prorocesor directive saying

#

anything under Auxiliary will work only in the editor

calm coral
# rare basin

Yeah, I just added it, was having this error without this if as well

rare basin
#

yea cuz it's something related to the editor

calm coral
rare basin
#

some kind of asset, i dint know what it is

rare basin
calm coral
rare basin
#

you cannot use this in build xd

calm coral
#

I can even delete this Auxiliary class completely and try bulding my game again

rare basin
#

then do it

calm coral
wintry quarry
#

what is Auxiliary?

calm coral
wintry quarry
#

Where are things like displayName and username coming from?

calm coral
wintry quarry
#

Can you show the full Card script?

#

In a paste site?

calm coral
wintry quarry
#

I can't download files on this computer

#

it's a work computer

#

Discord truncates it

calm coral
wintry quarry
#

It doesn't show all

eternal needle
wintry quarry
eternal needle
#

and forget mobile, who just sees "download attachment" and thats all

short hazel
#

Just hit the arrows aside? Shows all

#

But yes mobile can't see those

calm coral
wintry quarry
#

Anyway I want to see the Card script

calm coral
#

Aight, hold on

eternal needle
calm coral
#

!code

eternal falconBOT
wintry quarry
calm coral
wintry quarry
#

Try restarting the editor maybe? I'm not immediately seeing any issue

cosmic dagger
calm coral
#

Maybe should I get rid of [SerializeField] attributes? Will that solve the issue?

polar acorn
#

You're using Visual Studio, right? or VSCode?

tender breach
#

Yeah

short hazel
#

Horrendous code style btw

frosty hound
polar acorn
frosty hound
#

You're not going to post code here if you're going to continue to refuse to format.

#

Your post is deleted until you do so.

covert wyvern
#

I'm trying to create an interaction with my player and NPC capsule but no output in the console to show I touched the capsule.


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

public class PlayerInteract : MonoBehaviour
{

    private void Update() {
        if (Input.GetKeyDown(KeyCode.E)) {
            float interactRange = 5f;
            Collider[] colliderArray = Physics.OverlapSphere(transform.position, interactRange);
            foreach (Collider collider in colliderArray) {
                Debug.Log(collider);
            }
        }
    }
}

rich adder
eternal needle
covert wyvern
#

Right, debug is not printing and the code is placed onto my player

wintry quarry
rich adder
#

full scene view no crop pls

short hazel
#

Or the code is running but you're not pressing E

rich adder
#

is your keyboard even plugged in?

covert wyvern
#

Nvm, I got the code working. Second time it's happen where i had to restart Unity

#

Maybe it reverted to different save and it fixed it. idk.

candid gorge
#
{
    _isGrounded = Physics.Raycast(groundCheck.position, Vector3.down, 0.05f, _groundLayerMask);

    Vector2 moveDir = _moveAction.ReadValue<Vector2>();
    Vector3 vel = _rigidBody.velocity;
    vel.x = moveDir.x;
    vel.z = moveDir.y;
    Vector3 a = transform.right * vel.x;
    Vector3 b = transform.forward * vel.z;
    Vector3 c = new Vector3(0f, 1/100000000, 0f);
    _rigidBody.velocity = (a + b + c) * speed;
    //_rigidBody.velocity = vel;

private void OnJump(InputAction.CallbackContext context)
{
    if(_isGrounded)
        _rigidBody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}

Hey guys, could someone help me real quick? I'm trying to make a fps character controller but I can't manage to get the jump and movement to work together.
If I use the velocity that is commented out the player can jump but his movement doesnt follow the camera's direction, and if I use the line on top, the player moves fine but doesnt jump

rocky canyon
rich adder
candid gorge
north kiln
#

1/100000000 is 0 btw; you are using integer division

covert wyvern
#

Actually it wasn't restart. My E key got stuck. I realised this after changing the key in the code to different letter. I need to clean my keyboard XD

north kiln
#

you also never seem to keep the y velocity, and just discard vel.y

covert wyvern
#

Thank you for help!

rich adder
candid gorge
rich adder
#

if you wanna jump with velocity you have to well, assign y velocity

rare basin
#

Well AddForce modifies the velocity

rich adder
#

it does but if you force velocity directly it barely does anything, only 1 frame cause of impulse prob

#

hence the tiny hop in vid

candid gorge
#

i see

#

do you have any suggestion on how could I approach it? I'm trying another thing rn imma see if it works

rich adder
#

are you set on building your own controller?

#

there are also premade ones like KCC or the unity regular CC

candid gorge
#

i was just trying to build it my self because I didnt find any that workds properly on the asset store

rich adder
#

in what sense ?

candid gorge
#

I downloaded a few from there and there was editor errors

#

so I just tried to make one myself

rich adder
#

the unity one is good to start with and easy to extend, if you want a solid one premade with features use the Kinematic CC.
guaranteed those have no errors lol

calm coral
#

Why do I have this error

#

It's not even related to any of my scripts

rich adder
calm coral
candid gorge
#

im going to try it then

rich adder
#

or reset layout

candid gorge
rich adder
#

seems the window took a poo

candid gorge
#

I'm going to try the KCC

rich adder
grizzled pagoda
slender nymph
#

you call SpawnZombie every frame for a quarter of a second

north kiln
#

and only increment the counter after a delay

candid gorge
#

what's up with the reloading domain thing taking 15 mins to load

rich adder
grizzled pagoda
#

Yeah

#

For now I only have one zombie in it tho

rocky canyon
#

whats the +

#

is this version control?

rich adder
#

seems to be , I dont have it 😮

rocky canyon
#

when domain reloading gets super slow good to restart the machine (even) and it'll speed back up

rich adder
#

also if it is or getting progressevily worse might be worth deleting and rebuilding library

rocky canyon
#

^ this too.. but usually a good restart will help ya out..

#

library getting full of nonsense

rich adder
#

yeah lots of cache xD

#

I could be wrong but feels like , even when the assets are no longer there or packages the cache still present from b4

rocky canyon
#

ya i should follow my own advice

#

i got a 40 second playmode

rich adder
#

Playmode without Domain Reload is amazing

#

its how the engine Should be by default imo

rocky canyon
#

ya, but u have to remember to manually trigger it

rich adder
#

but static ruins it ig

rocky canyon
#

right?

rich adder
#

nah thats Compiling Script or w/e is called iirc

#

I mean compile

#

nvm

rocky canyon
#

lol okay, i was confused there a minute 😄

rich adder
#

yeah can't do much about the speed for that

#

asemdef ig

rocky canyon
#

just updated my Hub, Yay!

#

its been a while

rich adder
#

soo much clutter now

rocky canyon
#

ohh snap

rocky canyon
rich adder
#

every other table like UI has disable/enabling columns, Wtf is up with this bs

eternal needle
rocky canyon
#

i didnt even read it, im guessing they arent lying

#

¯_(ツ)_/¯

rich adder
#

gotta remake that money back somehow for buying out Plastic

rocky canyon
#

also this cloud stuff now

#

not sure thats just for version control, or if we can store our projects in the cloud now

#

that'd be a SSD saver for real

rich adder
#

also when you make a new project you have to like select an account which is annoying when you have 3 for example

#

why no permanent option

#

they have monkeys designing this hub fr

eternal needle
#

basically, just use git. its always better

rocky canyon
#

ya, the only problem i have with git is understanding the LFS

rich adder
#

you just enable it, anything else is normal from there

rocky canyon
#

i think thats the abbreviation, but ive had one project break my repo, b/c it had lots of audio files

#

not sure how or what i did

#

but i would get some weird error it would get stuck on 99%

rich adder
#

are you using a GUI or commandline

rocky canyon
#

Fork

#

to do the LFS setup i think u have to use the terminal

#

i had to look it up everytime

eternal needle
#

you dont even need to understand it, you can get away with just sharing the files through other means. Unless you have assets that are really up there in the GB

rich adder
#

iirc its the best way yea through CLI

rocky canyon
#

the old one wont allow me to change anything on it

eternal needle
#

audio files individually shouldnt be that large

rocky canyon
#

it gets hung up on 99%, if i get around to it ill try to read what it was

rich adder
#

how big are these audio files individually
🤔

rocky canyon
#

b/c the way i understand it its big single files

#

is what cant be over 100mb

rocky canyon
#

not any over 5mb i bet

rich adder
#

tru

#

wave could be pretty large though ngl

rocky canyon
#

OR it possibly could be a PSD thats hidden in there

rich adder
#

they are uncompressed

rocky canyon
#

but i dont think any of those are over 100mb either

rich adder
#

hmm it usually tell you which file failed

stuck palm
#

is there a scriptableobject equivalent of getcomponent?

#

like can i get an array of all SOs of type level for example

slender nymph
#

what exactly are you expecting that to do? SOs are not attached to any other objects

stuck palm
#

im storing my level data in scriptable objects and i just wanna grab all the SOs and put them in a list

slender nymph
#

just drag them into a serialized list in the inspector

#

otherwise you could put them into a Resources folder and use Resources.Load or addressables or something

wanton canyon
#

trying to look at tutorials for randomly generated 3D terrain but I noticed every tutorial I look at creates a new mesh instead of using Unitys' built in terrain features. Is there an explanation for this? I'm worried about creating my own mesh because of the work that would entail going forward (creating UVs, randomly placed vegetation, etc) that are simple to use with Unitys' built in terrain features.

rocky canyon
#

found the error

rich adder
#

thats weird, no logs?

rocky canyon
#

im pretty sure its still broken b/c i have zipped files of this repo now on my HD

#

thats all i would get.. it would hang up on 99% and that same fatal error

rich adder
#

have you tried GitHub Desktop , for a GUI its pretty decent

#

no tree/timeline view though 😦

rocky canyon
#

i used to use Github Desktop but fork is really good

#

its only this repo thats broken

#

and i thought it was all the audio.. fun fact i finally got it updated by pushing every folder individually

rich adder
#

I bet there is a log somewhere with more info

rocky canyon
#

yea, this was dated last year.. i'll try to push it again later for shits and giggles

rocky canyon
rich adder
#

You can with heightmaps and all that

wanton canyon
rich adder
#

but I bet generating your own mesh is ofc always more flexible and you can cut it in chunks for performance

rocky canyon
rich adder
rocky canyon
#

doesnt unity allow u to use heightmaps with their terrain component?

#

might be a way to do it

rocky canyon
#

b/c i really dont understand how it works

#

i kinda just copied it 😄

rich adder
#

oh haha still nice to use in stuff other then open world

#

i bet for static map gameplay would be nice

rocky canyon
#

ircc it was getting good colliders on it

#

the reason i stopped

rich adder
#

aren't those just meshes? so like mesh collider no?

#

prob kill perfomance tho

#

unless its static prob gets as one big mesh

#

idk how that works with runtime gen tho

stuck palm
#

how do you change scriptable objects data when you load?

#

wait

rare basin
#

What

rich adder
stuck palm
#

levels is a scriptable gameobject

rare basin
#

Unless you know what you are doing

#

But i doubt it

#

Since you ask such thing

#

Don't use SO for saving system

#

That is not a way to go

stuck palm
#

im just using it cus it makes it easier for me to set level data on the fly

rich adder
#

jesus store your path in a variable at least

rare basin
#

Don't ever use SO for save&load system

rich adder
#

think of it like a static class/vars

rocky canyon
#

i mean, if ur using JSON u could just make a class/struct

stuck palm
#

😭

rare basin
#

Initial stats should only be there

#

Not the player statistics/score

stuck palm
#

ohhhh

#

so like

#

save the player stuff in just a normal class?

rare basin
#

Yes for example

#

Don't ever use SO for saving things

#

Make a mono behaviour

queen adder
rare basin
#

Like Dictionary<Level, LevelSavedStatistics>

rich adder
#

it can just be a regular class

#

no need for mono

rare basin
#

Then you can map each statistics to each level

stuck palm
rare basin
#

Even better if you make the dictionary serializable

stuck palm
#

yeah i be doing that with json stuff i think

#

i have an idea on what to do now

#

thanks

cosmic dagger
rich adder
#

no need to encapsulate the whole class

queen adder
rich adder
#

with the ifeditor

queen adder
#

editor folder and monobehaviour are quite not friendly with each other

timber tide
#

can just compile it out too be using one of those directives

rich adder
#

if its on gameobject unity serialized it and it expects it to be there

#

but you put #if editor on the whole class

queen adder
cosmic dagger
queen adder
#

that looks ugly, but ig better

rocky canyon
#

the scene camera isnt the same thing s the game camera is it?
Im using a render feature for outlines and they're displayed in the gameview but not the sceneview,
its not a big issue or problem, im just being curious

rich adder
# queen adder hmm turnin it into an empty class if!Editor?
    #if UNITY_EDITOR
using UnityEditor;
    #endif
using UnityEngine;

[ExecuteInEditMode]
public class DisconnectPrefab : MonoBehaviour
{
    public string RenameTo;
#if UNITY_EDITOR
    void Update()
    {
        gameObject.name = RenameTo;

        if (PrefabUtility.GetPrefabType(gameObject) == PrefabType.PrefabInstance)
            PrefabUtility.DisconnectPrefabInstance(this.gameObject);
        DestroyImmediate(this);

    }
#endif
}```
#

or just the whole update method

queen adder
#

hmm, even if i dont need the whole file?

rich adder
#

then dont put it on a gameobject

#

unity expects it there

#

that's why serialization error, dont match

queen adder
#

did it, it feels itchy that there's no better way for it though 🥹

stuck palm
#

if i have a dictionary and try and add to the same key twice, does it override they value for the key?

turbid path
#

Intellisense worked yesterday in vscode, but today it's not. Also, when I type [ctrl + shift +p] >omnisharp no commands for omnisharp pops up and no omnisharp logs are present. My dotnet version is 6.0.412. I installed the latest mac mono version, tried regenerating unity project files, setting omnisharp.useModernNet to false, and uninstalled and reinstalled c# and unity extensions.
Any ideas? My C# log:

Using dotnet configured on PATH
Dotnet path: /usr/local/share/dotnet/dotnet
Activating C# + C# Dev Kit + C# IntelliCode...
waiting for named pipe information from server...
[stdout] {"pipeName":"/var/folders/m6/kv19br757x316_pn4twdxn7h0000gn/T/451100eb.sock"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info  - 3:35:33 PM] [Program] Language server initialized
rich adder
cosmic dagger
queen adder
#

helpful for buttons

rocky canyon
#

that'll be sufficient

rich adder
potent garnet
#

Does anyone know why I keep getting this error? "Assets/Resources/Scripts/Utility/AudioManager.cs(45,11): error CS1061: 'Sound' does not contain a definition for 'source' and no accessible extension method 'source' accepting a first argument of type 'Sound' could be found (are you missing a using directive or an assembly reference?)"

queen adder
rich adder
#

so it just materializes the prefab object basically

#

gotcha

potent garnet
#

my good btw

potent garnet
rocky canyon
#

how do you assign source?

#

if its hidden in the inspector how have you assigned it to a valid audiosource?

potent garnet
#

I assigned source in the other script, in the foreach loop

queen adder
#

why would this not change the animation curve value?

#

just for extra info, here is the debug, you can clearly see there is a weight value

cosmic dagger
potent garnet
#

the errors got removed

rocky canyon
#

i have no clue why

potent garnet
#

yea i have no idea why either

rocky canyon
#
using UnityEngine;
public class AudioManager : MonoBehaviour
{
    public static AudioManager Instance { get; private set; }
    private AudioSource audioSource;

    private void Awake()
    {
        if(Instance != null && Instance != this)
        {
            Destroy(this);
        }
        else
        {
            Instance = this;
            audioSource = GetComponent<AudioSource>();
            DontDestroyOnLoad(gameObject);
        }
    }

    // Play a single audio clip
    public void PlayClip(AudioClip clip,float volume = 1f)
    {
        audioSource.volume = volume;
        audioSource.PlayOneShot(clip);
    }
}```
potent garnet
#

thought it would jsut hide it in the inspector, i wanted it public so other scripts could access it easily but I didn't want it to be accessed from the inspector

rocky canyon
#

heres my audiomanager.. i just pass in a clip and a volume and play it. ive never seen a class called Sound like u have, interesting to me lol

rocky canyon
#

i use NaughtyAttributes and the ReadOnly attribute

potent garnet
#

oh

#

I didn't know that

#

thanks

rocky canyon
#

it helps sometimes esp when debugging

cosmic dagger
#

I like using a ReadOnly attribute as well. It's good to have . . .

cosmic dagger
#

An SO is even better . . .

rocky canyon
grizzled pagoda
eternal needle
grizzled pagoda
rocky canyon
#

im not very familiar with the HideInInspector attrib but i dont understand why it would say sound doesnt have a source when it appears it does

#

and then work when its removed

rich adder
# grizzled pagoda How would those help btw

But regardless when you remove the item cal method on spawned that sets the spawneras references . When you destroy an enemy you cal method on spawner/counter to remove entry from list