#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 650 of 1

maiden estuary
#

I did everything on the site, yeah.

maiden estuary
#

Hey everyone, I know this isnt exactly coding but I cant possibly begin to think where else to try and find an answer to this so I defaulted to here.

Im using CodeAcademy to try and learn C#, and literallt the 3rd thing it asks me to do I dont even know what It wasnts from me. What the hell is a CS and why am I typing it? What does it do and do I even have it? Im so bafflingly confused as to whats going on.

naive pawn
#

cd stands for "__c__hange __d__irectory", it's used to navigate the file system

#

i'd recommend googling that sort of thing in the future

#

but uh, you sure it doesn't want you to actually open the project in vscode?

#

this thing

dapper mirage
#
{

    public Transform player;
    public Vector3 offset;
    public float smoothSpeed = 0.005f;
    // Update is called once per frame
    void LateUpdate()
    {
        if (player == null) return;
        Vector3 desiredPosition = player.position + offset;
        Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed);
        transform.position = smoothedPosition;
    }
}```
Trying to make a script to make the camera follow the player smoothly but it ends up looking really jittery
naive pawn
#

also @maiden estuary if you're asking about just c# stuff unrelated to unity (project setup is kinda handled by unity) then maybe ask in the csharp server
https://discord.gg/csharp

naive pawn
dapper mirage
naive pawn
#

sorry i misremembered the url

#

yeah i posted that above

#

i edited my message to point to the right place

dapper mirage
#

oh okay lol

#

thanks

maiden estuary
# naive pawn this thing

Im just following the learning on code academy, it goes download VSC, download an SDk, then to this. Theres nothing that says anything about making a project, making a folder, nothing.

naive pawn
maiden estuary
#

I didnt google it because I didnt even know if it was a term, it couldve been like, a file name they made or something

naive pawn
maiden estuary
#

I dont like

#

Am I just fucking dense what

naive pawn
naive pawn
#

i don't know how, i don't do plain c#, only unity lol
unity handles this section for you

maiden estuary
#

Oh boy off to some other forum or something to find answers

#

Thank you

maiden estuary
naive pawn
#

not sure why you'd go there, "desktop" seems pretty unrelated to this whole thing

maiden estuary
#

Oh god dammit I need to move my unity from MSV to VSC fuck

naive pawn
#

no clue what msv is here, but you definitely don't need to move unity into vsc

#

they work alongside each other

maiden estuary
# naive pawn ...huh?

I have it so it runs on Mocrosoft Visual Studio, but now because of this code academy I moved over what I'm coding in to Visual Studio Code, so now I would have to change what it's recieving from to VSC would I not?

naive pawn
#

unity doesn't have to "move" anywhere

maiden estuary
#

Poor word choice

naive pawn
#

also visual studio is just known as vs

#

are you talking about the "external editor" configuration in unity? if so then yeah you would have to change that

#

btw though; if you're just planning on learning c# for unity, maybe just skip the project setup stuff and get to the actual language, since that'd be what you'd be using

maiden estuary
maiden estuary
naive pawn
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

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

https://on.unity.com/vscode

maiden estuary
#

Oh thats real fucken nice

dapper mirage
#

Is there a better shape/size of hitbox to use for this or nah

#

This is when the player is falling

stuck field
#

Boxes are fine, capsules just work better for humanoids at least in my experience

dapper mirage
#

Good stuff thank you very much

stuck field
naive pawn
toxic flower
#

may someone please help me with my code?

naive pawn
#

!ask

eternal falconBOT
#

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #๐Ÿ”Žโ”ƒfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696

naive pawn
toxic flower
#

okay

#

so im following the Brackeys youtube channel cube guide thing (i can send link if needed) and the code wont work

#

found it

#

it was a typo

rapid laurel
#

Hello guys, I'm not sure why my Coin object isn't appearing. I initially thought it was because the BulletController script Iโ€™m using to instantiate the coin gets destroyed when my bullet collides with an enemy. However, Iโ€™m dropping the coin before deleting anything, and I also have the reference to the coin prefab correctly assigned. I've tried debugging, but all I get is that the bulletPrefab is null.
It should drop when I kill an enemy, heres the code:
https://pastecode.io/s/dw8fgv47

frail hawk
tired garden
#

Hello, can anyone tell me why the resolution is weird when I export my game, even though I've selected the resolution by hand?

keen dew
#

The game view resolution in the editor doesn't affect the build in any way

frail hawk
rapid laurel
frail hawk
#

ok, change the random.range part please and see if it is what you want

rapid laurel
#

i'll try now thanks mate โค๏ธ

keen dew
#

it's exactly the same thing

frail hawk
#

oh he is converting it into float

frail hawk
woven scaffold
#

hey, just a seemingly simple question. why does it feel like intelisense is getting trashier and trashier? it keeps suggesting to add whole blocks of code, instead of autocompleting simple lines like myBool = true;

#

im on vscode btw. and no copilot. but it feels like it is copilot thats doing these suggestions from how bad they are

#

like, every time i make any brackets, it tries to tell me what script im trying to make while it has no idea what im actually doing

naive pawn
tepid summit
#

Hey i have a script here in a 3D game where it's meant to detect a collision and send a debug.log, then run a coroutine but nothing is happening when the gameobjects touch. Can someone please help?

public float UnitClass;
public GameObject Ore, Ingot;
void Start()
{
    if (this.CompareTag("Drill"))
    {
        UnitClass = 1;
    }
}

void OnTriggerStay(Collider other)
{       
    if (other.CompareTag("Mineable"))
    {
        if (UnitClass == 1)
        {
            Debug.Log("Mineable Found");
            StartCoroutine(DrillMineOre());
        }
    }
}
    IEnumerator DrillMineOre()
    {
        yield return new WaitForSecondsRealtime(3);
        Instantiate(Ore);
        yield return new WaitForSecondsRealtime(1);
    }```
sour fulcrum
#

don't directly compare floats

woven scaffold
tepid summit
sour fulcrum
#

UnitClass

tepid summit
#

yeah i just realsied

#

so what do i do

sour fulcrum
#

ints or other values

#

you should debug log in the compare tag and in the ontriggerstay aswell

#

figure out where specifically thing isnt happening

tepid summit
#

alright

naive pawn
woven scaffold
frail hawk
#

also becarefull , you would be starting a ton of Coroutines if the OnCollisionStay takes place

#

Darkovic

tepid summit
#

yeah im gonna fix tha

naive pawn
sour fulcrum
tepid summit
woven scaffold
naive pawn
woven scaffold
#

cool, ill try that

naive pawn
tepid summit
#

forgot you need rb's for trigger stuff

#

its been a while alright

#

what does kinematic do again

naive pawn
tepid summit
#

alright sick

#

ty all

tepid summit
tepid summit
#

would making the coroutine restart itself at the end of the cycle be bad?

#

e.g:

{
  yield return new WaitForSeconds(4);
  StartCoroutine(Coroutine())
}
verbal dome
#

With the yield inside the loop

#

Otherwise you are creating new coroutines which creates garbage

#

(Which isnt a huge concern every 4 seconds but might as well do it the better way)

tepid summit
#

never done whiletrue in unity

naive pawn
tepid summit
#

naturally, id be able to swap out "true" with any bool, yes?

#

also

#

wouldi have to manually start the first coroutine or will it happen automatically when (true)

north kiln
#

Also note that this setup won't be accurate over time, if that matters to you you'll need to yield per-frame and track time manually

tepid summit
#

thats alright

verbal dome
#

And as long as the owning object is active

tepid summit
#

so hypothetically if i had:

public int MyInt;
void Start()
{
StartCoroutine(Coroutine());
}

IEnumerator Coroutine()
 while (MyInt == 3) {
    
    yield return new WaitForSeconds(n);
  }
}

would that work

verbal dome
#

Sure

tepid summit
#

what does sure mean

#

is there an issue

verbal dome
#

It would work

tepid summit
#

alright

verbal dome
# tepid summit alright

Although, if MyInt is not 3 when you first start the coroutine, it doesn't get a chance to check it again

tepid summit
#

ah ok

tepid summit
naive pawn
#

you should probably just start it in OnTriggerEnter and end it in OnTriggerExit or something

tepid summit
#

yeah but ive already come all this way and id like to look at this whiletrue thing

verbal dome
#

If you want to use coroutines here, maybe you want something like cs IEnumerator Coroutine() { yield return new WaitForSeconds(4); if(MyInt == 3) StartCoroutine(Coroutine()); }

#

(I didn't read all the previous messages yet)

tepid summit
verbal dome
#

Wait that was me

tepid summit
#

i will try it however

#

oh

#

oh wait yeah thats what starte this whole thing

verbal dome
#

Do you need something to repeat?

tepid summit
#

ye

#

and i need a delay between repeats

verbal dome
#

If you want to use the while loop for learning purposes you can do something like this
OnTriggerEnter -> set a bool to true and start coroutine
OnTriggerExit -> set the bool to false
Coroutine -> while(thatBool) { ... }

rocky canyon
#

simple structure ^

naive pawn
#

could also use while (true) and a StopCoroutine

verbal dome
#

Or store a reference to the coroutine and stop it in ontriggerrexit

#

Yea

tepid summit
frail trench
#

both objects have collider component and one rigidbody I guessing and is trigger on one, OnCollisionEnter for physical and onTriggerEnter ( for trigger) , also make sure the layers can collide with each other in the matrix

#

hope that helps

tepid summit
#

i took the message too literaly and tried to write EndCoroutine()

rocky canyon
#

no worries ur in good company

#

cachedCoroutine = StartCoroutine(myCoroutine());

StopCoroutine(cachedCoroutine);

frail trench
#
{
    private Coroutine myCoroutine;
    public int MyInt = 0;

 void OnCollisionEnter(Collision collision)
    {
        myCoroutine = StartCoroutine(MyCoroutine());
    }
void OnTriggerEnter(Collider other)
    {
        myCoroutine = StartCoroutine(MyCoroutine());
    }

void OnTriggerExit(Collider other)
    {
        if (myCoroutine != null)
        {
            StopCoroutine(myCoroutine);
            myCoroutine = null;
        }
    }
 IEnumerator MyCoroutine()
    {
        yield return new WaitForSeconds(4);
        
        if (MyInt == 3)
        {
            myCoroutine = StartCoroutine(MyCoroutine()); 
        }
    }
} ```
#

does this work

#

sorry I just got here bad formatting

rocky canyon
#

the code formatting?

#

nah u ignored it

#

lol

frail trench
#

''' "" ?

rocky canyon
#

nope.. `

frail trench
#

I'm using a 75% keyboard so having to use US a lot to acess hash

rocky canyon
#

backticks.. not quotes

tepid summit
rocky canyon
eternal falconBOT
verbal dome
rocky canyon
frail trench
tepid summit
tepid summit
rocky canyon
#

anyway.. best to just tryitandsee

#

u have the code available to u.. just save it and see ๐Ÿ‘€

rocky canyon
frail trench
#

myCoroutine = StartCoroutine(MyCoroutine());
}
else
{
myCoroutine = null;
}

verbal dome
#

It's good to keep in mind that you can be inside two triggers or touch two colliders simultaneously

frail trench
#

and for trigger / collision enter if (myCoroutine == null)

tepid summit
#

what

tepid summit
rocky canyon
tepid summit
#

totally hasnt gotten worse

tepid summit
rocky canyon
#

sometimes it has to be worse b4 it gets better

tepid summit
#

true

frail trench
#

I put a short clip of what I'm working on in #archived-game-design if anyone has a second for some feedback ๐Ÿ˜„ โค๏ธ

#

hope is right place

tepid summit
#

gotta hit rock bottom before the only way is up

rocky canyon
#

well it was

frail trench
#

I need help with the red moving platform

#

i've tried so many things and it always looks juddery

verbal dome
rocky canyon
verbal dome
#

(Also I don't think people like it when you advertise on other channels)

frail trench
#

oh mate its 15 seconds of a prototype I did today not an advert

tepid summit
rocky canyon
tepid summit
#

fark

tepid summit
naive pawn
#

osmal did

tepid summit
#

oh

frail trench
verbal dome
#

I don't mind that much, just pointing it out

naive pawn
#

also osmal means advertising your question

verbal dome
#

Didn't mean it's a literal advertisement lol

naive pawn
#

stick to one channel; if it doesn't fit, move the question, don't just copy it over

tepid summit
frail trench
#

sure thing, it's no biggie, just working out how people operate in here and already came in to contribute (: !

#

no need to argue โค๏ธ

rocky canyon
#

delta's signify my journy or learning.. what i did know vs what i do know.. vs what i thinki know.

tepid summit
#

oi sick

rocky canyon
#

something something Dunning-Kruger effect

tepid summit
rocky canyon
#

what ideas u lookin for?

tepid summit
#

fixes

rocky canyon
#

i bet that frame-rate is wicked

tepid summit
#

a goo and solid 12 spf

verbal dome
#

Still using OnTriggerStay ๐Ÿค”

#

We been suggesting Enter+Exit

rocky canyon
#

๐Ÿค” i agree

tepid summit
rocky canyon
#

Enter -> Exit the way to go. to avoid Spam

tepid summit
rocky canyon
#

Stay go brrrrrr

frail trench
#

yeah and check I-enum is null in else statement on each

verbal dome
#

Nothing here stops it from starting a coroutine every physics frame in ontriggerstay

naive pawn
#

i don't think anyone abbreviates it like that lol

rocky canyon
#

IEnumerator i think they meant

tepid summit
#

yeah

naive pawn
#

if you're gonna shorten it just drop the I lol

rocky canyon
rocky canyon
#

le enum

naive pawn
#

l'enum

rocky canyon
#

lol

naive pawn
#

(i don't know french)

frail trench
#

no sleep its 2:27pm over here in England, cut me some slack ;;D

verbal dome
rocky canyon
#

people that develop at all hours of the night.. i just have so much concern for their code-base..

verbal dome
#

Because it doesn't get set to null automatically

rocky canyon
#

yield return null;

verbal dome
#

The reference stays

rocky canyon
#

ohh interesting

verbal dome
#

Only unity objects can magically become "null" even though you still hold a reference to them

frail trench
#

yeah in uni they insisted for good reason to always clear states and ints that will be potentially used in memory or active, even when 'le compiler didint care' lol

rocky canyon
#

the left side is a function.. in ur screenshot

tepid summit
#

so no brackets

#

nope didnt work

verbal dome
#

You need to store a reference to the coroutine. This part of the example: cs private Coroutine myCoroutine; ... myCoroutine = StartCoroutine(MyCoroutine());

rocky canyon
#
Coroutine mineCoroutine;

void StartMining()
{
    if (mineCoroutine == null)
        mineCoroutine = StartCoroutine(DrilleMineOre());
}```

```cs
void StopMining()
{
    if (mineCoroutine != null)
    {
        StopCoroutine(mineCoroutine);
        mineCoroutine = null;
    }
}```

this is how i would start it out if i were doing something like that..

firstly just get my coroutine being cached.. and reset to null.. and having methods to start and stop the coroutine
frail trench
#
{
    public int UnitClass;
    public bool ShouldDrill;
    public GameObject Ore, Ingot, BeltItem;
    private Coroutine drillCoroutine;
    
    void Start()
    {
        if (this.CompareTag("Drill"))
            UnitClass = 1;
        else if (this.CompareTag("Furnace"))
            UnitClass = 2;
        else if (this.CompareTag("Belt"))
            UnitClass = 3;
    }

    void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("Mineable") && UnitClass == 1)
        {
            Debug.Log("Mineable Found");
            Debug.Log("Drilling");
            
            if (!ShouldDrill)
            {
                ShouldDrill = true;
                if (drillCoroutine == null)
                    drillCoroutine = StartCoroutine(DrillMineOre());
            }
        }
        else if (UnitClass == 2 && other.CompareTag("Ore"))
        {
            other.gameObject.SetActive(false);
            Instantiate(Ingot, transform.position + new Vector3(0, 1, 0), Quaternion.identity);
        }
        else if (UnitClass == 3)
        {
            if (other.CompareTag("Ore"))
                BeltItem = other.gameObject;
            
            if (BeltItem != null)
                BeltItem.transform.Translate(0.25f, 0, 0);
        }
    }
    
    void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Mineable") && UnitClass == 1)
        {
            ShouldDrill = false;
        }
    }

    IEnumerator DrillMineOre()
    {
        while (ShouldDrill)
        {
            yield return new WaitForSecondsRealtime(3);
            Instantiate(Ore, transform.position + new Vector3(0, 1, 0), Quaternion.identity);
            yield return new WaitForSecondsRealtime(1);
        }
        drillCoroutine = null;
    }
}
#

try this

rocky canyon
#

then i'd just iterate and refactor

frail trench
#

and if not its still the IEnumerator needing to be nulled on the collosions

#

else derp im ded

#

Oh crap i think i just put your code

#

just to double check put again

rocky canyon
# rocky canyon ```cs Coroutine mineCoroutine; void StartMining() { if (mineCoroutine == nu...
void StartMining()
{
    if (mineCoroutine != null) StopCoroutine(mineCoroutine);
    mineCoroutine = StartCoroutine(DrilleMineOre());
}

// to start mining we stop the old mining first (if there is one)

// then we cache the *new* one

void StopMining()
{
    if (mineCoroutine != null) StopCoroutine(mineCoroutine);
    mineCoroutine = null;
}

// to stop mining we check if we *are* already mining.. and if we are.. we stop it and clear the reference
tepid summit
#

huh the what now

frail trench
#

I think the update() is a bad place to have the coroutine called

#

because its making it every frame

tepid summit
#

we noted that

rocky canyon
#

fr.. wouldnt the OnTriggerEnter -> be the one in charge of calling or starting the coroutine

#

welp, id much rather wake up to discussions of coroutines..

#

yesterday it was Quaternions ๐Ÿ˜„

tepid summit
#

hol up i think i did it

frail trench
tepid summit
#

nevermind

rocky canyon
tepid summit
#

soup bowl goes hard

rocky canyon
#

i gotta hop off a sec.. just wanted to post up my example if need be.. ๐Ÿ‘‹

#

oof apparently i can't spell Drill either..

tepid summit
#

ok so we are a step closer

rocky canyon
#

hecks ya

rocky canyon
#

so this was wishful thinking?

tepid summit
#

pree much

rocky canyon
tepid summit
#

fair

tepid summit
#

i frankensteined it into my code and it works

verbal dome
#

I'd still add a mineCoroutine = null; at the end of the coroutine

tepid summit
#

just working on the instantiate now but the hard parts over for all i care

rocky canyon
tepid summit
#

there i did it

rocky canyon
#

but sounds to me like uv gotten on the right path

tepid summit
#

i am king of unity

rocky canyon
tepid summit
tepid summit
rocky canyon
#

open world skyrim clone

tepid summit
#

done

rocky canyon
tepid summit
#

i did it already

#

ill do that

#

ive made like 9

wild peak
#

Release it in steam for him

tepid summit
#

hold on lemme think

#

ive made 13 - 14

tepid summit
#

or if i get a cut

#

whichever

rocky canyon
#

gotta tell em about a thing called "gravity"

#

and they should be fine

rocky canyon
tepid summit
# tepid summit ive made 13 - 14

btw heres a list if anybody wants:

  • GunKill 1 (7 versions)
  • GunKIll 2: Ultimate Demise (3 versions)
  • GunKill Online ( 2 - 4 versions i forgot)
tepid summit
#

here one sec

tepid summit
#

bruhh alright let me convert

#

there we go

tepid summit
rocky canyon
#

this is a really good app if ur sharing vids alot

tepid summit
#

nah not really but thanks

rocky canyon
#

np.. converting mkv's are fun too

spark sinew
#

hi y'all, question on wireframe objects. When I create a wireframe object, the color of the wires are a function of how far away I am from the object (for example if I have a wireframe plane, some elements are red, others are green, yellow, etc, all as a function of the radius between me and that particular point. Can we have just a single color for the wireframe object?

teal viper
#

What component is that? I don't remember there being something like that in unity by default

tepid summit
#

yeah me neither i think its a custom script

#

bro im so used to being in vs that i just tried to press control s before sending that message

verbal dome
#

Spatial mapping wireframe shader or something like that

#

Is that it?

frigid sequoia
#

Hey, can I not Invoke an Event from outside it's script?

verbal dome
#

@spark sinew This one, right?

#

I guess it's included in HDRP by default

spark sinew
#

yes, correct. I have the same effect

#

and you can have other layers beyond just red and green

frigid sequoia
verbal dome
#

@spark sinew I guess you can try editing the shader (a copy of it) and removing the color gradient functionality

#

Or just look for a similiar shader online

sour fulcrum
verbal dome
#

AFAIK all it does is prevent it from being invoked from the outside

frigid sequoia
#

Mmmm, so I would have no real reason to make it an event to begin with then

rocky canyon
slender nymph
#

if you want it to be invoked from outside of the containing object then it does not need the event keyword

verbal dome
#

Let me see where it came from

#

I don't have any VR packages in the project

#

I think it just came with HDRP, not sure

rocky canyon
#

been wanting a generic one to use

frigid sequoia
wintry quarry
#

If you want to do it from outside remove the "event" keyword

#

I would just recommend the wrapper method anyway though

sour fulcrum
frigid sequoia
blazing prairie
#

is it fine to getLoclizedString in update ?

rocky canyon
#

depends on ur definition of "Fine" lol

#

myself i'd only get it when and if it changes

#

could use a flag to mark it as dirty when it needs updated

#

a couple of strings aren't gonna make a noticeable difference tho

verbal dome
blazing prairie
#

i want to update some descriptions in which some numbers and multipliers changes with some player actions quickly and some score and stats display ?

verbal dome
#

Doesn't sound like it needs to be in Update, it'd be better to change only when something changes

blazing prairie
#

I think i have a little messed up code with so many events and stuff that i myself am not sure when those values changes as there were many modifier so i just put in the ui stuff in update but now that i am localizing my game its becoming a pain :<

verbal dome
#

Sometimes it's good to take a bit of time to refactor things into something that's easier to work with

blazing prairie
#

yes thats what i am thinking

crisp vortex
#

yo does anyone want to check my code cuz im running my game but i cant seem to move even with the code i implemented if anyone has a solution plz dm me

naive pawn
#

if you think the code is the issue, show !code as per below:

eternal falconBOT
crisp vortex
#

alr thx

azure dust
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

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

https://on.unity.com/vscode

tepid summit
#

love how my game is so well optimised it cant handle more than 13 conveyer belts

#

beautiful work on my part, really

#

however, hundreds of loose, physics-based items is alright

#

honestly i dont think i couldve done better

rocky canyon
#

maybe they dont all need to be physics objects? or atleast not all the time..

#

maybe theres some optimizations to be had

#

if 100s of physics objects is just part of the gameloop then you'll probably want to find some optimizations somewhere somehow

frigid sequoia
#

How can I order the children of a gameObject? I have a button that adds a prefab UI element to the hierarchy and I want it to be exactly on top of the button and after everything else

slender nymph
#

hint: look at the docs for the Transform class

frigid sequoia
#

Mmmm.... I was thinking more of GetSiblingIndex (of the buttom) and then SetSiblingIndex (of the instantiated prefab) to that one

rich adder
#

Ohh cool. I thought you meant "on top" in UI . gotcha..

frigid sequoia
#

I want it to be the last one of children, but always before the buttom (which would remain)

rich adder
#

makes sense.. I literally just learned about SetIndex myself now lol I havent played around hierarchy too much via code

tepid summit
#

ive fixed it

#

hold on

rocky canyon
#

depends on the code tbh.. im almost positive i could get 100 physics objects to crash out ๐Ÿ˜„

tepid summit
#

ok i havent quite got it but its close enough for me to focus on other tasks

tepid summit
#

whyd i tirn texan

rocky canyon
tepid summit
#

whyd i go buster scruggs mode

rocky canyon
#

๐Ÿ—จ๏ธ "if'n" pretty cool word

tepid summit
tepid summit
brisk flume
#

How should i start about learning code plz i am so lost rn

grand snow
#

time to learn

rich adder
meager gust
rich adder
#

make an RPG in console you will be a c# expert in no time xD

river vapor
#

why do i keep getting this error?

rich adder
#

cause it tells you why exactly you are getting it

river vapor
#

yes but i dont know what to change in player settings

naive pawn
#

do you want to use the old or new system

river vapor
#

well

#

what changes between those two?

naive pawn
#

...how you use them

river vapor
#

i want the new system ig

naive pawn
#

cool, then uh, stop using the old one?

#

right now you have it set to use the new system, but you have code using the old system

rich adder
river vapor
#

oh

river vapor
rich adder
#

Event , Messages or Polling

#

imo if you're new to unity you should probably learn the old inputs first

#

so tutorials dont look confusing

river vapor
#

alr

rocky canyon
#

i currently have it set to Both.. b/c im learning the new system.. but alot of my legacy code uses teh old

spiral magnet
#

hi guys im new to unity and coding but i realised codes in tutorials i watch dont work in unity 6.1. So do i do something wrong or is it actually not working? cuz i tried the same codes on an older version of unity it worked but in unity 6.1 it doesnt work. So my question is should i stick with unity 6.1 or i use the older version 2022?

spiral magnet
#

for example this one whatever i do i couldnt make my character move

rich adder
#

the only thing changed here is Input system is now considered legacy

spiral magnet
#

you are trying to read input using the unityengine.input class this error

rich adder
#

also that tutorial is really bad..

#

remove all the Time.deltaTime from the calculation (in fixed update its fixedDeltaTime so you'll applying it twice)

#

rigidbodies already has a fixed time , adding that is whats making those forces such high numbers and probably cause jank issues in lower frames

spiral magnet
#

i mean i tried without time delata and it still didnt do anything and about force numbers, wiht lower numbers my cube didnt move when i higher the numbers it started to move that was so stupid

#

if its gonna be that hard to learn on 6.1 i should go to 2022 version or 6.0

#

idk

rich adder
spiral magnet
#

ig ill try out

spiral magnet
rich adder
#

if it moved its probably because the line BEFORE the inputs

rich adder
#

Time.deltaTime(in this case fixedDeltaTime cause its in fixed update) isn't 0 so forwardForce * small number it wouldve moved a little sure

wintry quarry
rocky canyon
#

Game-dev and coding is hard.. regardless of what version u use... for example ^ dealing with time.. and deltaTime is exactly the same.. the only things that have really changed are just a few menu items..
and ofc some methods that have been deprecated and/or replaced with alternative versions..

for example rb.velocity became rb.linearVelocity

#

but all of that can be googled super easily.. IDE makes squiggly underlines.. hmm that should be right tho,
googled-> ohhh its linearVelocity now

rich adder
#

everything works exactly the same as it would in 2022.. Unity just decided to default the new input system as inputs..that can be easily changed, everything else is the same.. besides that one change to velocity ^

rocky canyon
#

thats teh only two i've encountered so far

rich adder
#

but yeah as spawn said 100% get yourself a configured IDE and it will tell you the replacements in the code editor

rocky canyon
#

hopefully its the only two i will encounter.. lol.. I finally remember teh alternatives! haha

rich adder
#

on related note..I always wondered if there was come type of List of all the api changes through the years? I know its probably mentioned in docs or change logs but those you actively need to look

rocky canyon
#

even if it makes it thru the ide

rich adder
#

true

rocky canyon
spiral magnet
#

well ty ill stay on 6.1 then ty again

rocky canyon
#

just take it slow.. dont get discouraged

rich adder
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

rocky canyon
#

facts

rich adder
#

random youtube tutorials in the beginning will teach you bad habits, esp the brackys ones are not the best code

#

this guys slaps Time.deltaTime on everything ๐Ÿ˜†

hearty robin
#

Hello guys, just staring with C# and got some mistakes that struggling to fix in my code, if someone can help me with ill be thankful

rich adder
eternal falconBOT
hearty robin
rich adder
# hearty robin

yes PlayerInput should not contain those.. Did you create / generate a C# class from inputs with same name?

hearty robin
#

just following the guide at YT currently

rich adder
hearty robin
#

moment

rich adder
#

this has nothing to do with what i asked

hearty robin
#

9 30 is timecode

rich adder
#

anyway you should refrain from using the same Class name as the Unity Component

#

for exactly this reason

hearty robin
#

so i can look

rich adder
rich adder
#

its not even a tutorial thing, its just a common thing in scripting

#

don't use the same names for classes unless they are separated with namespaces

#

the computer is confused to which one you're using, well here its directly trying to use the Component rather than your generated class

hearty robin
#

alright man, ill try to solve it

rich adder
#

ok..the solution is just to rename the generated class from PlayerInput to something else

#

PlayerInputActions or something

pliant dune
#

whats the difference between the old and the new input systems? the new one is just breaking every tutorial i try to follow

timber tide
#

'new' input is event driven, while the older input system is based on polling input in your update loop

#

if you don't mind checking for input in the update, then don't worry too much about the newer input system

pliant dune
#

hm, alright, shouldn't be that big of a deal to keep the old one

#

though the movement script from the tutorial i followed is not working, maybe i messed up somewhere

maiden estuary
#

What have I done wrong here? Im seeing zero errors or anything, but "Hello World" isnt appearing like it does in the course I'm following.

pliant dune
#

i assume the old input system for the player controller assumes WASD as the default keys?

maiden estuary
pliant dune
#

or do i have to declare these in the script?

teal viper
pliant dune
#

yup, WASD or arrow keys are set as alternative and default respectively, so why is the capsule movement not working?

teal viper
pliant dune
#

C#*

#

ah, so i forgot to include some functions in the update cycle, and the capsule is moving! on the wrong axis but its moving

obsidian iris
#

Hello, I just started the universal 2D for the first time and my camera is a circle, is there a way to make it rectangular?

#

I just see this atm

obsidian iris
#

How do I get it to this view?

wintry quarry
#

turn on gizmos in scene view

#

and also double click/press F on the camera

obsidian iris
#

Thx!

wet pivot
#

I am trying to draw a ray that shoots straight down a small distance forward from the center of my player object. This code seems logical but it is drawing a ray in the center of the map every time...
Debug.DrawRay(new Vector3(playerObject.transform.localPosition.x + 0.25f, playerObject.transform.localPosition.y, playerObject.transform.localPosition.z), Vector3.down, Color.red, 1f);

#

I'm not quite sure why.

wintry quarry
#

If the player has a parent object, those won't necessarily be the same

#

Use .position not .localPosition

wet pivot
#

I assumed localposition would take rotation into account but i now see it doesnt work that way

#

The draw ray is working somewhat but is there a way so that the starting position of the ray rotates with the character?

wintry quarry
#

you mean you want the direction to rotate

wet pivot
#

I don't think I do.

wintry quarry
#

you should use basically:

DrawRay(playerTransform.position, -playerTransform.up, Color.red, 1);```
steep rose
#

use the objects local direction instead of a global direction

#

yeah

wintry quarry
#

perhaps draw a picture of what you want if you think it's not being understood

wet pivot
#

So I'm using a sphere check to check groundedness. I want a separate raycast a bit ahead of the center of the player to check if theyre close to an edge

#

idk if im wording it right but thats what i mean by the starting position should be a bit in front

steep rose
#

so an offset

wintry quarry
# wet pivot

Ok so the question is what does the "rotated" version look like? Are you just meaning to do it to the left if the player is facing left?

#

and to the right if they're facing right?

wet pivot
#

yeah

wintry quarry
#

then that would be:

transform.position + transform.right * 0.25f```
#

assuming you actually rotate 180 degrees on the y axis or invert the scale of the player when they face left

#

if you rotate the player some other way then you'll have to explain that for us to get to an appropriate answer here

wet pivot
#

thanks for the help

wintry quarry
#

based on your sketch

wet pivot
#

I need to read up on transforms some I'm still confused on using the different transform directions

wet pivot
wintry quarry
#

pret straightforward

#

forward is the blue arrow you see

#

when you select an object in the scene view with the position tool selected

#

right is the red arrow

#

up is the green one

#

that's all

wet pivot
#

ah that makes sense

#

whats throwing me off i guess is the addition part. does transform.right/forward/up represent an actual set of numbers?

wintry quarry
#

you can add vectors to each other

#

this is pretty much basic vector arithmetic

#

and yes vectors are "sets of numbers"

wet pivot
#

i mean i get that (1,1,1) + (1,1,1) is (2,2,2)

wintry quarry
#

the position is a vector, then we offset it by the offset vector we want, by adding them

wintry quarry
wet pivot
#

transform.up though, doesn't actually represent a number until we multiply it by something right?

wintry quarry
#

what do you mean by "actually represent a number"?

#

It's a vector, which is a set of 3 numbers

#

it is an actual real set of 3 numbers

#

regardless of what you do with it

wet pivot
#

so up would be (0,1,0)?

wintry quarry
#

if your object is not rotated at all, yes

wet pivot
#

i might be overthinking things here lol

wintry quarry
#

you are

wintry quarry
wet pivot
#

so in theory, transform.forward * 2 would give us the position of a point 2 units away in whatever direction the object is facing

wintry quarry
#

not until you add it to transform.position

#

transform.forward * 2 will give you a vector in the direction the player is facing, with a length of 2

#

another way to think of it is that it's a position 2 units away from the origin (0, 0, 0), in whatever direction the object is facing

wet pivot
#

it... kinda makes sense but now i have even more questions

#

eh maybe i should watch a video on vector3 math

#

actually ok i think i got it lol

novel nymph
#

https://paste.mod.gg/qfkgdjonwwfl/0 I have this simple script, when I press one in the game, it doesn't switch to the desired meshfilter but to a cube. I know this is not code related much but I don't know where to put this. (Should be head in image)

sour fulcrum
#

can you post a screenshot of both meshfilters in question?

#

Also out of curiousity any reason your referencing a meshfilter and not a mesh specifically?

novel nymph
#

oof, didn't know you could do that. Just placed the meshfilter and saw a cube.

glossy bluff
#

Im super new to Unity and coding in general and couldn't find anything with some googling about my specific issue.

I have a button that when clicked, needs to rotate the camera 60 degrees, i have a function created to rotate the camera at a set speed, i just cant figure out how to make the button linked to it, or how to set it to do so for a set amount of time

teal viper
#

Could also use a coroutine.

#

This and more is covered in beginner pathways on unity !learn

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

glossy bluff
#

thanks, honestly im struggling a lot but its pretty fun

#

think i might be in a bit over my head

twin pivot
astral falcon
#

Good morning, what is the best place to ask about package composition and similar topics?

dusky tusk
#

How to remove baked lighting when playing the scene in editor, or when running the build? Directional Light is off, Cleared Baked Data in the editor, but they returned when running the scene.

astral falcon
dusky tusk
stuck field
#

I think #โ†•๏ธโ”ƒeditor-extensions is best for asking this, you'd get an answer by somebody who knows about them, as this channel is runtime code usually, editor extensions would be best to be asked in the specific channel for it.

austere sluice
#

this.tag returns the tag that the current gameobject has right?

stuck field
austere sluice
#

thanks!

#

and

#

if I use this function

#

Spawn Bullet

#

on a different gameobject

#

(by refering to this gameobject)

stuck field
#

Btw, please delete this since you reposted in another channel, just to avoid confusion

austere sluice
#

would it show the tag of the gameobject that called the function

#

or the tag of the one where it was created

stuck field
#

It would use the tag of the source object, so the GO with the script attached

#

To achieve it not doing that, pass in a tag instead

#

So calling scripts would pass in their tags and the script would use them instead of its own tag

austere sluice
austere sluice
stuck field
#

All functions work where they are, if you called from a player script to a gun object with that script, it would use the gun objects tag since you are accessing the current tag (that's why this.tag works)

#

function(string callingTag)

#

Something along those lines

austere sluice
#

so i have to create another function which calls the tag?

stuck field
#

No?

#

I'm not entirely sure what you mean

#

You can add it into your current method unless you want to use tag for calling on itself

austere sluice
#

sorry, english is not my first language, it gets kinda confusing T-T

twin pivot
#

If you are very new with unity you can !learn here

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

austere sluice
astral falcon
astral falcon
#

Ah okay, just wanted to clarify and be on the same page

austere sluice
#

but I want the createdBullet.sourceTag = this.tag to store the tag of the gameobject that calls the SpawnBullet() function and not the script itself

stuck field
astral falcon
#

yeh you just have to pass the tag with it if you calling the function on another script/gameobject as Dark suggested in the second method example

austere sluice
#

waiiitttt

twin pivot
austere sluice
#

oh i think i understood

#

and when I call this function in my player script, i can pass in the player tag

#

right?

#

i feel so dumb, this was so obvious

stuck field
#

Happens to all of us at some points

astral falcon
#

for sure ๐Ÿ˜„

twin pivot
astral falcon
#

void is a function in the end

twin pivot
#

Is it just another way to make it?

stuck field
#

I think

#

I was just using it as a placeholder

twin pivot
#

Oh i see

stuck field
#

What I was showing is you can have 2 functions with different variables

austere sluice
#

thanks ya all!

twin pivot
#

I really gotta get better at spotting the difference

#

I was typing the equivalent of Instantiate(instantiate parameters myGameobject) the other day

stuck field
#

Hard to tell sometimes what it's asking for so makes sense

austere sluice
#

so now that I am calling this function from my player script, would the bullet instantiate from the gameobject that has the original script or from the gameobject where the function is called?

stuck field
#

If you do gameObject inside a function, it will return the GO it is attached to, not the calling GO

#

Same for transform and everything else, but those are just 2 examples

austere sluice
#

so since the function is linked with the gun object and not the player object, it will instantiate from the gun object even tho player object is calling it anyways?

twin pivot
#

Yes

stuck field
#

Yes, but you can pass in a Vector3 for the position it spawns, and a Quaternion for the rotation

#

So where transform.position is, would be a variable inside the function, same as the callingTag variable in the function, you would use Vector3 position

#

Then replace transform.position with position (Or whatever the variable you call with is named)

astral falcon
austere sluice
#

i think i am getting it but the editor is a bit angry...

stuck field
#

That means the object is null, not much other ways to put it

#

"bullet" is null

twin pivot
#

You didnt assign the gameobject

austere sluice
#

yeah i understand that

#

but i have referenced the bullet prefab already

austere sluice
#

let me recheck the script

#

maybe i messed something there

twin pivot
#

Huh thats interesting

stuck field
#

Did you fix that?

austere sluice
# stuck field Well there's an error here

that wasnt an error actually, because i want the bullet to spawn from the gun (where the script is attached) and not the player (where the function is getting called)

astral falcon
#

Are you referencing the gameobject or a script?

#

Looks like you are referencing the script file from project view

stuck field
#

Seems to be the object, but it's the class on the object

austere sluice
#

i was referencing the script

#

rather than the object

#

changed that and its fixed

#

is there a way to detect if the input is being hold? Like currently I have to press left click each time i want to fire, which is good enough for basic shooting, but if i want to add variations by adding something like assualt rifle type of gun, i'll have to make it so that the gun fires a barrage of bullet when left click is hold

stuck field
#

Instead of .GetKeyDown

austere sluice
#

i am using the other input system

stuck field
#

Yeah, I got no clue then

#

I don't use it

austere sluice
austere sluice
astral falcon
#

Its great

twin pivot
stuck field
astral falcon
#

stick to the new input system for sure

austere sluice
austere sluice
twin pivot
astral falcon
austere sluice
#

i find the other one easier imo, its more intuitive and better for crossplatform (not that it matters to me lol)

austere sluice
#

and then i can add a bit of delay between each bullet spawn

astral falcon
austere sluice
#

i was actually openign that doc lol

twin pivot
austere sluice
#

The first code is part of a health script which is attached to my enemy, the seecond code is from a script attached to my Bullet, the sourceTag is basically tag from where the bullet is originating from (and it is working) but the bullet is not able to identify the enemy? I think the enemy has necessary components which is required for collision checks (attached a screenshot just in case), I think its a problem with the logic itself as console isnt giving any errors as well

austere sluice
nocturne hawk
#

What is the best multyplayer method for a 2d platformer? Where can I follow through the process of making my game multyplayer (tutorial, website)?

final sluice
#

I want to learn unity by doing projects to projects while learning about coding and concepts on the way, can anyone recommend a good tutorial on youtube ? I tried Unity Learn but it doesn't suit me
It's also would be nice if someone can give me a list about what I should learn in each level , from beginner to intermediate to a job-ready unity developer
Thank you

teal viper
#

If following structures learning paths is not your thing, you've gonna learn to find answers to your own questions.

dusky tusk
#

im looking at a tutorial in yt rn and after they save the changes to their code and go back to unity theres no reloading domain popup that shows in theirs, hows that possible?

teal viper
cloud shore
rich scroll
#

Hey all! If I know that the only three kinds of interactions i can have is Pickup, Grab and Inspect, is it reasonable to create an abstract 'InteractableObject` class, and have that three kind inherit from that?

#

I've heard interfaces are neat for interactables, but i found that it becomes a bunch of if statements if I need multiple kinds of interactables

eternal needle
eager spindle
#

what's the difference between Pickup and Grab?

eternal needle
#

id go with an abstract class if you wanted to implement default functionality per item, or had values that had to exist on every item. either way you shouldnt have so many if statements to handle different logic here

eager spindle
#

Won't the workflow be to pick up and object and while it's being held, you can inspect the item?

rich scroll
#

Pickup would destroy the object and fire an event, hold is like how you hold the chairs in Amnesia, inspect just brings up some text

eager spindle
#

What you can do is have them all inherit the abstract class you brought up, and have an abstract function OnInteract().

You shouldn't be comparing the types of the classes

rich scroll
# eternal needle id go with an abstract class if you wanted to implement default functionality pe...

I know, that's why I'm asking about the thing being abstract. I had a script like so (for handling interaction with interfaces)

private void FixedUpdate() {
  if (Physics.Raycast(_ray, out RaycastHit hit, rayDistance) {
    if (hit.collider.TryGetComponent(out IInteractable component)) {
      _interactableObject = component;
    } else {
      _interactableObject = null;
    }
  } else {
    _interactableObject = null;
  }
}

and you can't do things like _interactableObject.GetComponent<SomeClass> to figure out what kind of interactable it is to handle its specific case

eternal needle
#

abstract classes dont really change that either. you shouldnt often be in a case where you need to figure out what the deriving class is

#

if you want an abstract class, it'd be because you want the child classes to
derive from monobehaviour
all have some default values
or all have some default functionality

#

the interface vs abstract class part here doesnt change how you call methods

rich scroll
#

well, I can't really do things like _interactableObject.gameObject if I'm using interfaces (from the example above)

#

or is there a way to do that?

#

Cause I'd much prefer to have an interface

naive pawn
eternal needle
naive pawn
#

if you want that guarantee, then extend MonoBehaviour

eternal needle
#

it does seem odd to actually need to get the gameObject still

rich scroll
#

hm, I'll fiddle around a bit, to see if that's really necessary

rare junco
#

Hi. I'm trying to get NetCode for GameObjects to work for a Multiplayer MVP Game.

For some reason, when I click "Start Host", a Player Prefab is loaded for the host and a camera is there, I can move around. When I click "Start Client" with a cloned project (ParrelSync), it just says "No cameras rendering" and doesn't work

#

any idea why?

#

I have added the Player Prefab to the DefaultNetworkPrefabs List, but didn't set it as the Default Player Prefab

#

Is this correct?

dusky tusk
#

it is enabled

pulsar crest
#

hello. i was trying to make it where the cube goes Right and Left by pressing A and D, but the unity system keeps giving me errors. if anyone could help me that would be great

verbal dome
pulsar crest
verbal dome
#

It's a package, not sure if it's installed by default

#

Most tutorials use the old system though so might be easier to stick to that for now

pulsar crest
cosmic dagger
pulsar crest
verbal dome
near meteor
#

i find myself that trying to implement an AI framework for my NPCs is not the hardest, the hardest thing is trying to figure out what damn lines do what in unity.

#

like what does this even mean:
private static readonly Bounds Bounds = new(vector3.zero, new vector3);

verbal dome
#

It declares a new bounds variable. Have you done any C# courses?

hexed terrace
#

That wouldn't compile?

verbal dome
#

Yep, couple of mistakes in there

near meteor
#

and uhh *

verbal dome
#

Check the pins of this channel for C# beginner courses

near meteor
#

right, checking the playlist, i should be here. this is new to me

#

bout to crashout and just do spaghetti

ionic topaz
#

I'm trying to use composition over inheritance in my latest project, I'm trying to get the hang of things but have got stuck on how I want to handle camera shake (using cinemachine), it feels like I'd need a singleton for a CameraShakeManager to handle update code so multiple shakes don't overlap and then to get a reference to the cinemachine noise component instead of dragging the reference in the inspector for every component, is this setup fine or should I be doing something different?

timber tide
#

I usually make a Singleton for camera management

#

No reason to destroy main camera anyway with cinemachine

charred spoke
#

Adding shake requests to a centralised component is how we do it as well.

ionic topaz
#

It feels okay but Singletons have blown up a previous project and I live in fear now

charred spoke
#

Hold on there was a great gdc video on shake

#

Singletons are great if used properly

ionic topaz
#

I know but I'll need more experience using them right

charred spoke
#

In this 2016 GDC session, SMU Guildhall's Squirrel Eiserloh explores the math behind a variety of camera behaviors including framing techniques, types and characteristics of smoothed motion, camera shake, and dynamic split-screen.

Register for GDC: http://ubm.io/2gk5KTU

Join the GDC mailing list: http://www.gdconf.com/subscribe

Follow GDC on ...

โ–ถ Play video
#

I basically took the idea of adding trauma to the camera shake

#

So there is inly one shake and multiple sources add trauma

timber tide
#

I mean you'll know the problems of singletons the more you use them, but until that point I'd just continue on with what you're doing

ionic topaz
#

but cool, appreciate the info! I'll check out the vid

charred spoke
#

intense ?

ionic topaz
charred spoke
#

Sounds just about right. Something that start intense and then heals slowly over time

#

Watch the video itโ€™s great

ionic topaz
#

ohhhh, that is actually a smart term

charred spoke
#

Also this video is a must watch for extra juicy actions https://youtu.be/mr5xkf6zSzk?si=B7EP6lKkoXWIcuLb

In this 2015 GDC tutorial, SMU Guildhall's Squirrel Eiserloh takes a dive into the world of 1D nonlinear transformations to help game programmers make better games.

Register for GDC: http://ubm.io/2gk5KTU

Join the GDC mailing list: http://www.gdconf.com/subscribe

Follow GDC on Twitter: https://twitter.com/Official_GDC

GDC talks cover a ran...

โ–ถ Play video
pulsar crest
verbal dome
#

Google "unity player settings" and you should see an answer without even opening a link

pulsar crest
#

oke

verbal dome
#

This should be the first thing you do anyway instead of relying on this discord server

pulsar crest
near meteor
lean pelican
#

Why is my SerialiseField Array variable not showing up in the inspector?

[SerializeField] List<Direction> links;
public List<Direction> connected;```
#

The other two show just fine.

timber tide
#

Cant serialize interfaces

lean pelican
#

How do I work around that, then?

timber tide
#

If that's too much for you then I suggest just not using interfaces for serialization purposes unfortunately

#

Odin Inspector I believe has serialization for them

lean pelican
#

At least for this small thing I'm doing rn, this is a bit much, I'll just go without the Interface, then. I take it I just wanna have all the classes that implemented the Interface inherit from a (relatively sparse) Monobehaviour instead?

timber tide
#

You can declare abstracted monos just fine, it's just that interfaces are a little too ambiguous to serialize

#

meaning you can insert different derived monos if you do declare as the abstractions

lean pelican
#

I see. I think I get it, thanks.

sharp bloom
#
else if (!moving && turning)
        {   
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(randomDir, Vector3.up), Time.deltaTime * 0.25f);
        }

This is in my Update(). How could I make this as such that the rotation time was fixed, so it could adapt to the random direction value?

naive pawn
#

secondly, sounds like you'd want to use the right lerp for this

#

or perhaps compute an angular velocity and use RotateTowards

#

ah wait that changes the smoothing though

#

to have both smoothing and a fixed time... thonk

sharp bloom
#

I know there's like DOTween but figured I could do this myself

naive pawn
#

i think you'd just have to do math if you want the exponential decay (similar behaviour to what you have now)

red cedar
#

!code

eternal falconBOT
sharp bloom
naive pawn
ancient berry
river vapor
#

hi im a beginner and i don't know which tutorial should i watch, which one do you recommend?

#

i'd just like to be able to make a simple first person system

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

river vapor
rich adder
#

when you learn Lego you don't immediately try to make a replica of empire state building, you start with basic houses / structure

river vapor
#

yeah, i'm just gonna make basic games then try to make it a bit harder

#

and i'll repeat until i get some knowledge

rich adder
#

sounds good..yup.. just keep practicing what you learn and repetition makes knowledge build up.

#

in the beginning when learning don't know how many times i had to copy something like Physics.Raycast , from the docs / google until I kept writing it on my own eventually "it sticks"

river vapor
#

ty

daring star
#

Please help, 'i' is class object with field material

naive pawn
#

what's the issue

hexed terrace
#

looks like they're expecting the material supplied by i to be assigned to materials[0], but the name being printed to console is (presumably) the previous (but still current) material

rocky canyon
naive pawn
rocky canyon
#

wouldnt be so bad if there wasnt like 14 of em

rocky canyon
#

VisualStudio do this to anyone else?

When i create a new script I don't even have time to double click it or anything b/c Studio pops open..
that wouldn't be soo bad, but its always either showing the last script i was working on, or the Missing File page..
I can't even swap over to it in the Solution explorer..

i then need to click back into Unity.. let it Recompile.. and then finally can i double click it to open the desired file..

smoky river
#

how do i mark it as legacy

rocky canyon
#

not only that.. but its the (1) program that likes to tack its Tooltips on the screen

smoky river
#

i did that but my animation still doesn't work

silent valley
polar acorn
queen adder
#

can someone

#

tell me why its rotated the wrong way

polar acorn
#

Because Blender and Unity have different coordinate systems

queen adder
polar acorn
queen adder
#

its z

queen adder
polar acorn
queen adder
#

i made it z

#

i know its not x

#

i was doing it to test if it will work

polar acorn
#

Unless you apply transforms none of them will even do anything

copper nymph
#

hello, i am having a problem in detecting a collision in my game, i have a waypoint with a void OnTriggerEnter2D(Collider2D other) function, it checks for the other objects tag to be PlayerCar "which it is" and it should output something in the console but it doesnt happen

queen adder
copper nymph
#

do i just paste it as text here? or i need to write something

polar acorn
#

!code

eternal falconBOT
copper nymph
#
   // This method is called when any car passes through a waypoint
    void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("Triggered by: " + other.tag);  // Log the tag of the object that triggered the waypoint

        if (other.CompareTag("PlayerCar")) // Ensure this matches the tag exactly
        {
            UnityEngine.Debug.Log("Car passed through waypoint");

            GameObject Car = other.gameObject;
            int currentWaypointIndex = carProgress.ContainsKey(Car) ? carProgress[Car] : 0;

            // Check if car passed the current checkpoint (waypoint)
            if (Vector2.Distance(Car.transform.position, waypoints[currentWaypointIndex].position) < 1f)
            {
                // Car passed the current waypoint, move to the next one
                currentWaypointIndex++;

                // If car completes the lap, reset to first waypoint
                if (currentWaypointIndex >= waypoints.Length)
                {
                    currentWaypointIndex = 0; // Reset to first waypoint
                    lapCount++;
                    Debug.Log("Lap " + lapCount + " complete!");
                }

                carProgress[Car] = currentWaypointIndex; // Update car progress

                if (other.CompareTag("PlayerCar"))
                {
                    Debug.Log("Car passed through waypoint");

                    // Change the car's color to green when it passes through a waypoint
                    SpriteRenderer carRenderer = other.GetComponent<SpriteRenderer>();
                    if (carRenderer != null)
                    {
                        carRenderer.color = Color.green;
                    }

                    // Reset the color after a short delay (optional)
                    StartCoroutine(ResetCarColor(other));
                }

            }
        }
    }
#

this is the waypoint, please dont hate the code :)

polar acorn
copper nymph
#

i dont get anything in the console

polar acorn
#

Then this object never collides with anything

cosmic quail
#

or its not set to be a trigger

copper nymph
#

i have a box collider on the waypoint and one on the car, the waypoints collider is set as trigger

polar acorn
#

The Three Commandments of OnTriggerEnter2D:

  1. Thou Shalt have a 2D Collider on each object
  2. Thou Shalt tick isTrigger on at least one of them
  3. Thou Shalt be moving via a 2D Rigidbody on at least one of them
copper nymph
#

both have a collider, trigger is right also and the car has a rigidbody which im steering it with

timber tide
# polar acorn

Still no clue why we use -z as the forward in the export

copper nymph
#

im very new still maybe i got something wrong

polar acorn
polar acorn
copper nymph
verbal dome
#

Show the waypoint

copper nymph
polar acorn
# polar acorn It's so Y can be Up in both 3D and 2D

Elaborating: Unity wants to work with the usual 2D plane of "X sideways, Y up", and it wants to maintain the same direction for gravity in both 2D and 3D. This means that Unity doesn't use Z-up like most 3D programs do. In an effort to make X "forward" in 2D and the same direction in 3D, it ends up making Z forward

verbal dome
# copper nymph

Does the waypoint have the script that has OnTriggerEnter?

copper nymph
#

its the track manager which has the script

polar acorn
verbal dome
#

I don't think that trigger messages propagate upwards from child to parent except when the parent has a rigidbody maybe

copper nymph
#

i didnt set one for the TrackManager, just the waypoints themself

#

ooooh

polar acorn
copper nymph
#

okay thanks a lot, can i target the collider from the child somehow? i wanted to have a list where i put the waypoints and they are "scanned"

polar acorn
#

Then have those waypoints report back to the parent object that they've been hit

copper nymph
#

thanks a lot :D

true fox
#

Why does the build fail even though there aren't any compile errors before hand? Errors flash in the console for a second or so and then disappear. One of the errors is to do with a certain script. I go to check that script and my VS Code shows no errors. Anyone have any idea how I can fix this?

polar acorn
true fox
crisp token
#

are events the most common way to communicate between different systems?

ripe shard
crisp token
ripe shard
crisp token
#

im trying to avoid that

ripe shard
#

and an event should usually pass a reference to the event source along

#

Events are a pattern for decoupling code. If that is your goal, use them.

#

but events often make it more difficult to understand code flow and thus debugging will be more tedious

crisp token
#

If you imagine a "system" as a heirarchy of classes or composition, is it a common approach to keep intersystem communication kind of at the top of the hierarchy, and then have all children within the heirarchy just interact with their respective root for any intersystem stuff?

ripe shard
sour fulcrum
#

Sounds about right? I tend to write code similar to a supermarket or such, where thereโ€™s different departments and a manager in each one

grand snow
#

Beans manager ๐Ÿซ˜

ripe shard
crisp token
#

its tough, because what I need is essentially a singleton manager class for each system, but since Im doing multiplayer i cant have a singleton. Although i guess I could kinda have a singleton store where you input an id and it uses specific reference

grand snow
#

Dont forget about interfaces as another way to "decouple" without using events

sour fulcrum
#

Why canโ€™t you have a singleton in multiplayer

twin pivot
crisp token
rapid thunder
#

guys i have a problem with this thing i should be able to take the box from ground again but i can't any idea why?

rapid thunder
crisp token
twin pivot
rapid thunder
sour fulcrum
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

twin pivot
#

Start with the basics

grand snow
#

its all fun and games until ai has no fucking idea how to fix some weird ass error ๐Ÿ˜

#

learning yourself gives you the tools to fix problems

rapid thunder
twin pivot
#

Then you should know what part of the script does what

crisp token
rapid thunder
rapid thunder
verbal dome
#

Are you going to do VR or mobile AR development?

#

So yeah you wouldn't need to watch those

twin pivot
rocky canyon
#

u should show the box Before you first pick it up and after u drop it..

#

you've only given us like half the puzzle pieces

earnest wind
#

!code

eternal falconBOT
earnest wind
#

sorry just wanted the pastebin website

#

I already know where the bug is located. just dont know how i could fix the scaling issue with the Canvas

#

its because i am calculationg based on Screen, i have no idea if this will bring issues but i think i need to fix it...

rocky canyon
#

pass ur MousePosition thru this method and see if it helps

earnest wind
rocky canyon
#

no..

#

overlay is fine

earnest wind
#

cause i tried passing it and it just wont work?

rocky canyon
#

u just need the Rect of the Canvas ur trying to map the mousePosition to

earnest wind
#

i will check tommorow

#

i have to go right now

#

thanks for help

bold pawn
#

Right so i've got a question, are there any circumstances where you can use the "new" keyword in a monobehaviour?

Because, in one unity project i have a script that does use the "new" keyword ( MyList.Add(new whatever(1, 2)) and unity gives me the "you are trying to create a monobehaviour using the "new" keyword. this is not allowed" message in the console. okay.. makes sense i guess.

But why does the exact same script (unless i'm missing something) Work in a different project with no errors? I'm so, so confused lol

#

Like, i've been messing with the first project using "new" in a monobehaviour script for a couple days now, and i've never seen that message until i created a new project and tried the same thing

polar acorn
#

No, you cannot create a MonoBehaviour with new

#

The different project either:
A) Isn't actually working
or B) Isn't a MonoBehaviour

wintry quarry
wintry quarry
#

it doesn't work when whatever IS a MonoBehaviour

bold pawn
#

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

namespace Assets
{
    [DefaultExecutionOrder(-700)]
    public class PlayerData : MonoBehaviour
    {
        public int SkillPoints = 0;

        public List<Skill> SkillsList = new List<Skill>();

        private void Start()
        {
            SkillsList.Add(new Skill("Brewer", 1));
            SkillsList.Add(new Skill("Drunkard", 9));

        }

    }
}

(hope that works)

wintry quarry
#

The issue is how is Skill defined?

#

Is Skill a MonoBehaviour or not

#

if it is, you shouldn't be doing this

#

if not, then it's fine

#

that's it

bold pawn
#

oooh, skill is not a monobehaviour

polar acorn
#

Which means it's fine to be created with new

bold pawn
#

๐Ÿคฏ sweet, thanks folks. This was frusterating XD

wintry quarry
#

I would highly recommend creating these objects in the inspector instead of in your code.

#

Which you can do as long as Skill is marked with [Serializable]

#

And as long as its fields are public or have[SerializeField]

sand field
#

Trying to figure out why this doesn't work, feel like I'm at least close

// Start at 180 degree angle
private Vector3 toAngle = new Vector3(0f,180f,0f);
void ChangeSpawnerAngle()
{
    // Once above 225 degrees, reverse rotation direction
    if (transform.eulerAngles.y >= 225)
    {
        toAngle.y = 135f;
        transform.eulerAngles = Vector3.Lerp(transform.rotation.eulerAngles, toAngle, Time.deltaTime);
    }
    // Once below 135 degrees, reverse rotation direction
    else if (transform.eulerAngles.y <= 135)
    {
        toAngle.y = 225f;
        transform.eulerAngles = Vector3.Lerp(transform.rotation.eulerAngles, toAngle, Time.deltaTime);
    }
}

sand field
wintry quarry
#

Is this called in Update or something?

sand field
#

Yes

wintry quarry
#

There are several issues here

#

One - you're using Lerp completely incorrectly
Two - Using Euler Angles here is going to be a complete nightmare

wintry quarry
#

Those are the main two issues

sand field