#💻┃code-beginner

1 messages · Page 770 of 1

meager siren
#

Its also in FixedUpdate

timber tide
#

Queue would work fine if the idea is you're executing as you pop dequeue them. List works fine too though as you can just get the count and pop from the end of it

#

Really the queue is just a more restrictive list when you think about it (c# list allows 0 index insertions). Something like a stack however has some more usage imo

true pine
#

why does adding an editable list break the editor?

timber tide
#

Reset the editor

true pine
#

this happens every single time I look at an object with an editable list, without fail

#

also would that just mean close it and relaunch the project or

timber tide
#

Yeah, restart unity. Also this is a coding channel, so if it persists and you think it's code related then post some code, otherwise take it to #💻┃unity-talk with any other information you can provide.

#

Seems more just like Unity bugging out though, but if you do have plugins or something going it may be conflicting

languid gull
#

Are you sure that the constraints are 100% and not causing some off call?

languid gull
true pine
meager siren
#

How to check at a negative angle until a different angle?

#

if you could somehow figure that out lmao?

#

I cannot

slender nymph
#

what does that even mean

languid gull
#

explain it abit more

#

because currently thats a very open ended statement

meager siren
#

idk how else to explain

slender nymph
languid gull
#

so checking if 2 angles is a certain degree?

slender nymph
#

for what

meager siren
#

door

#

Im also tryna figure out how to explain

slender nymph
#

alright i'm out

languid gull
#

trying to find out if door is open im assuming ?

meager siren
#

cause I have said I dont know how to explain it

meager siren
slender nymph
#

if you cannot explain what you are even trying to achieve then how do you expect anyone to know what you actually need to do

meager siren
#

But I want it to be able to close, not instantly but after it goes above (below in this case) a certain angle

#

well

#

open

#

not close

#

close after opening, just not instantly

#

allowing you to

languid gull
#

oh like lerping?

meager siren
#

I've done that I just want to check if the doors rotation is gone past a certain angle

#

after opening.

languid gull
#

Oh okay, so seeing if max threshold has been exceeded?

meager siren
#

Max threshold is about to be exceeded

#

idk anymore

#

its hard to explain

#

and its confusing

slender nymph
#

finish a thought before pressing enter rather than spamming one thought across 4 small messages
#📖┃code-of-conduct

meager siren
#

nvm i figured it out somewhat

languid gull
#

can you post the code because im curious as to what you meant

meager siren
#

i hate rotations so much

#

I'll see if I can explain this better

languid gull
#

rotations are not bad once you understand all of the ways to make it work

#

Can you post a version of the not working code as well

astral void
#

Why don't you just rotate the object over x time using lerp, and then when x time is up, rotate it back the same way?

#

I saw someone mention coroutines, did you try using them?

meager siren
#

So i want to check if the doors rotation is IN between or equal two angles, -15 and 0. And if it is in between or equal allow the input.

#

something like that

meager siren
languid gull
#

if (Mathf.Abs(currentZAngle - targetZAngle) < 5f)

meager siren
#

THERE IT IS

#

im dying

#

what even does Abs do?

astral void
#

convert to positive value

#

so -5 return 5, and 5 returns 5

languid gull
#

Mathf.Abs takes a single numerical argument (which can be an int, float, long, sbyte, or short).

meager siren
#

I know what converting to positive value means. But I will test this out rq

languid gull
#

Mathf.Abs in Unity is a static method belonging to the UnityEngine.Mathf class. It is used to return the absolute value of a given number.

meager siren
#

YES OMG

#

feel good

#

I really need to learn more

#

arguments

#

also this is my code btw

#

about to fix it

languid gull
#

Having that in fixed update will lead to some issues but for now is a great way to proof of concept

meager siren
#

its just a placeholder for me rn

#

I'll be doing something completely different later on

languid gull
#

perfect

meager siren
#

I do plan to make it an animation

#

instead of just rotating

#

literally

#

but, eh.

#

This solves one of my problems that totally hasn't taken me idk, 12 hours to figure out?

#

and I didnt

languid gull
#

you could move all of that out of fixed update into a void like

  //After key pressed do raycast check this away the raycast is only being cast once and not over all the time causing issues

}
meager siren
#

oh

#

I dont really use methods ngl

#

I should start using them

languid gull
#

Ya Update or Fixedupdate raycasting is heavy on pc's to make it simple

polar acorn
meager siren
#

something like this?
Or do I do return hit

polar acorn
#

Update and whatnot are methods just like any others

meager siren
#

methods I create

#

using the code

meager siren
astral void
polar acorn
languid gull
#

you can just not like that hold on one sec ill write it out

polar acorn
#

right now it's just being thrown away. (Well, right now it's a compile error but I'm assuming you'll be passing in the values later)

cunning narwhal
#

Is there a difference between registering and subscribing to an event?

#

Or are they just synonyms

ornate pelican
languid gull
#
{
if(interact.action.IsPressed())
          CheckDoorStatus();
}
void CheckDoorStatus()
{
  currentRotation = transform.eulerAngles;
  if(Physics.Raycast(mainCamera.position, mainCamera.TransformDirection(Vector3.forward)* raycastDistance, out hit, layermask))
  {
    if(Mathf.Abs(transform.eulerAngles.y - closedTargetRotation.y) < 5f)
    {
        currentRotation.y = Mathf.LerpAngle(cirrentRotation.y, openTargetRotation.y, speed * Time.deltaTime);
        transform.eulerAngles = currentRotation;
        openInput = true; // not even sure you need this
    }
  }
}
languid gull
#

this will limit ray call and and help clean things up i typed this in a web app so might need some tweaks but concept is there

meager siren
#

I was just tryna get the premise down for my code

#

like not, whats the word for making the game run better

#

optiomized

#

optimized

languid gull
#

this will make it where the raycast isnt going crazy

#

oh i know you would have most likely done this i just like to make things slightly optimized when it comes to raycast as to many ray calls will cause major performace issues

meager siren
#

I just wanna get the premise working before optimization

#

since I'm new to Unity

languid gull
#

then you go down the rabbit hole

meager siren
languid gull
#

this is my current WIP on my state controls

#
     (Crouch.inProgress ? MovementState.crouching : !move.inProgress ? MovementState.idle :
     Sprint.inProgress ? MovementState.sprinting : MovementState.walking);```
#
 {
     switch (state)
     {
         case MovementState.idle:
             Debug.Log("Player is idle.");
             // Add idle animation or behavior
             rb.linearVelocity = Vector3.zero; //current not working right but i think its from ground check issues
             movementState = MovementState.idle;
             break;
         case MovementState.walking:
             Debug.Log("Player is walking.");
             movementState = MovementState.walking;
             break;
         case MovementState.sprinting:
             Debug.Log("Player is sprinting.");
             movementState = MovementState.sprinting;
             break;
         case MovementState.crouching:
             Debug.Log("Player is crouching.");
             movementState = MovementState.crouching;
             break;
         case MovementState.air:
             Debug.Log("Player is in air.");
             movementState = MovementState.air;
             break;
         default:
             Debug.Log("Unknown player state.");
             break;
     }
 }
meager siren
#

ah huh

languid gull
#

thats first code controls my entire player motion in one line depending on keys used

meager siren
#

uh huh

#

I cannot comprehend this as of rn

winged ridge
#

It's a switch statement which takes an enumerator and depending on which it is, outputs the code in the case: section

#

So if for example you were to have an enum as A, B, C, D, you can have case A: DoAMethod(); break; case B: DoBMethod() etc and it's within what's known as a switch statement that's the switch(enum type name here)

naive pawn
#

enum stands for enumeration

winged ridge
#

It's an enumerable value

naive pawn
#

nope, different thing

#

it's an enumerated number

#

an enumerable is what other languages might call an iterable - lists, arrays, dictionaries, etc

#

(same for enumerator/iterator)

#

an enumeration numbers (lists) out the possible values

winged ridge
#

So youre saying, an enumerator isn't an enumerable although they are lists that are 'arguably' finite, to enumerate through something is to go through each step by step usually in order.

#

Regardless, I shall look into this further

slender nymph
#

enums aren't infinite btw

naive pawn
#

an enum is an enumeration

meager siren
#

also whats this thats highlighted meant to mean

winged ridge
#

If the maths.abs is greater than 5

slender nymph
meager siren
#

thats not what Im asking

meager siren
#

Im weird

naive pawn
slender nymph
#

"i know what that is"

someone explains what it is
"that helps"

meager siren
#

ah im not going to bother arguing

winged ridge
#

MathF.abs is taking the absolute value of the sum in its method, and checking if it's greater than your 5, an absolute value is basically even if the Sums a negative, it's positive version is the absolute

naive pawn
#

that isn't a sum btw

winged ridge
#

Not even, positive

#

I didn't say this was, I explained what absolute value is

naive pawn
#

the absolute value of a difference gets the.. well, absolute difference. a difference without a sign

winged ridge
#

Absolute of -5 is 5 as an example

naive pawn
#

absolute value gives the absolute value

astral void
#

both of you know what mathf.abs is

winged ridge
#

The sum is a synonym for total, so your sum is the end result

astral void
#

lets just not argue about it :3

naive pawn
meager siren
naive pawn
#

you have the right understanding but you're using the wrong words

#

words mean things

winged ridge
#

You've never heard the term sum total?

naive pawn
#

i have, and it's not relevant to absolute

#

sum is the result of additions

#

there are no additions here

astral void
#

if I Mathf.Abs(-4) is there a sum?

naive pawn
#

there is not

winged ridge
#

The Sum total of abs(-4) is 4

naive pawn
#

the result/value is 4

#

there is no sum/total there

winged ridge
#

Often denoted in books as |-4|

naive pawn
#

maybe look up what sum means

winged ridge
#

Oxford languages

naive pawn
#

yeah, the second definition

#

that's the only one used in math

astral void
#

I think saying |-4| gives a sum total would be the same as saying sin(4) gives a sum total which... doesn't make sense to me. not a mathematician but that sounds odd

#

I think you need two numbers for it to count as a sum

naive pawn
#

that would be because it's wrong lmao

#

a sum is the result of addition

naive pawn
languid gull
#

what have i come back to

winged ridge
#

|-4| does have a formulae to it, it's not just remove the negate sign

naive pawn
#

the result of subtraction is a difference, multiplication is product, division is quotient for example

astral void
#

ohhhhh

#

yes this is familiar

naive pawn
#

it's only addition where the result is a sum

winged ridge
#

That's the formula if your curious

astral void
naive pawn
winged ridge
#

Are you going to carry on being this irritating and unhelpful?

#

Or should we summary this

astral void
#

come on man...

naive pawn
#

are you going to keep insisting on wrong terminology lmao

#

it's an active detriment to beginners to be taught the wrong terminology

#

it creates a communication barrier, making learning/researching harder

#

ive tried to be helpful, ive explained the correct terminology and ive explained what the terms you used actually refer to

#

up to you if you want to accept that and learn from mistakes

mistakes are a crucial part of learning, ive made a ton myself. it's fine

#

you don't need to accept it to me or anything, but at least accept it to yourself so you can learn

winged ridge
#

The issue in this, and my issue mainly is not how you have corrected me if you correct me, it's how you do so that's the issue, as you have done with others before

astral void
#

that's... vague

#

how specifically is it an issue?

naive pawn
#

your issue isn't how i correct you, but how i correct you?

winged ridge
#

It wasn't 'constructive' is what I mean, it was confrontational

naive pawn
#

tbh, i think i started pretty light. you kept deflecting

naive pawn
winged ridge
#

Sum, summary, total synonyms, you told me they were not and sum and total were not

naive pawn
#

i never said that lmao

#

sum and result are not synonyms

#

sum and total are synonyms

astral void
#

I can't imagine this convo ending well :c

#

I think we should just leave it here

#

nothing is going to be gained going forward

naive pawn
#

...well, i tried...

winged ridge
naive pawn
#

why are people so resistant to learning

ornate pelican
naive pawn
#

i would hope so

astral void
naive pawn
#

also sum and summary aren't synonyms 🤨 though that wasn't brought up so whatever

cinder trout
#

anyone now what he is using?

polar acorn
#

A keyboard most likely

astral void
#

...visual studio?

#

I believe

cosmic dagger
#

looks like a public variable, but I'm not sure the name of it . . .

astral void
#

this question is a bit too vague it seems...

naive pawn
#

-# looks like they're using dark mode to me

cinder trout
#

and when i open a c script were is the option playercam

ornate pelican
cinder trout
#

oh

#

thanks

naive pawn
cinder trout
#

thank youu that actually helps and is the thiing hes usiing the visual studiio

naive pawn
#

yeah

cinder trout
#

ok thank you

naive pawn
#

(sidenote - visual studio (vs) and visual studio code (vscode/vsc) are separate things. blame microsoft for confusing naming. both are valid options though)

slate summit
#

how do i move the arrow to my mouse?

#

so if i put my mouse in the position where the red square is... the arrow should rotate around the circle to face the mouse new position

#

the arrow is a separate object

ivory bobcat
#

What have you tried so far?

slate summit
#

making it one object worked fine but i want it to be two so i can animate the arrow differently from the circle

astral void
slate summit
astral void
#

np ^^

ivory bobcat
solemn crypt
#

Anybody got any guitar hero style scripts that work with a ui slider and ui buttons

naive pawn
#

not sure how sliders would fit in there though

solemn crypt
#

Thinking about combining the functions for pressing the buttons on the screen to make the bar slide

#

Example being rect transform

young crypt
#

hi guys im making a weapon bench in my game when u enter it switches the input map but when i try using it nothing happens no errors no debugs that its null even tho i enable them all
`var values = playerGeneralValues.Instance;
if (values == null)
{
Debug.LogError("playerGeneralValues instance is null!");
yield break;
}
values.playerInput_i.Enable();
// Get and enable the weapon bench map
weaponBenchMaps = values.playerInput_i.weaponBenchMap;
if (weaponBenchMaps == null)
{
Debug.LogError("Weapon bench map is null!");
yield break;
}

    weaponBenchMaps.Enable();
    
    // Find actions
    leaveAction = weaponBenchMaps.FindAction("leaving");
    clickAction = weaponBenchMaps.FindAction("click");
    mousePositionIA = weaponBenchMaps.FindAction("mouse");
    
    // Verify actions were found
    if (leaveAction == null) Debug.LogError("Leave action not found!");
    if (clickAction == null) Debug.LogError("Click action not found!");
    if (mousePositionIA == null) Debug.LogError("Mouse action not found!");

    // Enable actions
    leaveAction?.Enable();
    clickAction?.Enable();
    mousePositionIA?.Enable();`
#

i am not using a player input component

naive pawn
astral void
#

!code

radiant voidBOT
astral void
#

wait does error message count as code or can I just paste it

#

that looks like code

naive pawn
#

the error message itself isn't code, but putting it in a code block (or a pastebin if it's long) doesn't hurt

#

makes some parts easier to read, but not a requirement

astral void
#

ok idk how paste.mod.gg works i'ma just do the inline code one

naive pawn
#

(btw that embed is available in #🌱┃start-here, so you don't have to summon the bot every time)

astral void
#

I don't see it there-

naive pawn
#

as for the inline code thing, you can just type those

astral void
#

oh yeah the sites yeah
I should be able to remember the inline thing hopefully

naive pawn
#

(technically it's not inline code (which would be this), it's a codeblock... not sure why the embed says that 😔)

knotty river
#

hey, how do i create an enemy AI that shoots towards you and follow you

hot wadi
#

U can use state machine combined with scriptable object to store the enemy's states. If u want smarter movement (to avoid walls, doors, etc.), u can use navmesh

frail hawk
#

i think he is using 2d envoirement

hot wadi
#

Yeah, just a heads up

spiral summit
#

it seems like i have some bug that wont open the game mode, while the code seems normal

hot wadi
spiral summit
#

I got this message and don't know where the error is coming from

naive pawn
#

seems like your vs is not configured

#

!ide

radiant voidBOT
hot wadi
#

The error suggests missing bracket but everything does look ok

naive pawn
limber turtle
#

i've been seeing it from time to time but i'd like to know just to be sure; what's the difference between struct and ScriptableObject, and when would i want to use one over the other?

hot wadi
naive pawn
#

yes

naive pawn
limber turtle
#

oh

naive pawn
#

can't really compare them

limber turtle
#

well can you give me a rundown of scriptableobjects then?

naive pawn
#

structs are bundles of data (for processing, etc)
SOs are configuration data (static)

limber turtle
#

right

#

in what situations would i use SOs then? i'm looking through the ror2 code right now and the items are all SOs but i'm not quite sure what that means in terms of how they function

naive pawn
#

that's pretty much all structs are, they're just a language feature, they can be applied in a variety of circumstances
SOs are a unity thing, basically data as assets

limber turtle
#

ah right

#

so SOs are easier to use within the editor and are more versatile, but structs are simpler and smaller?

#

or am i getting this very wrong

naive pawn
hot wadi
#

U can use struct in SO

naive pawn
naive pawn
hot wadi
#

SO is just normal class

limber turtle
#

i might have to look into this a bit more then

naive pawn
#

SOs definitely aren't just normal classes, unity specifically knows about SOs and can instantiate them as assets

naive pawn
#

overall maybe structs are more versatile? but i don't think that matters for comparing them to SOs

limber turtle
#

right yeah

#

i just saw that they both store data and in my inexperienced brain that was close enough for comparison

naive pawn
#

i guess that's fair

limber turtle
#

i'll definitely have to look this up further

sour fulcrum
#

The big value of so is that it’s an asset and not a behaviour tied to a specific scene

#

like how materials are assets that can be edited in 1 place and used in a bunch of places

#

But with data you specifically want

limber turtle
#

so they basically exist outside of the game state?

#

and you can use them wherever

sour fulcrum
#

Ya

#

It unity had hindsight and could go back Materials probably would be scriptableobjects

limber turtle
#

right that makes a lot of sense

#

since in ror2, items need to carry over between stages

#

and you need to be shown what you had on the end screen

sour fulcrum
#

yeah

limber turtle
#

and the items themselves don't change in any way other than how much the player has, which is stored in the player

#

so you can use a scriptableobject to store all of the item's data like the sprite/model (if 2d/3d), name, description and id

#

then you can control the effects based on how many the player has

sour fulcrum
#

But usually you’d maybe have the so for static data to reference and a live instance of something that knows about that so and would have any live changes

naive pawn
#

those would be references

#

the SO means there's only 1 true instance of the item that controls its stats

sour fulcrum
#

Same as minecraft having the block in your inventory vs the block placed in world

sour fulcrum
naive pawn
#

you would not be instantiating SOs for each item you have in your inventory

limber turtle
#

ah

#

so the SOs are already in the scene, you just take their data when you want to use them somewhere else?

sour fulcrum
#

so’s are not in the scene

limber turtle
#

ah

naive pawn
#

SOs are assets, they exist outside the concept of scenes entirely

limber turtle
#

mb

hot wadi
#

U still have to reference them

limber turtle
#

right yeah we covered that earlier

naive pawn
#

the data exists separately, when you want to access it you use a reference to the SO

sour fulcrum
limber turtle
#

ok

#

just want to recap to make sure i've gotten everything right

#

SOs are data collections stored as assets that are not affected during runtime, but can be called and referenced from anywhere for their data to be used?

#

forgive me if i'm misunderstanding, i'm not great at this

#

ahhh

#

so would it be a good idea to essentially think of them as universal global variable stores that can be used so long as you give a script "permission" to do so?

sour fulcrum
#

They can be affected at runtime, but in editor those changes will persist so it’s recommended you don’t do that

limber turtle
#

ah

#

are they used for save data collection in some cases or will i have to come to that another time?

#

because if you were to change it at all, those changes would persist regardless of the game state

sour fulcrum
#

Only in editor

limber turtle
#

oh

#

nevermind then

spiral summit
hot wadi
naive pawn
#

it might automatically get fixed, but don't rely on it

#

actually do the configuration

naive pawn
#

you aren't supposed to instantiate SOs at runtime

#

i don't see any reason you'd duplicate SOs for each item in an inventory. that seems like it would completely nullify the benefits

#

a wrapper class, maybe? but not the SO itself

sour fulcrum
#

Depending on the game instantiating can be convenient if you don’t want to spend time establishing some kinda so <-> base class relationship inheritance tree for when you need to edit a lot of those properties at runtime

cosmic dagger
brave robin
#

Its a good way of doing the flyweight pattern, where the SO holds the data that never changes, and the instance non-SO class holds anything specific to the instance
Like an SO class for an enemy for its base stats and other details, while the instance non-SO class has its current health and other state info

hot wadi
#

It's better to discuss it in practice rather than in theory

polar acorn
#

What's this got to do with code

tidal sable
polar acorn
tidal sable
#

Done

slow blaze
#

Hey I have a question, I am making a 3d game where it has a minigame that is supposed to shift the prespective into entirely 2D, with 2D drag drop and things like that.
I'm using cinemachine to pivot from 3D to the 2D look but I'm kinda confused on how to translate 2D things (like ray casts for drag and drop, rendering) into the 3D environment
I haven't really wrote anycode to try and do that I just want to get an idea on how it could be done, if there are tutorials or previews for something like that I'd love to see it

polar acorn
#

You can just use 3D physics in a 2D space, nothing would break. It's just some extra work over using 2D for an entirely 2D project but it's less work than switching everything over when you swap

slow blaze
#

I see
I'll try a little demo to see what I can come up with, plenty thanks.

forest wolf
coral patio
#

is there an option to speed up time to debug things which are reliant on light?

grand snow
wintry quarry
coral patio
#

oh my god my brain is dead

#

i made a custom clock for day and night cycle based on time.time but just figured i can just multiple it and stuff is faster

#

sometimes its just asking the question answering it

wintry quarry
wintry quarry
# coral patio can you elaborate

Something like

bool useDebugTime;
int customHourOfDay;
int customMinuteOfDay;

public DateTime CurrentTime {
  get {
    if (!useDebugTime) return DateTime.Now();

    return new DateTime(2025, 11, 15, customHourOfDay, customMinuteOfDay, 0, 0);
  }
}```
#

you can refine this of course, but - layer of abstraction that lets you inject whatever time you want

grand snow
#

Or some kind of interface so you can have different implementations

rancid tinsel
#

does anyone have some resources on group turn-based combat systems like in assassins creed, batman arkham etc.? ive been banging my head against the wall for like a week straight trying to make one

#

tbh i might just be too burnt out

forest wolf
rancid tinsel
#

i cant remember if its still like that in the modern ones but definitely the case in older ACs

forest wolf
#

If you are looking for something really turn based this is probably the best course: https://gamedev.tv/courses/unity-turn-based-strategy

GameDev.tv

<p>Are you looking to <strong>level up your game development skills</strong> and take your projects to the next level?</p><p>Do you <strong>play games like XCOM2 or Final Fantasy Tactics</strong>?</p><p>In this course, you’ll <strong>take your skills from beginner to advanced</strong>, learn to manage and organise a complex project. You’ll c...

rancid tinsel
#

not that kind of turn-based unfortunately

forest wolf
#

If I understand correctly what you want, it probably would be a matter of having a 'manager' that keeps a queue of all the enemies in 'range' and then triggering one at a time to attack. So each enemy would have the code related to attacking, the way he does it and so on, but ultimately the manager would choose who will be attacking.

rancid tinsel
#

the problem is that I can understand that system perfectly from a high-level view, but I've written it like 5 times from scratch now and every time it doesn't work

forest wolf
#

I think it will be easier to start writting it and if something doesn't work - come back with a specific question or problem

rancid tinsel
#

at this point I just don't even know what my problem is lol I'm so lost in all of it

#

I could show an example of what I've got hang on

#

!code

radiant voidBOT
rancid tinsel
#

its a lot of code though so if that's too much to help with then I understand

slow blaze
#
 private void FixedUpdate()
    {
        if (Input.GetMouseButton(0))
        {
            Debug.Log("Trying to hit smth");
            Vector3 mousePos =  Camera.main.ScreenToWorldPoint(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(mousePos,transform.forward, out hit, Mathf.Infinity))
            {
                Debug.Log("Hit: " +  hit.collider.name);
                Debug.DrawLine(mousePos, hit.point, Color.red, 1000000, false);
            }
        }
}```
Hey I'm trying to use this to raycast from the mouse to try and find an object to hit, 
The "hit" works a little too well because just having the object in the camera FOV marks it as hit (and does draw the Hit line correctly)
How can I limit it to check where the mousePos is standing? or not make it work as good as it does
rancid tinsel
#

so the enemies are not circling, they are not queueing attacks properly

#

I also just noticed that my LookAt causes them to look up but that should be an easy fix

wintry quarry
hot wadi
slow blaze
#

Thanks for the information

rancid tinsel
toxic atlas
#

Hello, I'm a beginner and I'd like to know where I can learn to code for Unity.

naive pawn
toxic atlas
#

ok thanks

true pine
#

I may be setting this up wrong, but how would I check if an object has a certain script component, and how would I call a function from that script remotely

#

or alternatively how would I get an object to do something if it hits another object's raycast

timber tide
#

Well, show what you've got so far with your raycast

true pine
#

so I created a whole other script called "objectManager" and that's basically what controls health and damage resistances etc

timber tide
#

I would suggest inlining your code for future reference

#

!code

radiant voidBOT
true pine
timber tide
#

You have the idea there though and it comes down to the hitInfo which contains all the helpful information for where/what the ray has hit

true pine
#

so.. what would I use to return the entire gameobject? cos that's what I'm using to look for whether the object has a manager script or not

timber tide
#

And more specifically what you're looking for here is a way to get information of the gameobject that is hit. Usually people will grab the collider information, but you can also get information via the transform. From there you can then use GetComponent (TryGetComponent is objectively the better method so look into that) and checking if it includes the component to access.

true pine
#

hell yea

timber tide
#

So the idea here is if you hit a collider you know it's a gameobject because it's a component to a gameobject

#

and from that you can use GetComponent to grab more of those components off the gameobject (assuming those components exist)

lunar coral
naive pawn
#

....wow...

#

why are they even separate methods

#

this could be a loop

#

uhh, anyways, what exactly do you mean by "stops working"?

lunar coral
naive pawn
#

what doesdialogueSystem.NextDialogue() do?

#

cost does not matter in the slightest at that scale

#

do not worry about optimization here

lunar coral
lunar coral
naive pawn
naive pawn
#

perhaps show the method i asked about

lunar coral
lunar coral
lunar coral
#

but I don't think it's something to focus on, the asset is made for it, it's ultra long, there are like 100 scripts and it shouldn't be wrong

naive pawn
#
if (currentAudio == null || currentData == null || !dialoguePlaying)
    return;

so that's a silent exit

#

try debugging that

#

see which condition is true there

lunar coral
#

maybe I should add a debug there to see if it returns null;

lunar coral
naive pawn
#

this is not blaming, this is going through to figure out what's going on, it's debugging

naive pawn
#

not sure what you mean by that

lunar coral
naive pawn
#

what exactly is the code you wrote?

#

that's a one-line if statement, if you just put another line there then the structure changes

lunar coral
naive pawn
#

you shouldn't be debugging inside anyways, you should be debugging before

lunar coral
languid gull
naive pawn
#

not necessarily wrong, but if you put the log before the if and log both positive and negative cases you can verify that the log works (as in, you saved and it's recompiled etc)

lunar coral
naive pawn
#

gotta trace through the nextDialogueTrigger thing then probably

languid gull
#

if playering return, whats calling for a second check after?

lunar coral
languid gull
#

Based on the first code you are suing a time system to call on NextDialogue right?

lunar coral
#

I've added a debug outside the if statement and it runs

#

do you know what that means and what might be the issue now? because I initially didn't understand why I had to add a debug outside to be honest, now the issue is probably into the function or code that uses this bool?

languid gull
#

okay this is where i could be confused just based on the snippet but whats im seeing is its only called once so if the audio takes over 4 seconds and you have the command being checked at 3 seconds

naive pawn
lunar coral
languid gull
#

Also i would look into switch statements

lunar coral
lunar coral
lunar coral
#

Lol

languid gull
#

Because you have 10 voids for one scene transition and could use that in more then one way

#

also the code is only being called once

naive pawn
#

the replacement for all that duplicated code would be a loop, not a switch

languid gull
#

loop as well

naive pawn
#

switches don't really solve anything here

lunar coral
#

switch is for if functions ??? bro I don't know if you're the issue or If I'm

naive pawn
#

-# ifs aren't functions

languid gull
#

Oh boy.

lunar coral
#

yes sorry got out my mouth

#

if statements*

languid gull
#

A loop repeats a block of code, while a switch executes a single block of code based on a specific value. Loops are for repetition and are controlled by conditions like ranges (e.g., for loops), whereas switches are for making a single choice among many possible outcomes (e.g., switch statements). A loop continues to run until its condition is no longer met, while a switch statement evaluates a single expression once and runs the corresponding code block.
Both can work in this.

lunar coral
#

by the way, how could I use loop for this? should I make a timer That I increase in Update()?

lunar coral
naive pawn
#

you have duplicated code there

#

you'd just do something like this

for (int i = 0; i < 11; i++) {
  dialogueSystem.NextDialogue();
  yield return new WaitForSeconds(timeBetween);
}
```replacing all the PlayNth calls
lunar coral
naive pawn
#

(this changes the behaviour slightly, but not too hard to fix)

lunar coral
#

anyway that doesn't fix the issue but yea looks much better and I'll always use them now

languid gull
#

also try

        {
            if (currentAudio == null || currentData == null || !dialoguePlaying)
            {
                Debug.Log("Nothing");
                return false;
            }
                

             return  true;
        }`
}```
this will for sure return a true or false and can be called at any time 
Using the return statement in a void method in Unity (or C# in general) immediately exits the method and transfers control back to the calling code. It does not cause the method to "run again" automatically.
naive pawn
#

you never return any values

languid gull
#

i hit enter on my own scirpt and sent here

naive pawn
#

return statement in a void method
that's the behaviour of return in general btw, not specifically in void methods

lunar coral
#

wouldn't doing that just be important if you return a bool?$

naive pawn
#

not sure what returning a bool would do here anyways tbh

languid gull
naive pawn
#

no, the method sets a member variable that's used as state

languid gull
naive pawn
#

it sets a member variable used as state

#

going of what theyve said already, this isn't even their code

languid gull
#

to return a true or flase to nextDialgueTrigger

naive pawn
#

that's not what return means, no

#

and if you want to use a return value instead, it'd have to be in the same class or system to be able to update the state correctly

languid gull
#

public void NextDialogue()
{
if (currentAudio == null || currentData == null || !dialoguePlaying)
{
Debug.Log("Nothing"); // still playing do NOT play new
return;
}

        nextDialogueTrigger = true; // move to next code allow BOOLEAN to be true. 
    }
naive pawn
#

..yeah, i can read code

#

please do consider what classes these methods are in

#

the calling method and this method are in different classes. if encapsulation is being followed in the asset, the member variable isn't exposed, so it'd be impossible to use a return value to replicate the behavior correctly

lunar coral
#

I can't find the issue, the script has 1000 lines

#

I'll try to use multiple dialogues instead and TriggerDialogue() each of them

languid gull
#

When a switch statement might be appropriate:
Handling distinct dialogue states or branches: If your dialogue progresses through clearly defined, separate stages or branches based on player choices, quest progression, or other game states, a switch statement can elegantly manage these different paths. Each case in the switch could correspond to a specific dialogue segment or a set of dialogue options.

    {
        case DialogueState.Greeting:
            DisplayDialogue("Hello, adventurer!");
            break;
        case DialogueState.QuestOffer:
            DisplayDialogue("I have a task for you, if you're interested.");
            break;
        case DialogueState.Farewell:
            DisplayDialogue("Goodbye, and good luck!");
            break;
    }

When a for loop might be appropriate:
Iterating through a sequence of dialogue lines: If you have a linear sequence of dialogue lines that need to be displayed one after another, a for loop (or a foreach loop) can iterate through an array or list of these lines.

    for (int i = 0; i < dialogueLines.Length; i++)
    {
        DisplayDialogue(dialogueLines[i]);
        yield return new WaitForSeconds(displayTime); // For sequential display
    }
#

Hybrid Approaches and Considerations:
Combining switch and for: You can often combine these structures. A switch statement might determine which set of dialogue lines to use, and then a for loop could iterate through those lines.
Data-Driven Dialogue: For more complex dialogue systems, consider using data structures (like ScriptableObjects in Unity) to store dialogue information. This can make your dialogue easier to manage and modify without directly changing code. You might still use switch statements to handle different dialogue types or for loops to iterate through dialogue segments within these data structures.
Performance: For the vast majority of dialogue systems, the performance difference between switch and for will be negligible compared to other factors like UI rendering or asset loading. Focus on readability and maintainability.
Ultimately, the choice depends on how your dialogue is structured and the specific logic you need to implement. For branching narratives and distinct dialogue states, switch is often clearer. For sequential display of dialogue lines, a loop is more suitable.

naive pawn
#

please don't just copy-paste LLM answers here

languid gull
naive pawn
#

respectfully, your point was irrelevant

languid gull
#

how is a on point statement irrelevant. his code was no functional

naive pawn
#

adding a switch would not help there

#

they were using an external asset for the dialogue - some of the code shown was not under their control or knowledge

languid gull
#

While true a switch can still function here. I be it, not the best option but could work. I agree where a for loop is the best option.

naive pawn
#

yikes, man

languid gull
#

again not sure why you are saying yikes.

#
    {
        yield return new WaitForSeconds(time);
        PlayFirst();
        yield return new WaitForSeconds(timeBetween);
        PlaySecond(); //calling after 1
        yield return new WaitForSeconds(timeBetween);
        PlayThird();//calling after 1
        yield return new WaitForSeconds(timeBetween);
        PlayFourth();//calling after 1
        yield return new WaitForSeconds(timeBetween);
        PlayFifth();//calling after 1
        yield return new WaitForSeconds(timeBetween);
        PlaySixth();//calling after 1
        yield return new WaitForSeconds(timeBetween);
        PlaySeventh();//calling after 1
        yield return new WaitForSeconds(timeBetween);
        PlayEighth();//calling after 1
        yield return new WaitForSeconds(timeBetween);
        PlayNinth();//calling after 1
        yield return new WaitForSeconds(timeBetween);
        PlayTenth();//calling after 1
        yield return new WaitForSeconds(timeBetween);
        PlayIleventh();//calling after 1
        yield return new WaitForSeconds(time);
        GoToGame();
    }```
```public void NextDialogue()
        {
            if (currentAudio == null || currentData == null || !dialoguePlaying)
            {
                Debug.Log("Nothing");
                return;
            }
                

            nextDialogueTrigger = true;
        }
``` If the dialog hadnt finsihed this will return on what ever next call is made
#
    {
        dialogueTrigger.TriggerDialogue(); // playded first 
    }
    private void PlaySecond()
    {
        dialogueSystem.NextDialogue(); //calls check on is something still playing only calls once
    }
    private void PlayThird()
    {
        dialogueSystem.NextDialogue(); // calls check if dialogue above was more then public float timeBetween = 1f; NextDialogue will return with no further call
    }
    private void PlayFourth()
    {
        dialogueSystem.NextDialogue(); // calls check if dialogue above was more then public float timeBetween = 1f; NextDialogue will return with no further call else this will play next
    }
    private void PlayFifth()
    {
        dialogueSystem.NextDialogue(); // calls check if dialogue above was more then public float timeBetween = 1f; NextDialogue will return with no further call else this will play next
    }
    private void PlaySixth()
    {
        dialogueSystem.NextDialogue(); // calls check if dialogue above was more then public float timeBetween = 1f; NextDialogue will return with no further call else this will play next
    }
    private void PlaySeventh()
    {
        dialogueSystem.NextDialogue(); // calls check if dialogue above was more then public float timeBetween = 1f; NextDialogue will return with no further call else this will play next
    }
#
   private void PlayEighth()
    {
        dialogueSystem.NextDialogue(); // calls check if dialogue above was more then public float timeBetween = 1f; NextDialogue will return with no further call else this will play next
    }
    private void PlayNinth()
    {
        dialogueSystem.NextDialogue(); // calls check if dialogue above was more then public float timeBetween = 1f; NextDialogue will return with no further call else this will play next
    }
    private void PlayTenth()
    {
        dialogueSystem.NextDialogue(); // calls check if dialogue above was more then public float timeBetween = 1f; NextDialogue will return with no further call else this will play next
    }
    private void PlayIleventh()
    {
        dialogueSystem.NextDialogue(); // calls check if dialogue above was more then public float timeBetween = 1f; NextDialogue will return with no further call else this will play next
    }
    private void GoToGame()
    {
        SceneManager.LoadScene(sceneName); // game loads
        
    }
naive pawn
#

that is some insane spam

#

the majority of it isn't even true

#

there is no time check inside NextDialogue, what are you going on about

languid gull
#

Spam? okay. wow.

naive pawn
#

real quick, do you know how coroutines work

languid gull
#

Do you?

naive pawn
#

i do, yes. ive used them extensively and have explained them numerous times

languid gull
#
    public float timeBetween = 1f;
    private IEnumerator PlayFirstWhenWanted()
    {
        yield return new WaitForSeconds(time);
        PlayFirst();
        yield return new WaitForSeconds(timeBetween);
        PlaySecond();
        yield return new WaitForSeconds(timeBetween);
        PlayThird();
        yield return new WaitForSeconds(timeBetween);
        PlayFourth();
        yield return new WaitForSeconds(timeBetween);
        PlayFifth();
        yield return new WaitForSeconds(timeBetween);
        PlaySixth();
        yield return new WaitForSeconds(timeBetween);
        PlaySeventh();
        yield return new WaitForSeconds(timeBetween);
        PlayEighth();
        yield return new WaitForSeconds(timeBetween);
        PlayNinth();
        yield return new WaitForSeconds(timeBetween);
        PlayTenth();
        yield return new WaitForSeconds(timeBetween);
        PlayIleventh();
        yield return new WaitForSeconds(time);
        GoToGame();
    }
``` then please tell me the current wait time on WaitForSeconds(timeBetween)
naive pawn
#

honestly, no clue what you're even asking

#

if you're asking about how much time is waited, it could be anything, given that timeBetween is serialized

languid gull
#

That was the simpliest question i could ask its in the code.

naive pawn
#

but that does not mean that each NextDialogue call checks the time and returns accordingly

#

they are not even called if the WaitForSeconds has not completed

languid gull
#

HEY ^ you figured it out

naive pawn
#

..i figured out that you don't know what you're talking about?

languid gull
#

Oh no.

#

Okay, so let me get this right, let me go slow incase imwrong here. how does waitforseconds work

naive pawn
#

...ok, so do you know how coroutines work

#

were you being sarcastic/rhetorical before

languid gull
#

answer the question

ivory bobcat
naive pawn
#

WaitForSeconds is a YieldInstruction that Unity accepts and knows to keep a timer, where - for each frame (aka upon Update, though WaitForSeconds happens after Update in each cycle) the timer is incremented by deltaTime, and once the timer is greater than or equal to the specfied time, completes the YieldInstruction and continues execution of the IEnumerator body of the coroutine

#

happy?

#

// calls check if dialogue above was more then public float timeBetween = 1f; NextDialogue will return with no further call
nothing about NextDialogue's return has anything to do with timeBetween, or time in general
the time check is in WaitForSeconds, or to be pedantic, inside unity's handling of WaitForSeconds, not in any of the PlayNth calls or in NextDialogue

#

no clue what "no further call" is even supposed to mean

#

return inside NextDialogue would not escape the coroutine body, and no throws are involved either

languid gull
#

I am. So when using

 public float timeBetween = 1f;
IEnumerator Somethinghappens()
    {
        Debug.Log("Line 1 done");
        yield return new WaitForSeconds(2f); // Wait for 2 seconds
        Debug.Log("Start line of code 2.");
        yield return new WaitForSeconds(timeBetween); // Wait for 1 seconds ( right?)
        Debug.Log("Start line of code 3.");
        yield return null; // Wait for one frame
        Debug.Log("do something after frame passed.");
    }
naive pawn
#

// Wait for 1 seconds ( right?)
not necessarily, given that it's a serialized field

#

but assuming timeBetween is set to 1, then it's approximately that

languid gull
#

okay lets say that an outside force is infact workiong with timeBetween and setting it do dialog length

naive pawn
#

not sure what dialog length you're referring to there. doesn't seem like the code given accounts for that

languid gull
#

^ thats the point. he set it to 1f in the code and could have set it to any number after in the editor.
he then calls this code

public void NextDialogue()
        {
            if (currentAudio == null || currentData == null || !dialoguePlaying)
            {
                Debug.Log("Nothing");
                return;
            }
                

            nextDialogueTrigger = true;
        }
``` simply checking if the dialogue has  played or still playing. 
``` now i dont see in the code where the logic is handled if the above is reading false
public float timeBetween = 1f;
   private IEnumerator PlayFirstWhenWanted()
   {
       yield return new WaitForSeconds(time);
       PlayFirst();
       yield return new WaitForSeconds(timeBetween);
       PlaySecond();
       yield return new WaitForSeconds(timeBetween);
       PlayThird();
       yield return new WaitForSeconds(timeBetween);
       PlayFourth();
       yield return new WaitForSeconds(timeBetween);
       PlayFifth();
       yield return new WaitForSeconds(timeBetween);
       PlaySixth();
       yield return new WaitForSeconds(timeBetween);
       PlaySeventh();
       yield return new WaitForSeconds(timeBetween);
       PlayEighth();
       yield return new WaitForSeconds(timeBetween);
       PlayNinth();
       yield return new WaitForSeconds(timeBetween);
       PlayTenth();
       yield return new WaitForSeconds(timeBetween);
       PlayIleventh();
       yield return new WaitForSeconds(time);
       GoToGame();
   }
``` if this is still going with using what ever time he has in place for timeBetween. if he calls PlaySecond() and nextDialogueTrigger was never set to true due to something still playing this would cause PlaySecond() not to work right?
naive pawn
#

keep in mind - it's saying "if dialogue is not playing, stop"

#

nextDialogueTrigger was never set to true
it was set to true though. he debugged that part and found out

languid gull
# naive pawn > simply checking if the dialogue has played or still playing. i don't think s...

this is my hope. but currenly as he said. the code isnt working. im working with what i have been given and the only thing i could see from the given is if he calls on player#() and nextDialogueTrigger = false then that could be a issue. all i was trying to do was find out how is the code handling if not true so i could help assist and some how we have dragged this out into something.

naive pawn
#

yeah, not a ton of info was given - thats what followup questions are for, don't make random assumptions lol

languid gull
#

I didnt assume anything. I do how ever see why this discord was laughed about in other dev discords. You are very intelligent @naive pawn i think we where arguing for no reason. but assumptions where not made.

naive pawn
#

...i see plenty

#

my man, the latter half of this you asked

languid gull
#

because you questioned my ability to code. Nothing i have said is wrong given the little knowledge we have atm. I used the given scirpt to infer that he had timeBetween set to 1. if he did and using code i cant see there could be a issue if he is calling dialogueSystem.NextDialogue(); and this is returning something at a time it shouldnt. again not sure why timeBetween would be 1 but thats all i got to go on. and since the WaitforSeconds(timeBetween) would be using the infered 1 second interval to call on dialogueSystem.NextDialogue() if somehow the other code was still doing something or a audo was not null and or current data was not null and or dialoguePlaying was true then NextDialogue would not make nextDialogueTrigger true and may in this mention other code cause play issues. as the mentioned code has a running timer set to the infered 1 second time interval to call the next void and call dialogueSystem.NextDialogue();

hybrid cobalt
#

Hello, have been recently learning about how UI is done in Unity:

What I've seen is that UI Toolkit is like the "new, polished" method to make UI, but there are some people that use the Legacy UI objects for simpler stuff. Is this right?

hasty summit
#

Guys, is it possible to write code so that when I click on an object, my index.html page opens in Google? (On a phone)

naive pawn
#

you can use Application.OpenURL for links in general, but not sure you can supply a local html file with that

languid gull
#

In your code for the objecting you can use
Application.OpenURL(urlToOpen);

#

^ the local html may be the problem

timber tide
naive pawn
#

this is just a bad faith argument at this point, i shouldn't engage lmao

hasty summit
languid gull
timber tide
#

I mean, if you do web dev and like css/html then you'll love UI Toolkit, but the thing that does create some complication is binding the UI to those gameobject which do require some boilerplate / middleman script

naive pawn
timber tide
#

Meanwhile UGUI you can directly reference (via editor) which does make things a hell of a lot easier

viral kestrel
#

someone knows how to implements vivox

#

i realy like to pay someone to do it for me

#

the role game is finished

#

i tried every thing

#

i didnt found anything

#

some can helpme?

ivory bobcat
#

!collab

radiant voidBOT
# ivory bobcat !collab

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

viral kestrel
#

i think the idea is very promising

#

ou

#

sorry

#

i joinned now

#

i did't read the rules

naive pawn
#

you should make it a habit to read server rules when joining new servers

hybrid cobalt
timber tide
#

Yeah exactly. The referencing is easier with UGUI because everything is an independent gameobject, while your UIDoc would be a single gameobject that you need to open up and bind everything inside of the script

#

Not the largest problem, but when you compare it to Button where you can bind event directly on the UI to a gameobject script it makes debugging so much easier

#

Oh, and if you want it to expose properties in the editor, then you're usually making the drawer for it too

hybrid cobalt
#

You mean expose properties of the UIDoc?

timber tide
#

Right, it doesnt expose any properties on the editor unless you make a property drawer

#

really they need to make this process easier. I'm already exhausted of thinking about it lmao

hybrid cobalt
#

Hm That doesn't really sound intuitive, thanks for saving me headaches!

forest wolf
#

So your UI doesn't have to be a single document, even more - you can define your own components so if you need multiple health bars (for whatever reason) or coin counters you can reuse the one you have

hybrid cobalt
#

Do you mean creating multiple UIDocument objects to separate stuff?

timber tide
#

You can have multiple documents instead of one yeah. That would probably be a good idea to keep stuff independent at least

timber tide
#

I'm not sure if I would make one for each button per say

hybrid cobalt
#

Although, if those ui elements interact with each other for sizing and positioning, not sure how that would play out.

forest wolf
timber tide
#

Yeah true, if it's not a unique button each that would be like some prefab

#

I should try that idea next time instead of these larger single docs

forest wolf
# hybrid cobalt Although, if those ui elements interact with each other for sizing and positioni...

I think we are talking about slightly different things here - I am not talking about keeping them as separate object in the sense of having completely independent UI elements, it's like regular workflow with prefabs - you define the reusable components but you still put them in one scene or parent prefab (UI). The idea is the same, you are always going to have a level that combines element together - same with building websites, you may have 3 columns in discord but they have a common parent - the page/view. It's completely fine but what's important is that you have the lines e.g. avatar + name + text as a component. That way you can consistently modify behaviour and appearance in one place.

#

The view is 'using' those smaller components, but it doesn't care about their concrete implementation until their attributes do not change.

#

I think the closest example is using classes in code - if the signature of the method doesn't change, you can modify whatever you want in the class you are using, and those are 2 different files so 2 different people can work on that at the same time.

timber tide
#

In a sense if you did want to go out of your way you could probably remake UGUI button

#

assuming you want to make the drawer for it

forest wolf
#

It can, but communication between those components will be harder. You can make your healthbar and coin count so you can 'drag & drop' them as part of the parent document ui

#

though you probably could just make ui document properties for those and drag & drop them there, however if it's a large project, long term I would prefer to have something that has a clear component defined. Probably it is time for me to make a youtube tutorial about it. I was thinking about it for a while

hybrid cobalt
#

Oh! you mean make the healthbar and coin count components that show up here?:

forest wolf
#

yep, exactly :)

timber tide
#

I think that's fine? I think the larger problem is if you do have an independent button inside of a gridlayout doc, which I don't think the prefab idea would work.

#

but of course can have those elements in independent docs like how those style sheets work and build upon it on that doc

#

but for healthbar that doesnt need to be contained in a layout then its own doc/gameobject seems ideal

hybrid cobalt
#

I see. Since I look to work with the UI without tedious workarounds or tight coupling, I'm leaning more towards UGUI, but if the UI Toolkit fits the job better, then I'll try to roll with it!

timber tide
#

UI Toolkit is more intuitive that's something I can say for sure. Especially when you start dealing with resizing elements / anchors

earnest patio
#

anyone know why i get a type mistmatch when i try to drag my player in the scene to a serialized field variable for my enemy in the inspector? people online say you cant do this because your enemy is a prefab but i made this enemy in the player scene (which someone else worked on) its not a prefab. the only thing that wasnt made with that enemy in that scene is the script of the enemy. im referring to class names correctly

grand snow
#

an instance of some prefab in a scene can ref other things in a scene just fine
its a problem when you try to on the prefab asset itself.

#

Type missmatch can also appear if you change the type of a serialized field but it already had a value

forest wolf
cosmic dagger
forest wolf
cosmic dagger
forest wolf
green snow
#

Hi, I have a 3 prefabs metal, wood, axe and I can "wield" each one but when Axe gets instantiated, the children of it doesn't, has anyone had this problem before?

#

I also need to explicitly set the axe prefab to active or it'll instantiate as inactive

maiden totem
#

if i have a class BaseSpell and a class FireballSpell that extends BaseSpell, how would i put a FireballSpell into a variable public BaseSpell spell1

#

in the editor

slender nymph
#

by using the assignment operator (or drag it into the slot in the inspector if it is a component)

maiden totem
#

oh wait i forgot to make it an instance 😭

#

my bad

#

i always forget i need instances of classes always

teal viper
green snow
#

yeah

sour fulcrum
#

that + implies the child is an edit of a prefab instance in the scene and not a change made to the actual asset

#

how did you add the cube child

green snow
#

from prefabs/items

sour fulcrum
#

oh forgive me, im mistaking what that + is apparently

earnest patio
visual heath
#

Hello everyone. I have a problem. I created a game and I'm passing changes through json to the server and from there to the client, but at some point the json breaks and I get an invalid json
System.ArgumentException: JSON parse error: Invalid value.

slender nymph
earnest patio
#

No they are in the same scene

slender nymph
#

then if they are both objects in the scene and are in the same scene then the object you are dragging into the field does not have the type of component you are trying to reference

earnest patio
#

I honestly just opted with finding the game object during run time instead of trying to fix it

#

I’m not able to access unity now but I’ll just give a rundown of what I did: I made a scene. Added a 2d sprite called player and other 2d sprite called enemy. I attached an existing script to the player and an existing script to the enemy. I have made sure their class names are properly set. I go to drag player into enemy then it gives me the mismatch error

slender nymph
earnest patio
#

What does type of component t mean

slender nymph
#

what was the variable type

visual heath
#

Do you have any ideas about my problem?

slender nymph
#

considering you've not provided any actual explanation or details about your issue, how would you expect anyone to have any idea about it?

earnest patio
meager siren
#
using UnityEngine;
using UnityEngine.InputSystem;

public class DoorScript : MonoBehaviour
{
    public Transform mainCamera;
    LayerMask layermask;
    float speed = 30f;
    Vector3 currentRotation;
    Vector3 openTargetRotation = new Vector3(0, -135, 0);
    Vector3 closedTargetRotation = new Vector3(0, 0, 0);
    RaycastHit hit;
    float raycastDistance = 2f;

    void Start()
    {
        layermask = LayerMask.GetMask("Door");   
    }

    public void DoorCheck(InputAction.CallbackContext context)
    {
        if (context.phase == InputActionPhase.Performed)
        {
            bool isDoorClosed = transform.eulerAngles.y == closedTargetRotation.y ? false : true;
            bool isDoorOpened = transform.eulerAngles.y == openTargetRotation.y ? false : true;
            if (isDoorClosed == true && RaycastDistanceCheck() == true)
            {
                OpenDoor();
            }
            if (isDoorOpened == true && RaycastDistanceCheck() == true)
            {
                CloseDoor();
            }
        }
    }

    public bool RaycastDistanceCheck()
    {
        bool state = Physics.Raycast(mainCamera.position, mainCamera.TransformDirection(Vector3.forward) * raycastDistance, out hit, layermask) ? false : true;

        return state;
    }

    public void OpenDoor()
    {
        currentRotation = hit.transform.eulerAngles;
        currentRotation.y = Mathf.LerpAngle(currentRotation.y, openTargetRotation.y, speed * Time.deltaTime);
        hit.transform.eulerAngles = currentRotation;
    }
    public void CloseDoor()
    {
        currentRotation = hit.transform.eulerAngles;
        currentRotation.y = Mathf.LerpAngle(-currentRotation.y, closedTargetRotation.y, speed * Time.deltaTime);
        hit.transform.eulerAngles = currentRotation;
    }
}

Do you know why its not working? I havent really learned how callback works.

timber tide
#

Should toss some debug logging to figure out what's not firing

meager siren
#

the entire thing isnt working

timber tide
#

Like can you confirm by printing to the console that DoorCheck isn't being called, even if it doesn't go into the first statement there

#

If not then it's something with the input map (not binded correctly or disabled?)

meager siren
#

doesnt matter Ill just not use callback

sour fulcrum
#

then why bother asking for help 😭

#

if you want to figure out why something isn't working you need to figure out what specificlly is not working

#

which is not "the entire thing"

polar dust
#

Callbacks aren't bad per say, but going off that second screenshot, this seems rather overkill.

A callback for sprinting? And moving?

#

It's not like those wouldn't work, but what's the intention?

slender nymph
#

that's part of the PlayerInput component from the input system

polar dust
#

Ah!

rugged beacon
rugged beacon
#

approximate

meager siren
#

yes I know

#

but what does it do

rugged beacon
#

it compare 2 float correctly

sour fulcrum
#

heres the google search you could have done 😄

meager siren
#

Ill try it out

meager siren
#

but stll helpful

#

lemme try this out

shell sorrel
#

when comparing floats i tend to just decide what is close enough for my purposes can subtract the 2 floats get the abs of them and see if its under a threashhold you decide

meager siren
#

I just didnt understand how it worked so I gave up with it

rugged beacon
#

its the same, i just use the other cause autocomplete

shell sorrel
#

if (Mathf.Abs(a - b) < threshold) {

meager siren
#

I just dunno how to set it up

shell sorrel
timber tide
#

I wouldn't bother with Approx, yeah

#

just don't compare floats by exacts

sour fulcrum
shell sorrel
#

like i cna say 0.1f is good enough or 0.05f or what ever i need for the purposes of this

meager siren
meager siren
#

I'll get a screenshot of my old code rq

#

nvm

#

Idk where it is

#

alright

#

it works

#

buuut

#

its checking the player rotation not the doors

#

fun

cosmic dagger
mint flicker
#

hey i need some help the world ui is not displaying behind my player or objects do i need to add sorting layers Maybe

timber tide
polar dust
# meager siren dw I know what you mean by threshold

Say you have 10.5 - 10 = 0.5, there's a decent difference here, meaning if your "threshold" was 0.1, then the condition if (0.5 < 0.1) would be false, the two numbers aren't similar

However if (0.00001 < 0.1) is true, indicating the numbers are similar

#

Often floats will never be perfect whole numbers, 10.00000032 10.00000047. for all intents and purposes, you can just think of them as both being 10, but to a computer they aren't the same. You would always get false if you directly compared them

green snow
#

anyone know what might be the issue with this? I'm trying to scale the tree when it's been hit but it's not reflecting in the game scene


while (t < popDuration)
        {
            t += Time.deltaTime;
            var popAmount = popCurve.Evaluate(t / popDuration) * popIntesity;
            transform.localScale = startScale + Vector3.one * popAmount;
            yield return null;
        }

polar dust
#

But subtracting them, and having a threshold like if (0.00000015 < 0.001) you can basically ensure that "similar" values will be considered the same

meager siren
#
using UnityEngine;
using UnityEngine.InputSystem;

public class DoorScript : MonoBehaviour
{
    public Transform mainCamera;
    LayerMask layermask;
    float speed = 30f;
    Vector3 currentRotation;
    Vector3 openTargetRotation = new Vector3(0, -135, 0);
    Vector3 closedTargetRotation = new Vector3(0, 0, 0);
    RaycastHit hit;
    float raycastDistance = 2f;

    void Start()
    {
        layermask = LayerMask.GetMask("Door");   
    }

    public void DoorCheck(InputAction.CallbackContext context)
    {
        if (context.phase == InputActionPhase.Started)
        {
            if (RaycastDistanceCheck() == true)
            {
                bool isDoorClosed = Mathf.Approximately(hit.transform.parent.eulerAngles.y, closedTargetRotation.y) ? true : false;
                bool isDoorOpened = Mathf.Approximately(hit.transform.parent.eulerAngles.y, openTargetRotation.y) ? true : false;
                if (isDoorClosed == true && RaycastDistanceCheck() == true)
                {
                    OpenDoor();
                }
                if (isDoorOpened == true && RaycastDistanceCheck() == true)
                {
                    CloseDoor();
                }
            }
        }
    }

    public bool RaycastDistanceCheck()
    {
        bool state = Physics.Raycast(mainCamera.position, mainCamera.TransformDirection(Vector3.forward) * raycastDistance, out hit, layermask) ? true : false;
        Debug.DrawRay(mainCamera.position, mainCamera.TransformDirection(Vector3.forward) * raycastDistance, Color.yellow);
        return state;
    }

    public void OpenDoor()
    {
        currentRotation = hit.transform.parent.eulerAngles;
        currentRotation.y = Mathf.LerpAngle(currentRotation.y, openTargetRotation.y, speed * Time.deltaTime);
        hit.transform.parent.eulerAngles = currentRotation;
    }
    public void CloseDoor()
    {
        currentRotation = hit.transform.parent.eulerAngles;
        currentRotation.y = Mathf.LerpAngle(-currentRotation.y, closedTargetRotation.y, speed * Time.deltaTime);
        hit.transform.parent.eulerAngles = currentRotation;
    }
}

More code to fill your screen! And a video!
Just watch the video for an awful explanation but a visual representation

sour fulcrum
#

(what is the problem you are looking for help with)

meager siren
timber tide
#

Well, one problem with your code is you're trying to lerp but this is a one-time event

#

You probably want some coroutine inbetween it all

#

otherwise some update logic using states to specify opening and closing

meager siren
split venture
#

Does anyone know any good FPS tutorials with the input system? im pretty new FPS movement so I think it would be a great help

rich adder
split venture
#

Fair point

cosmic dagger
#

Also, Googling "Unity FPS New Input System" will yield tons of results . . .

verbal dome
green snow
#

I added it to a tree prefab I found in the asset store

timber tide
# meager siren can you show me what you mean?

Im out in a minute, but what I'm trying to say is you have methods there which are supposed to be called over multiple frames for it to open/close over time, but this interact method is only ever called once. However, if you don't care about it opening/closing slowly and don't mind if it's instant then you'd probably want to look into other methods of rotation.

verbal dome
green snow
#

yup that was it thanks

solemn fractal
#

hey hey everyone, how are you ?

I was using normally my Unity now, and suddenly after weeks using without a problem. My underlines red is not workig, and the AI inline that helps me complete things also not working. Any ideas?

hot wadi
#

!ide

radiant voidBOT
hot wadi
#

Also, wdym by "AI inline"?

slate badge
#

hey there, i followed this tutorial https://youtu.be/dcPIuTS_usM?si=hLK-v7InA-SsB6aa to make a dialogue box with choices. But how do i make it where if they choose a certain choice, smth in the game also changes rather than only the text.
ex: if the player gets the question wrong, they lose one life.

The video utilizes the dialogue asset so i dont know if its possible, thank you!

In this Unity game development tutorial, I'll show you how to create a dialogue system with choices using Unity's built-in tools. This interactive system is perfect for creating immersive games with branching narratives.

Whether you're a beginner or an experienced game developer, this tutorial is a must-watch for anyone wanting to add a dynamic...

▶ Play video
keen dew
#

The video doesn't use any assets but you can put whatever code you want in the SelectResponse method that's called when the player makes a choice

naive pawn
slate badge
#

How do I get this dialogue asset? I can't seem to find it in my unity version

keen dew
#

You make it yourself. The entire video is about making it

slate badge
#

Yeah my bad, shouldve watched the video carefully

#

did not know u can make ur own assets in the files

polar dust
# slate badge did not know u can make ur own assets in the files

Its quite a nice feature of Unity, another handy thing is you can add things to the top row of the editor (with the File, Edit, Assets... row), like this:

    [MenuItem("MyThings/HelpfulStuff/Do Something")]
    static void ReloadDomain() {
        EditorUtility.RequestScriptReload();
    }```
slate badge
chrome apex
#

I have a joint object anchored to a target object. Then I have a camera following that joint object.

How can I make it so that I clamp the camera on the local x relative to the target and also make the x an absolute value?

It would be easy if it were parented to the target but I shouldn't do that for the joint

astral void
#

if you have a for loop within a for loop and use break, does it break outside of just the for loop break is in or out of both of them?

keen dew
#

That should be pretty easy to test yourself but it only breaks the loop it's in

astral void
#

ok sweet ty

naive pawn
astral void
#

ok cool I assumed as much

naive pawn
#

some languages have labels to be used with break/continue and/or goto as well

grand snow
#

Good old goto

#

Still useful in c or exceptionless cpp

placid jewel
naive pawn
#

it's pretty useful

#

it's easily overused though

#

so if you don't have the experience to use it well, avoiding it altogether would probably be better

placid jewel
#

I agree it's useful, but the reason given was that there's no way to tell what part of a function the goto was used in if there are multiple

grand snow
#

It can be used for re using cleanup code in a function

naive pawn
#

this is simply false

placid jewel
naive pawn
#

it's hard to read at a glance sure, but if it's hard to trace with a little reading? that would be overusing it

naive pawn
knotty river
#

hey i have an issue

naive pawn
#

!ask

radiant voidBOT
# naive pawn !ask

: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 #🌱┃start-here

knotty river
#

i am trying to make my gameobjects glow for aesthetic

#

i am trying to use post-processing but it doesnt work

naive pawn
#

how sure how that's a code issue

#

ask in #1390346776804069396, and provide some details about the issue (specifically, describe how exactly it isn't working - no result? wrong result? errors?)

placid jewel
# naive pawn - the program can tell, it's called static analysis. compilers wouldn't be able ...

From what I remember of the conversation I had with him after the lecture (it's been a little while) I think he meant more that it could very easily lead to logic errors in the program.
It might be relevant to note that this was a class specifically based around designing algorithms in C, so manual memory allocation/deallocation and general control over what state all variables in the program are at at all points was heavily focused on.
Anyway, I know that in general goto's aren't forbidden, but I was still under the impression they were bad practice

naive pawn
#

I think he meant more that it could very easily lead to logic errors in the program.
i don't see how that relates to "for the program to tell", but yeah, that is true - that would be a case of misuse though

#

gotos aren't bad practice, using them wrong is bad practice - but it's easy to use them wrong, so they may as well be bad practice if you don't have experience yet

that applies to a lot of things, actually...

ripe shard
#

practically all uses of goto are wrong and unnecessary, this is often simplified to goto == bad, using goto to break nested structures is the only real usecase (single exit cleanup) and should only come up in multidimensional iteration. Though even there it’s not strictly necessary.

placid jewel
# naive pawn > I think he meant more that it could very easily lead to logic errors in the pr...

That might not have been the exact right wording, but I think what he said was, if there are two goto statements that go to the same place, there isn't a (non-hacky) way for the program to know which goto statement was the one that got hit
Example:

if(condition) {
  //code
  goto position1
}
else {
  //code
  goto position1
}

//later down the line
position1:
//more code

Though I'm not exactly sure, since as I said, it was a while ago.
I do think that after looking back on it, that was most likely to prevent semi-beginners from getting used to using it wrong.

naive pawn
#

oh, yeah that's true. but if you have something like that you wouldn't care where it came from

placid jewel
naive pawn
#

otherwise you could have some sort of state variable. wouldn't consider that hacky

#

honestly from the sounds of it - he's making valid points but also exaggerating to dissuade usage

ripe shard
#

The badness of goto cannot be overstated. You may be able to live with it if only you will have to touch the code and you use it in a strong structured way by convention. As you would when writing assembly

naive pawn
ripe shard
naive pawn
#

aw cmon, let me have a little room to be creative. otherwise it'd just be "gotos are the work of the devil and anyone who even thinks about it deserves a death sentence"

ripe shard
#

at the end of the day structured constructs are implemented via goto. structured code that uses goto is the bad thing, not goto used to create structure

grand snow
#

I think using goto in c# is bad because we have many language features that are better suited
In C its a different story.

placid jewel
grand snow
ripe shard
vague socket
#

If I was a beginner and ran into people talking about malloc on a beginner channel I'd probably run screaming for the hills.

grand snow
#

funny joke

vague socket
ripe shard
placid jewel
vague socket
grand snow
#

people asking for help here hardly know any c#

#

so yea its not fit for here but people refuse to use code general 🤷‍♂️

sour fulcrum
hot wadi
#

I got this Theme SO that is used as addressable to pack my theme data. The PrefabList is supposed to contain segment prefab references that will be picked randomly to be spawned.
It works fine, but I'm wondering if I'm overusing AssetReference here. Since async operation is quite costly, should I switch back to just normal references? What are the exchanges?

{
    [System.Serializable]
    public struct ThemeZone
    {
        public float Length;
        public string Name;
        public AssetReference[] PrefabList;
    }
    [Header("Objects")]
    public ThemeZone[] Zones;
}```
grand snow
#

(another example of non beginner topics in this channel)

vague socket
#

I saw someone in a music context once say that the problem with tutorial-based learning (rather than something like one of the pathways on learn.unity.com) is that you end up with a musician who can't play C-major asking about phrygian dominant.

#

not throwing shade at you @hot wadi though. Your question made me go look up an aspect of SO's that I didn't know about.

naive pawn
placid jewel
naive pawn
#

definitely

#

not all languages have goto, as well

vague socket
#

just plain function calls and matching arguments -- what you pass into a function as in '3' and '4' in sum(3, 4) with formal function parameters -- as in 'x' and 'y' in public int sum (int x, int y) and then sorting out what is returned... that's probably overload already. I remember types being not that fun as a beginner.

naive pawn
#

-# uhh, is this in relation to a previous message? im kinda confused

vague socket
#

oh sorry. I sort of took a cognitive leap from goto, and breaking in and out of loops to something more basic.

#

I wasn't flexing... I'm legit remembering what was hard as a beginner.

naive pawn
#

oh yeah no i don't have an issue with it, i was just confused which message it was meant to reply to lol

hot wadi
grand snow
#

why are you replying to them 😆

vague socket
hot wadi
#

Ah, yeah, sorry wrong reply

vague socket
#

the general theory (again to keep it beginner friendly) being that when you request a resource over the network you can't just halt all progress and wait for it to come back, you have to basically say "when this resource is ready, call me back and we will handle what you loaded"

#

(that's a lot of reply from me for being the wrong recipient of a message though! sry! )

grand snow
#

what is going on

worthy veldt
#
for (int j = 0; j < myList.Count; j++)
{
    if (myList[j].TryGetComponent(out MyType myType))
    {
        myOtherList.Add(myType);
    }
} 
``` i have this being red highlighted in vs with suggestion to invert the if ``if (!myList....){continue;}myOtherList.Add(myType);`` why is this "better" ?
slender nymph
#

that suggestion seems a bit aggressive here, but if you were doing multiple things inside that if statement and nothing else was happening after it, then a guard clause would make sense for readability

naive pawn
#

what's the message on the highlight, exactly?

hot wadi
#

Not neccessarily "better"

naive pawn
#

oh, i misread as it being !myList, got real confused there for a sec lmao

worthy veldt
#

this red highlight bothers me, ill just follow the suggestion

cosmic dagger
#

red would be an error, no?

worthy veldt
#

no not an error message, the code is being highlighted with "Expression to evaluate" if you hover

naive pawn
#

could you show what the highlight looks like

#

(im curious)

cosmic dagger
#

Ugh, why does my Unity license keep disappearing? This ish is annoying . . .

vague socket
#

@avc Think of a loop like a function call in the sense that the loop should really only have one responsibility. If that responsibility is processing this newly found (or not found) object, you continue out of that iteration right away if the object isn't found.

naive pawn
naive pawn
worthy veldt
#

i followd the suggestion and the highlight persist, now suggesting the prev arrangement. wtf

naive pawn
#

wonderful

#

it's probably configurable

vague socket
naive pawn
#

the suggestion was about a guard clause, not responsibility

hot wadi
#

It's just suggestion. Unless u are getting real compiler error, u should keep it simple

magic panther
#

Yall know any tutorials or guides on making 2D physics from scratch, as in without rigidbody?
I tried multiple times and there's always some weird thing that messes up.

#

At least collisions limited to static objects, entities in my game don't usually interact with anything besides triggers and static surfaces

slender nymph
#

fun fact, but it is apparently more expensive to move a 2d collider without a rigidbody than it is to move it with one

ripe shard
slender nymph
#

i have to find the source that went in depth on it, but the gist is that the collider is basically recreated each time it is moved if you aren't using a rigidbody (at least for 2d, this likely does not apply for 3d)

naive pawn
#

i think ive heard that for 3d as well

#

it gets deleted and recreated in the physics scene, rather than getting moved

old remnant
#

Hey, I'm trying to learn the "new" player input and I am having problem to change directions with Pitch and Yaw by using mouse as the controller. is it not the basic one to have the binding as delta (mouse) because it doesn't seem to work even though mostly everything is connected

naive pawn
magic panther
#

So for instance I want to make a square that can move left and right and jump, while stopping by collision with static object.
WIll this (if this is what you meant) teach me how to do that?

ripe shard
old remnant
ripe shard
#

Caveat on custom physics: you should be able to point to a measurable/provable issue that requires a custom engine/system, otherwise you're likely reinventing what Box2D/PhysX give you. You still have to live with the same problems that they have, you can just apply more constraints and optimizations.

ripe shard
#

Usually you can extend the existing physics system with your customizations

slender nymph
#

also fun fact, but in the 6.3 beta there's a new low level physics api for 2d if you really want a custom(ish) solution without doing everything 100% manually

wintry quarry
ripe shard
#

naturally

magic panther
#

Yeah I wanna know more about game physics in general

#

that's the reason behind my question

ripe shard
#

one unfortunate thing with learning projects that tackle really tough problems: they rarely get to the interesting/hard bits (due to time/cost)

#

but even a general awareness of the problems and theoretical solutions is very valuable.

blazing kiln
#

hi, I was wondering if properties mess up serialization and therefore the ability to save games, and if so what the solution is (not using properties for data which needs to persist?)

grand snow
blazing kiln
wintry quarry
grand snow
#

the unity serializer for json wants fields that fit the normal unity rules

wintry quarry
#

You need to just follow the rules of whatever serializer you're using

#

some of them work with properties, some don't

blazing kiln
#

oh okay I'll just look into what serializers there are then

naive pawn
#

well, properties don't really store data at all, they define how data is retreived and replaced
you still need a field to actually store the data, and in the case of something like float x { get; set; }, there's a backing field automatically generated

wintry quarry
timber tide
#

jsonUtility follows the same serialization ruleset from what you see in the editor

wintry quarry
#

normally objects in memory are sort of strewn wildly around in RAM

#

serializers put everything nicely in "serial" order, so they can be written cleanly to a file

blazing kiln
timber tide
#

are you saying you're trying to serialize auto properties? That's not something you can even serialize in the editor without specifying the backingfield

blazing kiln
#

hmm so I'd have to actually write out the backing field too then?

#

that's okay, just a bit more text

timber tide
#

[field: SerializeField] public int value { get; private set; }

scarlet pasture
#

Hey, i have the Problem that if i code the "Global Audio" my Game does not function i have this code from the Docs. gived him the References but still it does not work for me.

naive pawn
#

what exactly doesn't function?

scarlet pasture
#

i change the Slider, and the Sound of my Game does not getting effected

naive pawn
#

ok, so not a code issue

scarlet pasture
#

okay, so it must be the Audio Mixer

naive pawn
#

did you route the audiosource through the respective mixer?

scarlet pasture
#

okay, i will ask there

#

thanks!

#

now i know the code is not the Problem

neat smelt
#

I want to make a system where, when the player does a specific thing, they get XP, and for every 100 XP, they get 1 Point.

what would be the best way to code this type of system in non-Unity 6 versions? I was first thinking of making it function with a threshold, where a hidden variable is added to with gained XP until it reaches 100, at which point the hidden variable is reset to 0 and the player is given 1 Point.
The problem with that, however, is the possibility of getting more than 100 points at once, which could cause the rest of the XP to be wasted, or not give Points at all...

keen dew
#

Unity version doesn't really factor into it

#
while(xp >= 100) {
  xp -= 100;
  points++;
}
neat smelt
naive pawn
#

or,

points += xp / 100;
xp %= 100;
neat smelt
naive pawn
naive pawn
#

a •= b -> a = a • b for arithmetic/bitwise operators

#

% itself is the modulo/remainder operator

warm sequoia
naive pawn
#

split it into smaller problems, and start by googling/researching

tough lagoon
#

Personally id guess its masking and moving a sub image in a world space UI.

solar hill
#

also from a design standpoint it feels like a horrible way to handle a map 🤔

rocky canyon
#

its kinda meh

#

a more static map would be better imo with a rotating marker

solar hill
#

it feels like what far cry 2 did just overdone

rocky canyon
#

but thats all it is tho is a rotating world space UI element i believe w/ masking

solar hill
#

and no attempt to hide the lack of tiling on the map itself

rocky canyon
#

and tacky nothingness of a border

solar hill
#

jinx or whatever

rocky canyon
#

the white behind it is gross 🤮

solar hill
#

its a nifty concept that should probably be draft number one out of like 5

#

lol

rocky canyon
#

i've been meaning to make one in all honesty

#

more like an iso holographic map that does the same thing..
-# (its basically the same mechanics you use for a top-down pannable game, like map scrolling, panning, zooming etc )

true pine
#

is there a way to cancel an Invoke() under a certain condition? I want to make my reload sequence interruptible if the user is still able to fire.

solar hill
#

when you said holographic

#

where the map just appears on the ground around you

#

thats also nifty im probably gonna try doing that honestly

true pine
#

didn't know that exists

solar hill
#

i didnt either until i took 5 seconds to google it

#

:)

sour fulcrum
#

out of curiosity

true pine
#

which I would advise against watching because apparently the code bro writes is utterly horrendous

sour fulcrum
#

yeah makes sense

#

generally you just wouldn't used invoke like ever tbh

#

Coroutines are what you'd be better off using and what you'll find better resources on online

#

a big benefit of them for this specific problem is you can store the actively running coroutine and cancel them specifically

warm sequoia
kindred dome
#

so i have some text inside a panel, but if the aspect ratio changes by a large amount then the text ends up too big for the box, any idea how to fix that?

grand snow
rocky canyon
#

you could use a content size fitter or something i believe

grand snow
#

no you dont need that

#

auto size for the text does the job fine

rocky canyon
#

ah cool.. gotcha

kindred dome
#

so it stays in the box now but why does the box get so stretched?

grand snow
#

its anchors probably

timber tide
#

welcome to UI

kindred dome
#

is that how your supposed to put the anchors?

solar hill
grand snow
kindred dome
#

i love discord hiding channels

solar hill
#

i dont think thats how that works

kindred dome
timber tide
#

yeah, they just started doing that with the new channels.

kindred dome
#

wow thats really annoying

timber tide
#

and I swear the tab to enable the channels is buggy at times and the UI breaks

kindred dome
#

i cant scroll through the browse channels thing because it keeps jumping around

#

i think because the channel descriptions are too long

tough lagoon
kindred dome
#

so ive got a script for switching scenes its just

using UnityEngine;
using UnityEngine.SceneManagement;

public class SwitchScene : MonoBehaviour
{
    public string sceneName = "MainMenu";
    public void NextScene()
    {
        SceneManager.LoadScene(sceneName);
    }
}``` and i was thinking instead of typing in the scene name, could i just set the public variable to be the type Scene and then just drag a scene into it in the inspector
#

but it doesnt seem to work

visual heath
#

I've created a client-server on a pure tcp protocol, and now I want to transfer its creation to netcode for game, but I'm facing a misunderstanding. Let's say I can send a value through sertverRPC and clientRPC, but I don't understand where it will go and so on. So, should I store a copy of the server class on each client to access the server's methods?

kindred dome
wintry quarry
#

you would have to type the name

#

the inability to serialize a scene reference is a long-running frustration in Unity.

visual heath
#

So it should be like this?

wintry quarry