#💻┃code-beginner

1 messages · Page 458 of 1

dry tendon
#

Then just drag it to your character... Nothing else

steep rose
#

Keep in mind you need to calculate friction forces or else your character will slide

dry tendon
#

And change friction on inspector

regal bear
marble hemlock
#

nothing is wrong with the code but its been saying scalar calculations are faster than vector calculations?

#

is that... necessary?

dry tendon
slender nymph
dry tendon
marble hemlock
#

i dont really understand what its referring to

#

the scalar calculations i mean. i'm not sure how i'd do that.

regal bear
slender nymph
#

instead of doing something like Vector3.one * speed * Time.deltaTime it's saying to do Vector3.one * (speed * Time.deltaTime) (this is just example code, not what you should be replacing your code with)

regal bear
#

i used some code from ChatGPT.

slender nymph
# slender nymph instead of doing something like `Vector3.one * speed * Time.deltaTime` it's sayi...

this results in fewer multiplication operations since multiplying a Vector3 results in 3 operations. so Vector3.one * speed * Time.deltaTime would break down to Vector3.one * speed which is 3 operations, then the result of that * Time.deltaTime which is 3 more operations for a total of 6 multiplication operations.
Vector3.one * (speed * Time.deltaTime) breaks down to Vector3.one multiplied by the result of the second set of multiplications so a grand total of 4 multiplication operations

dry tendon
dry tendon
marble hemlock
#

tryna wrap my brain around this a bit

slender nymph
#

remember that a Vector3 is 3 floats. when you multiply a Vector3 by a float it results in (x * scalar, y * scalar, z * scalar). it does that for each multiplication. so instead of multiplying your Vector3 by two separate floats (the scalars) which results in doing that operation twice meaning 6 total multiplication operations, you multiply all of your scalars together then mulitply the Vector3 by the scalar. resulting in fewer multiplication operations.
remember that multiplication is commutative so it doesn't matter what order you do the multiplications in, it ends up with the exact same result either way

marble hemlock
#

OH

slender nymph
#

so let's use some actual values with my previous example. Vector3.one is obviously (1, 1, 1), we'll call speed 2, and Time.deltaTime can be 0.02.
so Vector3.one * speed * Time.deltaTime is (1 * 2 * 0.02, 1 * 2 * 0.02, 1 * 2 * 0.02)
Vector3.one * (speed * Time.deltaTime) simplifies to Vector3.one * 0.04 which is (1 * 0.04, 1 * 0.04, 1 * 0.04)

marble hemlock
#

wait my brain is trying to catch up now
so for each thing vector 3 has to multiply by, it multiplies all the axis by those values, so speed and Time.Deltatime are things it has to do separately

slender nymph
#

Yes

marble hemlock
#

and then putting the parenthesis around the others will tell it to solve that first, and then multiply that (almost final) value to the Vector3

slender nymph
#

yes

marble hemlock
#

thank you

stone pilot
summer stump
stone pilot
#

I have one But the problem is what do I have to set the friction value ?

#

I've set it to 0.1

summer stump
#

.1 is very low

#

If you want more, increase it

stone pilot
#

Alright

summer stump
#

Also, you can add physics materials to the ground as well

#

Or set the friction mode to max or something

stone pilot
#

I've set to 1000 and still not workin , I'll try addin one on the ground

#

still not workin...

summer stump
#

Then likely a movement code problem

stone pilot
stone pilot
#

I fixed it, I just increased the angular drag

sullen perch
#

am trying to bake my mesh but i csnt click on navigation pls help

languid spire
sullen perch
#

wdum?

languid spire
sullen perch
#

ok

languid spire
sullen perch
#

i dont have a ai option

languid spire
#

Did you install the AI Navigation package?

sullen perch
#

how do i do that?

languid spire
#

package manager

mint remnant
#

is there like an event that fires whe a Grid Layout Group has completed adjusted items inside it?

sullen perch
#

i still cant select it

#

i think i need to import nav mesh components but i dont know how to

steel stirrup
mint remnant
steel stirrup
sullen perch
#

ye but i also need to download a navmesh component for the tutorial im following but idk how to do it, its from github

languid spire
#

This packages replaces the old Nav Mesh Components system

steel stirrup
mint remnant
# steel stirrup show code for how you're moving it, because this is definitely not the way to so...
        float scroll = Input.GetAxis("Mouse ScrollWheel");
        if (scroll != 0)
        {
            if (scroll > 0)
                slotIndex--;
            if (scroll < 0)
                slotIndex++;

            if (slotIndex > itemSlots.Length - 1)
                slotIndex = 0;
            if (slotIndex < 0)
                slotIndex = itemSlots.Length - 1;

            highLighter.position = itemSlots [slotIndex].icon.transform.position;
            player.selectedBlock = itemSlots [slotIndex].itemID;
        }
```https://gyazo.com/0e63805c99abb0798f102c46001c4c95
sullen perch
#

ok

dry tendon
sullen perch
#

but i still can use navigation

mint remnant
#

oh forgot to mention that chunk of code is in Update

steel stirrup
steel stirrup
dry tendon
mint remnant
steel stirrup
mint remnant
steel stirrup
#

oh, it's just your rect tranform not being set up right

mint remnant
#

public RectTransform highLighter;

steel stirrup
#

no in the actual inspector

#

you're not setting up your anchors to keep it where you want

steel stirrup
#

so when the canvas changes size it wanders off

steel stirrup
mint remnant
#

well I kinda was just putting it anywhere and moving it to the right place via code

steel stirrup
#

but dont be surprised when 'anywhere' is not the right spot to start

mint remnant
#

ok I might try over there then, I'm admittadly pretty newbish on UI

steel stirrup
mint remnant
steel stirrup
umbral rock
#

Learning what Mathf.Atan2 does and is, i wonder if u could write this as Mathf.Atan2(relative.z, relative.x) * Mathf.Rad2Deg;
if it would do the same and have the same outcome as they write it in the picture?

pallid nymph
#

swapping x and z would give a different result, if that's the question

umbral rock
#

why? he calculates the angle between x and z right? thats the same as calculating it between z and x?

cedar bone
#

How would I get the rotation for one vector3 to look at anther vector3?

#

cause im trying to instantiate a projectile to go towards where the player is looking.

raw token
umbral rock
night raptor
umbral rock
#

so x is always 1? or?

#

i dont quite understand the math behind it lol

#

i know it calculates angles

#

but i dont understand why u couldnt switch the z and x in this picture

raw token
umbral rock
#

the 1,2 is the 1 the x axis and the 2 the y? or the z?

cedar bone
#

I don't want my bullets to go through thin walls, but I don't want it to use rigidbodies cause of lag. How would I make it constantly go forward?

cedar bone
# languid spire lerp

but If I make it run every frame, and in between frames it goes through walls. How would lerp help?

raw token
# umbral rock the 1,2 is the 1 the x axis and the 2 the y? or the z?

In 1,2 - 1 is the horizontal coordinate and 2 is the vertical (I just wrote it in that order out of habit)...

Mathf.Atan2() takes the vertical then the horizontal as arguments. But which components of a vector which you pass in might change depending on what you're doing - Atan2 works on a two-dimensional plane, but that plane can be anything

night raptor
cedar bone
#

also if I set my rb to kinematic is there even any lag?

umbral rock
night raptor
cedar bone
#

its bullets

#

so for smthing like an AR

#

im guessing it would

night raptor
tall lodge
#

Have you tested it to see if it causes lag before trying to come up with an alternative? In my experience, any performance issues with bullets comes from not pooling them

cedar bone
night raptor
languid spire
cedar bone
#

to be honest i havent really noticed a difference

#

but thats y i was asking here

raw token
# umbral rock thats what i mean, in the code above i need to check the angle between z and x c...

There's no such thing as "the angle between the z and x coordinates..." Coordinates define a single point. Atan2 retrieves the angle from the positive horizontal axis to the point.

By passing x, z in, you're treating the x-axis as the vertical and the z-axis as the horizontal... So you're retrieving the angle from the positive z-axis to that point. In the code you've posted, it's "the angle from this object's transform.forward to the target"

#

That order gives you an angle on the x/z plane, measured from the positive z axis

umbral rock
#

what would happen then if u switch them? u rotate to the wrong angle?

raw token
#

But maybe try it and see?

umbral rock
#

well, my brain isnt braining anymore by now lol

#

that is such a hard thing to understand

keen needle
#

This should shoot straight right? For some reason shoot at a 45º angle

#

I have tried both

languid spire
#

whats wrong with

shotpoint.forward * speed;
keen needle
#

not working

languid spire
#

not a very helpful reply

keen needle
#

shotpoint rotation is 0,0,0

#

and bullet prefab same

#

Keep shooting at a 45º angle

frank flare
#

how can I spawn something through script from assets on a spawner object?

umbral rock
#

with the atan2 function, is the x axis always 0 and the opposite 270 or -90?

frank flare
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnItems : MonoBehaviour
{
    public GameObject itemToSpawn;
    public GameObject spawner;
    public GameObject Items;
    float lastSpawnTime;
    void Awake()
    {
        lastSpawnTime = Time.time + 5;
        Debug.Log(lastSpawnTime);
    }

    void Update()
    {
        if (Input.GetKeyUp("h") && Time.time - lastSpawnTime > 5)
        {
            Debug.Log("Key was just pressed");
            lastSpawnTime = Time.time;

            if (itemToSpawn.name != "Shit")
            {
            Instantiate(itemToSpawn, Items.transform);
            }
            else if (itemToSpawn.name != "Shit")
            {
                Instantiate(itemToSpawn, Items.transform);
            }
                
        }
    }

    /*void FixedUpdate()
    {
        if (Time.time - lastSpawnTime > 5)
        {
            Debug.Log(lastSpawnTime);
            lastSpawnTime = Time.time;
            Debug.Log(lastSpawnTime);
        }
    }*/
}

how can I spawn 3 times with a delay of 0.5 seconds if the itemToSpawn is Shit?

#

do I have to create coroutine or what?

wintry quarry
lost basin
#

I have a problem with my seed. I have made it so that the seed is the same as a random number I'm generating, but the map does not change with the new number, only when I edit it manually in the editor. The seed that's currently generated is actually 8.

lost basin
languid spire
frank flare
wintry quarry
frank flare
tall lodge
wintry quarry
#

Do what? Which part?

lost basin
languid spire
lost basin
#

Okok, I have to completely honest, I do not know how to change that🥲

languid spire
#

is it a public variable?

lost basin
#

It is a public int

languid spire
#

so change it to private or, if it needs to be public, change it to a property

lost basin
#

Okok I'll try that, thank you

frank flare
# tall lodge https://docs.unity3d.com/Manual/Coroutines.html
Debug.Log("Key was just pressed");
            lastSpawnTime = Time.time;

            GameObject spawnedObject;
            if (itemToSpawn.name != "Shit")
            {
                spawnedObject = Instantiate(itemToSpawn, Items.transform);
                spawnedObject.transform.position = spawner.transform.position;
            }
            else if (itemToSpawn.name == "Shit")
            {
                IEnumerator Fade()
                {
                    for (int i = 0; i == 3; i += 1)
                    {
                        spawnedObject = Instantiate(itemToSpawn, Items.transform);
                        spawnedObject.transform.position = spawner.transform.position;
                        yield return new WaitForSeconds(.5f);
                    }
                }
                Fade();
            }

I tried this way but it doesn't work

#

how?

#
else if (itemToSpawn.name == "Shit")
            {
                IEnumerator Fade()
                {
                    for (int i = 0; i > 3; i += 1)
                    {
                        spawnedObject = Instantiate(itemToSpawn, Items.transform);
                        spawnedObject.transform.position = spawner.transform.position;
                        yield return new WaitForSeconds(.5f);
                    }
                }
                StartCoroutine(Fade());
            }
#

idk

#

I have no other ideas now

lost basin
eternal falconBOT
lost basin
#

""cs

#

Ag gorrel

#

'''cs
public int Seed
{
set { seed = Mathf.CeilToInt(RandNum); ; }
}

#

MAN

#

I keep pressing ewnter too soonatwhatcost

#
public int Seed
    {
        set { seed = Mathf.CeilToInt(RandNum); ; }
    }
#

There we go

umbral rock
#

so if i understand this code correctly, the atan2() takes the input from the horizontal input and the vertical input then converts it into degrees and then the transform.rotation tells the object to rotate x degrees around the y axis, and the x degrees is the outcome u get from the atan2? is that right?

languid spire
#

so you still have your public int seed ?

lost basin
#

I would send the whole code but it's about 200 lines of code

languid spire
#

of course not, what you need is

public int seed
    {
        get { return Mathf.CeilToInt(RandNum); }   }
languid spire
lost basin
#

This is the whole script

languid spire
#

you do not need any of this

private int Seed
    {
        set { seed = Mathf.CeilToInt(RandNum); }
    }


    void Awake()
    {
        seed = Mathf.CeilToInt(RandNum);
    }

just do what I showed above

tall lodge
ripe oyster
#

i'm making a 2d platformer, but there are hundreds of tutorials to make one. been looking through some, but all are different.

is there a base which you guys advice to use? one with most of the basics (coyote time, input buffering etc.)

lost basin
rare shell
#

I don't know if this has been covered here before, but the free version of ChatGPT is very good at answering questions about coding in Unity. At least for simple questions. I think it would solve a lot of problems for newbies in this chat, instead of waiting for an answer or asking again and again.

silk night
#

for simple things maybe but you are better off not using chatgpt

#

it can straight up be malicious in what you are trying to do and when you dont have the knowledge to filter good from bad info yet its not a good idea

pearl garden
#

how do i make circlecast ignore a kayer

silk night
#

or make a layermask with only that layer and reverse it, then input it, easier if you add more layers

pearl garden
#

im kinda scared of doing that

silk night
#

whats scaring you? 😄

pearl garden
#

too many G.o

silk night
#

just do a public LayerMask, which lets you pick the layers in the inspector, then reverse it, i belive reversing a mask was mask = ~mask;

modest dust
umbral rock
#

i dont rly understand what atan2 is, i understand that its to calculate angles but first they say the arguments are (y, x) and then they say the arguments are (x,y)?

ripe oyster
silk night
eternal falconBOT
#

:teacher: Unity Learn ↗

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

frank flare
silk night
#

what is not working?

modest dust
frank flare
#

doesn't spawnedObject = Instantiate(itemToSpawn, Items.transform);
spawnedObject.transform.position = spawner.transform.position;

umbral rock
silk night
#

your exit condition is flipped

ripe oyster
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

lost basin
modest dust
#

If you're having a hard time visualizing something, it's always an option to just code it in and see by yourself how it works

umbral rock
modest dust
#

The y is your "y" relative to the plane you're working with

#

xy yz zx

umbral rock
#

okay

#

still dont understand it tbh

modest dust
#

Look at one wall in your room and then at the wall next to it

umbral rock
#

i thought if u look from above to your object u have the vertical and the horizontal and u set the direction.x = to that vertical line (y) and the z to (x) and then if u look straight ahead its 0° and if u go right u look 90°

modest dust
#

One would be in xy plane, the other in zy plane

modest dust
#

Unless you have walls at weird angles, but these are still 2D planes

umbral rock
#

indeed

umbral rock
modest dust
#

The short version is, as far as I'm aware: atan2(y, x) -> z rotation, atan2(y, z) -> x rotation, atan(z, x) -> y rotation

modest dust
#

Right axis is 0°

molten dock
#

Thanks

mint remnant
#

All Suckers Take Calc

#

(the acronym to remember)

umbral rock
modest dust
umbral rock
#

huh? right axis is 0? but in my tutorial he sets the y argument = the direction.x? and the top axis is 0° for him

umbral rock
verbal dome
fleet grotto
#

can someone help me setup vsc for unity it doesnt work for some reason

eternal falconBOT
modest dust
#

Basically image yourself aligning with one of the axis, so that you look in the same direction as the axis is pointing

umbral rock
#

i thought i understood the function but the more u explain the function the more chinese it gets for me lmao, its not that i dont know what atan2 is its how and what to give in the arguments, u have to pass in a (y,x) but i dont understand why my tutorial passes the direction.x and direction.z in it?? why would u do that? he also said atan2 sees the object from top down view and the u have a vertical line and a horizontal line, the vertical line is the y and the horizontal the x, that makes it easy for me to understand why u set the direction.x equal to the y argument because u want to go forward and by 0°...

frank flare
#

I'm using official unity asset character controller (using first person controller) why when I'm trying to slowly aim it's not aiming?

modest dust
frank flare
umbral rock
modest dust
frank flare
lost basin
umbral rock
modest dust
lost basin
mint remnant
umbral rock
modest dust
#

Don't think of y and x as the literal y and x axis in unity

#

Just relative to the plane you're looking at

umbral rock
#

oohh lol, its just 2 axis that u choose?

modest dust
#

Yes.

umbral rock
#

aahh so the y argument is not the y axis, its just like saying atan2(x1, x2) 2 axis?

modest dust
#

Yes

umbral rock
#

lol, i completely misunderstood :/

#

so the axis u put in the x is gonna have 0°? so in this case its z so forward is gonna be 0°

#

ig?

#

yes

modest dust
#

Pretty much

lost basin
umbral rock
#

oof, thank u very much, im pretty bad at maths and i rly need to improve it... thanks for the explanation lol

mint remnant
# lost basin Yes

Sebastion doesn't cover this in his tutorial, but the color map never lines up with the noise generation, it's due to the plane needing to be rotated about the Y axis 180 because the linear array is filled from 0,0 being in that upper right corner instead of the bottom left like the docs say it is

modest dust
mint remnant
#

sorry, corrected that, I meant Y axis

frank flare
swift canyon
#

Hi, really new here and in need of some help, currently I want to rotate my top half of my model to where my mouse is currently at, but for some reason the back of my model always follow the mouse not the front, and the model is not rotating properly either. I really need the help, and for those who will look at it thank you 🙂
Code for the mouse follow: https://pastebin.com/YFDVBcav
Note: already added an empty object to parent my top half of the model it did fix the issue where the model is facing up when rotating

frank flare
lost basin
#

Nvm it work

strong wren
#

was this

#

ChildScream = ChildScreams[randScream];

#

this is the line thats causing me trouble

#

it still lets me play and its an error that pops up only sometimes?

#
            ChildScream = ChildScreams[randScream];
            Child.clip = ChildScream;
            Child.Play();``` heres tghe thing that includes randscream
#

maybe itl help idk

languid spire
strong wren
#

it starts from 0

languid spire
#

yes, but if Length =0 array[0] does not exist

latent granite
#

Hi, i am kinda new to unity and i wanted to make a simple 2d shooter game to practice some things i learnt. i have a square with movement and jumping scripts and also interaction. but i wanna add a gun that follows the cursor but i dont really know much about rotation and cursor tracking

strong wren
#

so should i change the 0 to 1?

languid spire
strong wren
#

like if lenght = 0 then idk

languid spire
#

yes, how else ?

strong wren
#

but like what do i tell it to do then....

#

like yes if lenght = 0 then do specificly what?

languid spire
#

nothing

mint remnant
#

or print out the value just before accessing the array to at least see what it is trying to access

strong wren
languid spire
#

you can do if length > 0 // Do the code you have

mint remnant
#

maybe you filled hte array in playmode and restarted it and it went back to empty

strong wren
#

actually i think i found the issue

#

the array was somehow cleared?

#

i have 4 diff enemies and 1 of the enemies array had an empty array

#

yeș

#

sorry for wasting yalls time

#

thanks for the help tho

lost basin
#

where do I find this error so I can try and fix it, I know in what script, just which array should I be looking at

pliant sleet
#

can you help me with this camera setting ? I accidentally hit a button and now my camera movement is kind of odd so I want to revert it back but I don't know how.

mint remnant
#

double click it, should open the code at the error

lost basin
cosmic dagger
#

only one way to find out . . .

languid spire
mint remnant
latent granite
#

i wanted to make a simple 2d shooter game. i have a square with movement and jumping scripts and also interaction. but i wanna add a gun that follows the cursor but i dont really know much about rotation and cursor tracking.

lost basin
#

It works now thank you

frank flare
#

basically a 2d camera

pliant sleet
#

thank you

frank flare
#

np

frank flare
deft grail
latent granite
deft grail
frank flare
latent granite
deft grail
latent granite
deft grail
latent granite
#

can i use Vector3.RotateTowards?

lost basin
#

Why do the colours only render if I update the script manually?

mint remnant
#

Did you include his code for public override void OnInspectorGUI() ?

#

need to watch his videos end to end a few times, he covers tons of details in that series

umbral rock
#

im following a tutorial and i should be able to look left and right but i cant? anyone knows why

mint remnant
#

xRotation -= mouseY?

umbral rock
#

ye to rotate around the x axis

lost basin
#

found it

latent granite
lost basin
deft grail
latent granite
#

its rotating on all axis. ill try to lock rotation on the z axis

deft grail
ivory bobcat
#

Maybe consider showing the !code

eternal falconBOT
latent granite
ivory bobcat
#

Other than that, make sure the player variable has referenced the Player body object (not the camera) - assuming this component is on the camera.

mint remnant
latent granite
ivory bobcat
#

The main doc should have discussed this.. one sec.

mint remnant
ivory bobcat
# mint remnant it says this: This is frame-rate independent; you do not need to be concerned ab...

If the axis is mapped to the mouse, the value is different and will not be in the range of -1...1. Instead it'll be the current mouse delta multiplied by the axis sensitivity. Typically a positive value means the mouse is moving right/down and a negative value means the mouse is moving left/up.

This is frame-rate independent; you do not need to be concerned about varying frame-rates when using this value.

#

Get axis can be mapped to buttons or mouse. If it's mapped to the mouse, you do not need the delta variable because it's already a delta.

mint remnant
#

yes and then they do this
// Make it move 10 meters per second instead of 10 meters per frame...
translation *= Time.deltaTime;
rotation *= Time.deltaTime;

short hazel
#

The example binds WASD as axes, not the mouse

mint remnant
#

ah!

night raptor
#

The second example uses mouse and there's no deltaTime

ivory bobcat
#

Theirs was relative to buttons (horizontal and vertical)

mint remnant
#

interesting and confusing all at once lol

short hazel
#

The physical explanation is: you moved the mouse X centimeters over Y seconds. Whether at 60 FPS or 3 FPS this doesn't change, so it's framerate-independent!

#

This is also valid for the new input system IIRC, the mouse movement is also passed as a delta so no need to multiply by deltaTime

ivory bobcat
#

With the delta time removed from the equation, you should be getting more responsive results. If nothing is still happening, you've likely referenced the wrong object as the Player.

umbral rock
#

i have a weird bug with my camera when i move with my player (wasd) my camera spins around like crazy

ivory bobcat
#

Maybe consider showing the updated code

#

How to post !code
Use links for large code blocks or you can embed some statements here if they aren't too long/large using backticks.

eternal falconBOT
mint remnant
#

So I have these 2 lines
transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * Time.deltaTime * mouseSensitivityX);
verticalLookRotation += Input.GetAxis("Mouse Y") * Time.deltaTime * mouseSensitivityY;

And I tried taking out the Time.deltatime. Had to adjust mouseSEnsitivity to no avail and the camera goes nuts

minor dagger
#

Hello! My game is working perfectly fine in the editor NO errors NO bugs nothing but when i build the game some triggers are not working like they should be and an object is missing.

lost basin
#

Gindipple🤭
Would you mind helping me with the map not rendering, if you have any idea as to why It's not rendering when I start my game.

frank flare
#

can someone tell me how to randomize float?

mint remnant
#

Best if anyone available can help, sometimes others see things that someone else doesn't. But in general, show code and ask question. Sebastion's code is all on github, did you start with that or type it in as you watched the videos?

lost basin
frank flare
#

ok

frosty hound
#

Inb4 they copy that directly

lost basin
# frank flare ok

Just replace the min and max with what you want and put the name of your float in the first part

frosty hound
lost basin
mint remnant
#

He has 2 different things going on at once, one is the plane at editor time the other is the mesh at runtime. So which one isn't working for you?

lost basin
#

The mesh isn't working, Like in the video it's just black, even in the editor, until I click on generate, change the DrawMode, or Turn a bool off and on again.

mint remnant
lost basin
#

It should, but it don't. What script fo you think might be causing this? The MapDisplay?

frank flare
#

what is iterator in C#? idk what this word means

#

@cosmic quail google doesn't help

#

it just says something like

#

"iterator method"

#

but it doesn't say what's iterator

cosmic quail
frank flare
#

description doesn't really say much what makes sense

#

is GameObject iterator?

cosmic quail
cosmic quail
frank flare
cosmic quail
# frank flare this

should have posted this in the first place rather than asking what iterators are

frank flare
#

I'm trying to make GameObject spawnedObject; still keep the spawnedObject = Instantiate(itemToSpawn, Items.transform);

short hazel
#

"coroutines" use the C# iterator feature yes. You cannot use in, out, or ref with them

cosmic quail
#

why do you have a void inside a method

frank flare
#

using ref in coroutine isn't possible and I should just do it like that?

short hazel
#

That will not work as intended, re-assigning the variable inside a method won't update the variable outside that method, unless ref is used, which isn't possible here

#

Why do you need the instantiated object outside the method?

frank flare
#
void Update()
    {
        if (Input.GetKeyUp("h") && Time.time - lastSpawnTime > 4)
        {
            Debug.Log("Key was just pressed");
            lastSpawnTime = Time.time;

            GameObject spawnedObject;

            IEnumerator SpawnItem()
            {
                GameObject sigma;
                for (int i = 0; i < 3; i += 1)
                {
                    sigma = Instantiate(itemToSpawn, Items.transform);
                    sigma.transform.position = spawner.transform.position;
                    spawnedObject = sigma;
                    yield return new WaitForSeconds(.5f);
                }
            }
            
            if (itemToSpawn.name != "Shit")
            {
                spawnedObject = Instantiate(itemToSpawn, Items.transform);
                spawnedObject.transform.position = spawner.transform.position;
                //Vector3 direction = spawner.transform.position - (spawner.transform.position - spawnedObject.transform.position) * 800f;
                //Debug.Log(spawner.transform.position - direction);
                float randomX = Random.Range(-10f, 10f) / 10f;
                float randomZ = Random.Range(-10f, 10f) / 10f;
                spawnedObject.GetComponent<Rigidbody>().AddForce(new Vector3(randomX, -4, randomZ), ForceMode.Impulse);
            }
            else if (itemToSpawn.name == "Shit")
            {
                IEnumerator SpawnItem()
                {
                    for (int i = 0; i < 3; i += 1)
                    {
                        spawnedObject = Instantiate(itemToSpawn, Items.transform);
                        spawnedObject.transform.position = spawner.transform.position;
                        yield return new WaitForSeconds(.5f);
                    }
                }
                StartCoroutine(SpawnItem());
            }
                
        }
    }
#

because there's also other part

#

oh

#

I read it wrong

frank flare
short hazel
#

Why not?

frank flare
short hazel
# frank flare I don't know but it just seems to be more customizable

Nope, you can take the the if statements inside the coroutine instead, that will do the same thing.
Just make it so the yield instruction is still the last one within the loop, or else it'll add force with a 0.5 second delay.
Alternatively the part that adds force could be another script attached directly onto the prefab you Instantiate

frank flare
midnight meteor
#

Hello , how can i make it returns random numbers like 0.3 0.4124 0.921314 ? it only returns 1 or 0 although its float not int

short hazel
cosmic quail
short hazel
short hazel
#

Because you tell it to do so by using yield return new WaitForSeconds(0.5f)
Wait for 0.5 seconds at this point

frank flare
#

ah yes

short hazel
#

You need to understand the code you are writing/copying

midnight meteor
#

didnt think to do that

drowsy flare
#

I know how to instantiate a prefab when I reference it from GUI with a [SerializeField], but how do I reference a prefab from code if I dont wan't to do it from the GUI?

languid spire
marble hemlock
#

im not even sure what happened because i dont remember changing anything but now my entire movement script is failing

#

and it keeps giving me this message that scalar calculations are faster than vector calculations for 40 and 41. i thought i had a grasp on it but ig not

#

i noticed something was wrong when the character couldnt really move, and originally i thought the problem was specifically the WASD function of the script, but not even the gravity works now

#

so the entire script is the problem, but the script is active on the player object

#

it was working yesterday and now its just notlikethis

languid spire
#

why have you made no attempt to debug?

marble hemlock
#

it hasnt given me any errors

#

actually

#

sorry the script itself didnt give me any errors, but it kept saying that it was missing a reference

languid spire
#

Debugging is not about fixing errors, it's about seeing what your code actually does

languid spire
marble hemlock
#

that was an error on a button thing but im not sure its related

#

maybe its not the movement script thats the problem?

languid spire
#

if you debugged it like I said, you would know

marble hemlock
#

i mean i dont see anything that feels unusual

languid spire
#

I see one problem straight away, your usage of deltaTime

summer stump
languid spire
marble hemlock
#

nothing particularly stands out, i mean
i will try the debug.logs to see whats not turning on

#

oh i think i kind of have an idea

#

its not being used

#

sprint is giving a return but i must have removed the lines actually applying gravity and allowing movement

#

might just start the project over i think its just falling apart at this point

#

oh im fucking dense
the solution to the problem was right below the problem and i deleted the notlikethis

marble hemlock
#

okay got it up and running again 👍

drowsy flare
#

Anyone have a tutorial or general concept about an inventory system, where i can find items with attributes (ie "handgun", storyitem") and get their prefab?

mint remnant
#

there's only like 4-5 pages on google for the topic

winter tinsel
#

how can i lock the Z pos on an image ?

mint remnant
#

how is it being modified currently?

eternal needle
winter tinsel
drowsy flare
mint remnant
cosmic dagger
winter tinsel
#

its being modified via transform and being set to the input.mouseposition

mint remnant
mint remnant
#

subtracting it from the vextor3, hidng it from the next calc

#

as it implies, to mask is to hide

winter tinsel
#

do i do this in the transform.position = input.mouseposition?

mint remnant
#

you could on the fly creat a new vector3 and for hte x and y parts pass them along, for the z part just put in 0

rich adder
mint remnant
#

difficult to know for sure without your code

winter tinsel
rich adder
#

mousePosition is a screen coordinate / pixel position

winter tinsel
#

what happens is it modifies the z value and then

#

it becomes invisible ?

rich adder
#

oh if its UI its fine . and input mouse position doesn't have a z pos

mint remnant
#

so yea just force z part to 0 always

winter tinsel
rich adder
#

it's not mouseposition at least

winter tinsel
#

idle, if i try to drag it the z value gets sent to mars and when i let go everythings okay again

rich adder
#

The z component of the Vector3 is always 0.

winter tinsel
#

BUT it doesnt make it snap back into place

#

is the

pallid nymph
#

=> mars is at z=0

winter tinsel
#

transform.Setparent(transform.root)

rich adder
#

setting parent is what's messing up the z prob

#

maybe you want to pass true to KeepsWorldPos argument

winter tinsel
#

see thats the thing

#

in the tutorial im following all of this works right?

#

and im supposed to add

#

transform.SetAsLastChild();

rocky canyon
#

it probably wouldnt be a published tutorial if it doesnt work

winter tinsel
#

that makes it viible and on the top

#

of the hierarchy

rich adder
#

ohh could you link tutorial

winter tinsel
#

issue is that doesnt work

#

it doesnt make it visible

mint remnant
#

9 times out of 10 you missed some minor detail in hte turtorial

winter tinsel
#

i like the guy cause he explains what the code does

#

and form that i can see that i really do have everything, not 1:1 but its correct enough to work

rich adder
#

is this what ur trying to do or

mint remnant
#

where in your code do you do the line transform.SetLastSibling??

winter tinsel
winter tinsel
rich adder
winter tinsel
#

in the idle position

#

when not dragged and after dragged

#

it snaps back to where it should be right

#

but while dragging it just

#

dissapears?

winter tinsel
#

its.... there? but its not showing up

rich adder
#

looks like its outside the canvas maybe ?

winter tinsel
#

yeah uh for some reason

rich adder
#

show a screenshot of the inspector while you dragging it with hierarchy visible

rocky canyon
#

^ this plz

winter tinsel
#

wait lemme debug something

#

okay so yes it does leave canvas right

#

and i know now what code makes it do that

#

parentAfterDrag = transform.parent;
transform.SetParent(parentAfterDrag);

#

i dont know why

#

what happens

#

where it suspposed to be

#

it goes and becomes a part of the player?, which is at the top of the hierarchy ig

#

even his does that

#

yet it simply dissapears

#

if i remove all the code except transform.pos = input.mousepos then i can drag it fine but it wont snap into place when i let go

#

the code that controlls that is also the code that breaks everything...

#

the point of transform.SetAsLastChild is to counteract this, and make it visible but it doesnt do the job right

bleak sleet
#

Can someone help pls, I want that for int value I delete 1 Tkey

mint remnant
#

that's a strange group by predicate there

bleak sleet
languid spire
bleak sleet
languid spire
#

!code

eternal falconBOT
rich adder
#

root is going to go to the top most object

polar acorn
mint remnant
#

my thoughts exactly

winter tinsel
#

is that comparing a variable to itself?

bleak sleet
#

idk how groups work

mint remnant
#

apparently

polar acorn
#

What is this supposed to accomplish

bleak sleet
#

im trying to find out how many of a specific TKey are in the Dictionary

winter tinsel
bleak sleet
languid spire
#

there can be only one

rich adder
polar acorn
#

A dictionary can only have one of each key

#

so the answer of "how many of this TKey are in the dictionary" is either 0 or 1

bleak sleet
rich adder
#

what are you trying to do? what is the mechanic? what is this for ? etc..

polar acorn
bleak sleet
polar acorn
mint remnant
#

What's TKey?

rich adder
#

the type for Dict

bleak sleet
rich adder
#

but doesnt doesnt look like a dictionary

languid spire
#

TKey is the generic name for the type a key of a dictionary

winter tinsel
willow scroll
polar acorn
polar acorn
winter tinsel
rich adder
#

if its a dictionary why did you screenshot inspector of an array/list

winter tinsel
#

its a dictionary for what, goes to where and which one of the 2 elements are you looking for?

polar acorn
#

Dictionary<Foo, Bar> is referred to as a "Dictionary of Foo to Bar"

polar acorn
# bleak sleet ItemType Gameobject

Okay, so, Dictionary<ItemType, GameObject>. So, it maps an ItemType to a specific GameObject. What are you trying to actually do with this information right now?

rich adder
winter tinsel
#

like a inventory yk

bleak sleet
rich adder
winter tinsel
#

first, to get rid of confusion its not an ACTUAL function in the code

polar acorn
winter tinsel
#

whats putting it where its supposed to go is a grid component

rich adder
bleak sleet
winter tinsel
#

while dragging it goes to the root, ie the player

rich adder
winter tinsel
polar acorn
marble hemlock
#

uh i got an error but this time i actually didnt do anything

winter tinsel
marble hemlock
#

its not an error in VS but in unity's console

rich adder
ruby python
#

Hi all, I'm hoping someone can help with a little bit of code I'm having trouble with.

  newRecipeItemAvailable.text = 
    GameManager.gameManagerInstance.stationResourcesManager.availableComponentList
    [newBuildableItemRecipe.dataContainer.stationModuleRecipeList[i].componentAvailableIndex].componentAmount.ToString();

Full Code here
https://hastebin.com/share/gebafinuti.csharp

It's a little bit messy/simple at the moment.

Basically I have two lists of Classes (AvailableComponentList which keeps track of how many components the player has 'in Stock' (First Image) The Entries in this list are of the Class 'AvailableComponents'. This lives on my StationResourceManager script which is 'attached' to my GameManager.

public class AvailableComponents
{
    public string componentName;
    public int componentAmount;
}

and a 'StationModuleRecipeList' in which the entries are of the 'StationConstructionRecipe' Class which lives on the Scriptable Object for the specific module the player wants to build.

public class StationConstructionRecipe
{
    public string componentName;
    public int componentAmount;
    public int componentAvailableIndex;
}

I'm using the 'componentAvailableIndex' int to reference the specific Resource Manager list entry to then run a check to see if the player has enough of that resource to build the Module.

The problem I'm having lies in the line of code I've posted inline above. Everything up until that point works great, but it's seemingly not finding the 'componentAmount' list entry. So, would anyone be able to see any errors/issues in terms of finding said value in the way that I've written it above? Been staring at it for a while and just can't see an issue.

bleak sleet
winter tinsel
#

im naming it for organising

rich adder
polar acorn
#

If these don't help, ask better questions

winter tinsel
bleak sleet
marble hemlock
#

so it said "hey you dont have tmp pro stuff so we're going to import it" and it did
and its working, but now at line 525 its giving an error in the unity console that the object reference not set to an instance of the object

rich adder
marble hemlock
#

i just wanted to show the full page cuz its not my script

it just appeared with an error?

polar acorn
winter tinsel
#

should i just make it a canvas?

languid spire
marble hemlock
#

uh nvm
i delete the error and it doesnt seem to come back up

winter tinsel
#

or disconnect the whole Inventorycanvas thing from the player?

bleak sleet
winter tinsel
#

cause i put it in thinking i need it to be a child of the player or it wont work right but since its just ui over the full screen then i dont think it needs to be a child

rich adder
marble hemlock
#

i hope it doesnt come back to bite me

ruby python
rich adder
polar acorn
winter tinsel
#

i just removed it and made the whole inventory its own parent

polar acorn
#

So maybe get your shit together and figure out what you even want to happen. If you literally do not even know what you want how can you expect me to tell you how to do it

rich adder
marble hemlock
#

is there a way to have a button have an outline

marble hemlock
#

trying to link up this button to

rich adder
winter tinsel
#

and im a capitan thatll sail till i crash

marble hemlock
bleak sleet
#

this guy was giving me attitude first fr, attacking a newbie over very nice

rich adder
winter tinsel
#

with somali pirates

#

its kaptaejn but he pronounces it kapitan

rich adder
languid spire
#

you should know better than that

rich adder
#

oh shit you right let me delete that. forgot where i was for a second 😛

polar acorn
bleak sleet
winter tinsel
#

as a newbie we uh, we suck at coding lol so listen to what he says

#

but i do agree that he can come off as agressive in the way he talks

languid spire
bleak sleet
winter tinsel
#

not with the code, but in general

#

what is the idea you are trying to execute yk

polar acorn
winter tinsel
slender nymph
winter tinsel
winter tinsel
ruby python
#

tbh, I don't think Digi is aggressive at all, just right to the point without any dicking about. lol.

winter tinsel
#

what is your idea @bleak sleet ?

rich adder
winter tinsel
#

i say that as someone who is extremely direct, so its better to dilute the directness because otherwise it can come off as agressive

#

even though it might not really be, people can understand it in that way

rich adder
#

there is community rules about "perceived" tone

#

don't assume, its text after all..

ruby python
#

Clear explanations go a loooong way to getting useful help. That's why my questions tend to be on the long side, as much detail as possible about what you want to do and what the issue is. lol.

#

The most common 'useless' request for help is "why is this broken?" lol.

rich adder
#

I get called the "aggressive" or "with attitude" 90% of the time here

eternal needle
rich adder
#

apparently being direct is aggression on these new Zboyz

winter tinsel
winter tinsel
bleak sleet
# winter tinsel what is your idea <@661660368032104488> ?

Im trying to do crafting table and want to do it variable so that in future I can easily make something take 2 of specific Items but I have no idea how to check if theres those items inside and how to remove them properly. I keep getting error messages

rich adder
bleak sleet
frosty hound
#

It would help to share the errors?

rocky canyon
rich adder
#

You can get frustrated when your question doesnt make sense..

bleak sleet
#

its ok im gona try later by myself gtg w dog now

winter tinsel
#

furtstaed lol

#

looks like a german city name

#

furtstadt

marble hemlock
#

can you have a child object with a script tell its parent to no longer be active or can i only work downwards

drowsy flare
winter tinsel
rich adder
ruby python
winter tinsel
rich adder
#

its good to do it yourself if you plan on researching as you go
its not good if you expect to know it all out of gate.

winter tinsel
#

we

#

literally think, that youre tech wizards

rocky canyon
#

but that fixes itself w/ time

ruby python
marble hemlock
# rocky canyon ya, *once*

idk if this is overcomplicating it but im going to try to attach separate scripts to specific buttons (one will turn off the parent object), and then have the player have a script that allows them to turn it on/off.

#

idk if it'll work but i'll find out ig

rich adder
rocky canyon
#

as long as ur only turning it off (once it is disabled the script /child will not be able to turn on its parent (itself practically)

winter tinsel
rocky canyon
winter tinsel
#

tried to put 2 contradicting if statements

ruby python
winter tinsel
#

why is the code that wont work unless a nuke ray from a supernova explosion touches the one bit and changes it to 1...... not working?

rich adder
rocky canyon
#

if makes thing false.. else runs regardless lol

ruby python
marble hemlock
#

oh i just realized im working out of order notlikethis

#

i was trying to set up the buttons to work but i cant even test if the buttons work because i havent set it up to allow the mouse to freely move

rocky canyon
#
if (isActive)
{
    isActive = false; // This sets 'isActive' to false
}
else if (!isActive)
{
    Debug.Log("isActive is false now!"); // This will always run because 'isActive' was just set to false
}```
rich adder
#

or did i brain farted

rocky canyon
#

i think an else would actually work?

#

idk im still drinking my first cup of coffee ☕ ¯_(ツ)_/¯

rich adder
#

i think of else if like a switch case

#

if the first one was hit, the rest dont evaluate no?

rocky canyon
#
  • if statement: Checks the condition. If true, the code block executes, and then it skips the rest.
  • else if statement: Only checked if the previous if (or else if) was false. If true, its block executes, and the rest are skipped.
  • else statement: Executes only if none of the above conditions are true.
languid spire
marble hemlock
#

is it bad practice to attach debug.log to a bunch of stuff to constantly keep seeing if its registering things

#

even if nothing is broken yet

marble hemlock
#

noted
thank you 👍

languid snow
#

yo how do i store functions inside a list

rich adder
languid snow
#

wait nvm i asked chat gpt

rocky canyon
languid spire
rich adder
languid snow
#

do both work

rocky canyon
#

i us System.Action

rich adder
#

yeah action is simpler though (method has no return)

languid snow
#

alr

languid spire
#

depends on your method signature

ruby python
rich adder
languid snow
#

chatgpt is a fraud., ty guys

ruby python
rich adder
rocky canyon
#
       private void DrawCenteredButton(string buttonName, System.Action onClick)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            // Draw button with custom style
            if (GUILayout.Button(buttonName, buttonStyle))
            {
                onClick?.Invoke();
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }``` attribute button
rich adder
#

I use also an Action as method param to a IEnumerator
a nice modular way to make many timers for diff methods/actions

rocky canyon
#

i remember when i was very new.. i asked if i could pass a method into another method.. and someone called me stoopid..

#

said c# wasn't a macro language 😐

rocky canyon
languid spire
#

best useage for passing a method into a method is for async or coroutines to get a callback on completion

rocky canyon
#

that'd be great for my loading system

rich adder
#

very handy indeed

ruby python
languid snow
rocky canyon
#

whats horrible is it gets totally stuck when u go deep enough

rich adder
# rich adder very handy indeed
 private IEnumerator CoolRepeatingTimer(float timeUntilSomething, Action method)
 {
     while (true)
     {
         var time = 0f;
         while (time < timeUntilSomething)
         {
             yield return null;
             time += Time.deltaTime;

         }
         method?.Invoke();
         yield return null;
     }
 }```
#

ops

rocky canyon
#

i use it quite a bit to make tedious things abit less tedious

ruby python
#

tbh I use it occasionally just to get it to type out code that I'm feeling too lazy at the time to type myself. lol.

rocky canyon
#

for example.. giving it a list of enums and having it vomit out a switch statement for me

ruby python
#

I know enough now that I can spot whether it's wrong or not.

rocky canyon
ruby python
#

lol.

rich adder
#

yes if you can't spot whats wrong it can lead you into very dark places lol

languid spire
# rocky canyon

That is horrible, should be an array of Action and use the enum as the index

rich adder
#

I mean if it works it works amirite

languid spire
#

no

#

have some pride in your work

rich adder
#

I was studying the C++ code for GTA3 repo yesterday and their Enemy AI is basically one giant switch lol

ruby python
#

It's 'knowledge' is very out of date too. I asked it once (gpt3.5) how up to date its Unity c# knowledge was and it was something like 2017.

rocky canyon
# rocky canyon that'd be great for my loading system
  IEnumerator BootEnvironments()
    {
        FindLightController();
        yield return GetRandomWaitTime();
        environmentProgress = 100f;
        IncrementSector();
    }

    IEnumerator BootSystems()
    {
        FindGamePlayObjects();
        SetupSettings();
        yield return GetRandomWaitTime();
        systemsProgress = 100f;
        IncrementSector();
    }

    IEnumerator BootGameSetup()
    {
        SetupPlayer();
        yield return GetRandomWaitTime();
        gameSetupProgress = 100f;
        IncrementSector();
    }

    IEnumerator BootVisualFX()
    {
        FindCanvasObjects();
        yield return GetRandomWaitTime();
        visualFXProgress = 100f;
        IncrementSector();
    }``` guess i could make this *functional* now 😄
rocky canyon
#

tbh its due for a refactor.. this codebase is going on 2 years old..

#

soo past me thought it was legit 🤣

rich adder
#

I always evaluate
Time spent refactoring vs time spent rewriting it from scratch

languid spire
rocky canyon
#

umm wtf?

ruby python
pallid nymph
rich adder
#

Im horrible at designs and graphs

rocky canyon
#

ya, i wasn't skilled enough to design it first.. and then build it..
my workflow consisted of.. building up a little at a time..
then having a guide I could actually conceptualize..
then rebuilding it basically from scratch

rich adder
#

luckily I'm more of a generalist than a "coder" so to me as long a it works and its clear intent is there, I dont bother unless there is a performance issue

languid spire
rocky canyon
#

steve had c# grow up along side him.. its easier for him 😈

pallid nymph
languid spire
#

this is not a C# thing, it's a professional programmer thing

rich adder
pallid nymph
#

I tend to reach good code much quicker if I have only a high-level design plan and then write code that mostly does it and iterate

ruby python
#

I have a bad habit of coming up with new ideas for the thing while I'm writing/building it. lol.

rich adder
#

yeah I dont mind constantly iterating over it as long as I have a general idea/concept in mind already

rocky canyon
languid spire
pallid nymph
#

sure, but the design misses various details, also if it takes a long time to produce the design, you could be weeks in without doing any of the... practical work

#

whereas if you do high-level design, write some code that does some of it, then iterate, you kinda balance these... gives you an option to finish early, if some priorities changed

rich adder
#

haha fresh out of college CS students

languid spire
rich adder
#

too much yap less practice/exp

vast vessel
#

hey guys.
is there a way for me to get a list of all types derived from a base type (in this case, Action_Node)
and then use them as a list of type Action_Node, instead of a list of type Type?

i cant simply convert them with the as keyword. so are there any other ways to do this?

pallid nymph
languid spire
rocky canyon
#

c#sharpghetti 🍜

polar acorn
pallid nymph
#

I do design, just do it as an iterative process of refinement, and of coruse even the initial one is not 🤢 unless I need to potentially finish a new feature in a day

pallid nymph
#

some people get carried away with 20 days of design and only then code... that's what I'm against

polar acorn
#

It looks like this function takes an Action_Node, not a type

vast vessel
#
void CreateNode(Node node) {
        var n = graph.CreateNode(node);
        node.name = n.GetType().Name.Replace('_', ' ');
        CreateNodeView(node);
    }```
polar acorn
#

Yeah, looks like it takes an instance of Node

#

A type is not an instance

vast vessel
#

oh youre right

umbral rock
#

trying to make an AI enemy controller but i get a weird error like this

ruby python
umbral rock
#

i need to place him extremely high then... and then i get error failed to create agent because there is no valid navmesh

ruby python
#

Not really sure what you mean tbh. Basically your enemy (with the agent component) essentially raycasts down from the bottom of the collider to 'find' the navmesh, so if it's too low it can't see the navmesh, hence the first error. (that's a simplistic explanation and the best I understand it)

languid spire
umbral rock
#

wait, what should the navmesh be? the ground?

ruby python
#

Whatever the enemy walks/moves on.

polar acorn
#

It should just be up enough to know for sure its collider isn't intersecting the floor

ruby python
vast vessel
#

this is how im using the method :

polar acorn
vast vessel
#

its as base as you can get

polar acorn
# vast vessel

Okay, so, you can create one via new just fine. I'm guessing there's a lot of sub-classes that extend Node?

vast vessel
#

i need to get all types deriving from Node, then create a new instance of those types, no matter what they are, then use them as a Node.
thats why im doing all of the convertions.

umbral rock
polar acorn
vast vessel
#

im using this as a replacement graph.CreateNode((t)Activator.CreateInstance(type) as Node)

polar acorn
vast vessel
#

yes

umbral rock
polar acorn
# vast vessel yes

So from the types, you want to get the constructor and invoke that method. It even lets you pass parameters to it if you have constructors that take them

https://stackoverflow.com/questions/3255697/using-c-sharp-reflection-to-call-a-constructor

#

Although that does seem to be what you're doing with CreateInstance as well, which I thought was ScriptableObjects (they also use CreateInstance to be instantiated)

vast vessel
polar acorn
polar acorn
vast vessel
#

i need the as Node at the end:

polar acorn
vast vessel
#

okay ill add that too!

winter tinsel
#

how do i change where unity stores builds?

rich adder
winter tinsel
#

where it stores the build

#

that it runs

rich adder
#

the file explorer?

frosty hound
#

Wherever you designated it to be when you first made the build

winter tinsel
#

i know where it is i wanna change where its saved

frosty hound
#

If you just do a normal build (not build and run), it should ask you where

winter tinsel
#

and then when i do build and run itll save it there right=?

rich adder
#

why not try it

#

I almost never do Build and Run , i simply save to folder I want and the folder automatically opens when its done. I just run the exe..

winter tinsel
#

allright thats it

#

i wouldnt have figured that out its not intuitive for me

bleak sleet
#

This is too ez

steep rose
#

What is

bleak sleet
#

2 errors i had

#

and it works as i wanted it to

hallow sun
#

what's the name of the boolean function that goes like this: var = bool ? a : b

#

trying to google if it works with enums

wintry quarry
#

It works with any expression that returns a bool

rustic wasp
#

enumyouchoose==wantedenum kind of thing

#

== expression returns a bool

#

it would work with anything that returns a bool

thick rivet
#

Yall im watching a video and I'm following the script the first line he put worked but the second one doesent and when i type the popups dont come up this is the script https://gdl.space/hokiquwazo.http

polar acorn
wintry quarry
#

!ide

eternal falconBOT
wintry quarry
#

Then the "pop-ups" will appear

#

And you will make fewer typing mistakes like this one

thick rivet
thick rivet
frosty hound
#

Your code has errors. So configuring your IDE will point it out.

polar acorn
thick rivet
thick rivet
polar acorn
# thick rivet
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 175
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-08-13
frosty hound
#

Code doesn't "randomly" change itself.

rich adder
#

called it

thick rivet
#

What did i type wrong then?

rich adder
pulsar forum
#

You added a semicolon, also pls don't share code with just a picture from your phone

terse spindle
#

hey walleliu

rich adder
terse spindle
#

Cannot modify the return value of 'Transform.position' because it is not a variable (CS1612)

thick rivet
thick rivet
#

Tur

#

Tut

frosty hound
thick rivet
#

He also put a semicolon but i wasnt able to sc it in time

pulsar forum
rich adder
thick rivet
#

Sorry I'm just very confused 😅

rich adder
#

you were meant to send the Entire script as you had it

thick rivet
#

Ohhhh

#

I didint know

polar acorn
hallow sun
#

Does anyone have an idea why this:

    {
        RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.zero, Mathf.Infinity, LayerMask.GetMask("UI"));
        if (hit.collider != null) hit.collider.transform.gameObject.GetComponent<Food_1>().GiveToppings(order);
        ReturnToHolder();
    }```
always trigger twice? its not an issue so far, but any debugs write twice, so it could be a problem when i add scores
pulsar forum
rich adder
thick rivet
thick rivet
#

I thought ylal were tlaking about the one line of code

rich adder
#

also, is your script placed on a gameobject ?

hallow sun
# polar acorn What calls `Dropped`

when there is no mouse input, but still has the item reference:

// if input detected
else if (item != null)
{
    Drop();
    return;
}
void Drop()
{
    active = false;
    item.Dropped();
    item = null;
}```
polar acorn
polar acorn
steep rose
dire tartan
#

so im making a 2d game and i want it that if the character hits a wall its momentum is flipped i wanted to make empty gameobjects on both sides and if collided put a negative sign on the velocity is there a more efficient way of doing this?

hallow sun
#

drop is called by the else if, and that is simply on Update()

thick rivet
steep rose
#

Do right

#

But negate the vector

polar acorn
#

They didn't write Left

rich adder
true wind
#

Anyone that knows TextMeshPro can help me? I'm getting different results when calling a TypeWriter coroutine before and after a Canvas.ForceUpdateCanvases() and it's driving me crazy, idk what is wrong.

thick rivet
hallow sun
true wind
#

`` uiText.text = sb.ToString();

    if (autoScrollRect)
    {
        Canvas.ForceUpdateCanvases ();
        autoScrollRect.verticalNormalizedPosition = 0f;
    }

    StartCoroutine(TypeWriter(uiText.textInfo.characterCount));
    
    }

    IEnumerator TypeWriter(int charCount){
        while (uiText.maxVisibleCharacters < charCount)
        {    
            uiText.maxVisibleCharacters++;
            yield return new WaitForSeconds(0.05f);
        }
    }

    #endregion``
#

am I doing something wrong os is TMP being finicky?

umbral rock
#

anyone knows why i cant drag the TMP text into the variable?

thick rivet
rich adder
polar acorn
true wind
polar acorn
rich adder
#

use links for large code

thick rivet
rich adder
#

where does it say that Console or on the object ?

terse spindle
eternal falconBOT
languid snow
#

so i have a list of voids using list<system.action> called "rollMejoras" , and i wanna add one of those to a button onclick i thought this would work but it wont :(

thick rivet
thick rivet
rich adder
languid snow
#

the error says "The non-invokable member 'LogicManagerScript.rollMejoras' cannot be used as a method." (its translated from spanish so it might not be accurate)

rich adder
true wind
# umbral rock

I would do as one answer suggested and use TMP_Text instead of TextMeshPro

polar acorn
thick rivet
rich adder
languid snow
polar acorn
languid snow
#

btw

#

nvm itr does change

#

but its another error

rich adder
languid snow
#

Cannot convert from 'System.Action' to 'UnityEngine.Events.UnityAction'

thick rivet
polar acorn
umbral rock
polar acorn
polar acorn
thick rivet
terse spindle
#

https://hastebin.com/share/ixofomulab.csharp

I wanna make it like subway surfers like when you on the right you need twice input to go to left but in this code it takes one input to go to the left from the right

I want "right -> middle -> left"
it goes "right -> left"

rich adder