#💻┃code-beginner

1 messages · Page 792 of 1

frail hawk
#

is fadeduration correctly declared

solemn cedar
frail hawk
#

ok may i ask why you are not using a simple animation for this

solemn cedar
#

that might be a better idea

#

i'll try that

frail hawk
#

that is why animations exist

radiant voidBOT
#

success @praetorblue muted

Reason: Too many messages with links sent.
Duration: 29 minutes and 39 seconds

frail hawk
#

evil bot

naive pawn
frail hawk
#

about time to overthink it

fickle plume
#

!unmute 179367739574583296

radiant voidBOT
fickle plume
#

was that one too many edits with a message with a link?

solemn cedar
rough granite
signal gyro
#

quick question, i have a trigger that isnt showing up in my inspector (i have a door opening for a pressure plate type of thing and the pressure plate isnt showing up) to be more specific it does show up once then it just doesnt appear as an option

naive pawn
#

what do you mean "as an option", where are you expecting to see it?

signal gyro
#

i try to drag and drop it and it still doesnt let me

naive pawn
#

just drag the object in

#

is it the right type for the collider you have?

signal gyro
#

yup

naive pawn
#

what type is it, and what component are you trying to target on that other object

signal gyro
#

its just one door thats not cooperating

signal gyro
naive pawn
signal gyro
#

one door works pefectly the other is giving me this problem

naive pawn
#

what type is the field declared with, and what component does that pressureplate have

signal gyro
#

im making a rube goldberg machine so i didnt think itll give me an issue

naive pawn
naive pawn
#

what type did you declare for that field

signal gyro
#

trigger

naive pawn
#

and you have a class called trigger, or...?

naive pawn
#

and that pressure plate has the trigger? (don't assume, go check)

signal gyro
#

i used for like 4 other scripts all worked

#

yea it does

naive pawn
#

and these are both in the scene?

#

you aren't trying to drag something from the scene into a prefab, right

signal gyro
#

yea

naive pawn
#

what happens when you drag that object in

signal gyro
#

it just give me this 🚫

#

on my mouse

wintry quarry
#

WRong type

golden notch
#

it was yeah

fickle plume
#

This is a code channel. Do you have a relevant question?

solar hill
#

This is also such a specific question with no 1 clear answer lol

#

The equivalent of asking "how do i make a million dollars"

solemn cedar
#

anyone know why my game functions so differently in build compared to editor?

#

its not a specific issue this time but so many things work in editor but not in build

solar hill
#

Can you be more specific?

#

First thought is anything that is frame rate dependant being affected because build runs faster than the editor

solemn cedar
#

but its perfectly fine in the editor

solar hill
#

So ui issue?

#

If thats what you mean by "click"

solemn cedar
#

im using the legacy input system so just

#

mouse 0

#

i could try switch to the new one

chrome apex
#

Not code related but no proper channel for it...

Anyway, is there a way to search for components. I have a capsule collider on my player somewhere but cannot for the life of me find where as I got a billion children.

Is there an easy way to do this?

slender nymph
polar acorn
chrome apex
solemn cedar
#

it works in editor but the script isnt there in build

slender nymph
#

how have you determined that the "script isnt there in build"

#

-# i'm gonna bet this is actually a script execution order issue causing an NRE

solemn cedar
zenith cypress
# chrome apex Not code related but no proper channel for it... Anyway, is there a way to sear...

Since you said not code-related (for the future) you can do t:ComponentType in the hierarchy to find objects that have a component type. Can do that in your player prefab easily, or can shift+F the player object in the scene (hides everything else) then do the same search and ignore the ones that have the hidden icon. Quick Search lets you do more refined searches too, but the prefab type search is the simplest.

solemn cedar
#

there are probably much better ways to do this but

#

first way i could think of

slender nymph
solemn cedar
#

the noise doesnt play in editor and the game works fine

#

but in build it plays and breaks

slender nymph
#

that doesn't mean that a "script isnt there in build"
that just means a variable is null and that the object you are calling GetComponent on does not have that component attached.

solemn cedar
#

alright

slender nymph
#

have you actually bothered to read the logs to see if there are relevant errors or did you just ignore that part and pretend you can debug without doing it?

solemn cedar
#

where do i find the logs?

slender nymph
#

!logs

radiant voidBOT
# slender nymph !logs
📝 Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

languid stirrup
#

how can you switch characters and their abilities i have some ability and gun scripts for characters but how do i switch characters and switch all the abilities

rich adder
solemn cedar
slender nymph
#

errors?

solemn cedar
#

this is a lot of text, anything specific?

slender nymph
#

you need to look for errors. that is as specific as i can get because we literally do not know if there are any errors or what they are because you haven't checked yet

rich adder
#

search function will help you out

solemn cedar
#

[Licensing::Client] Error: HandshakeResponse reported an error:
ResponseCode: 505
ResponseStatus: Unsupported protocol version '1.17.4'.

found this

slender nymph
#

that looks like it's from the editor logs

#

or possibly the hub logs

solemn cedar
slender nymph
#

my bad, i assumed you knew how to read and use common sense and would click the "Documentation" link there since i said you needed to check the player logs and didn't say anything about the editor or hub logs

solemn cedar
#

d3d12: failed to query info queue interface (0x80004002).

#

ArgumentException: The Object you want to instantiate is null.
this looks relevant

#

i have no clue why but the build also seems to be outdated

#

i'll make a change to the project and make a whole new build folder and its still an older version

#

i've tried clean build

solemn cedar
slender nymph
#

point to anything i didn't "explain fully", other than expecting you to use your eyes with the bot message

solemn cedar
#

anyway im not having an argument here, goodnight

slender nymph
#

my guy, you literally started this

solemn cedar
#

your attitude was off-putting and hostile

slender nymph
#

your lack of effort in troubleshooting your issue was off-putting and hostile

solemn cedar
#

i have been stuck on this for the past 3 hours, believe me i have tried to put full effort into this

#

anyway fixed the problem, turns out it was the build settings causing the issue

slim solar
#

Lets you view logs in builds so you can log a bunch of stuff to narrow down exactly what's happening, or even see errors

solemn cedar
#

oh thanks! sounds useful

slim solar
solemn cedar
#

gpt was just as lost as me 😭

rich delta
#

Is it recommended to use public sealed class for a good maintanable code, for the classes that are not ment to be inherited ?

#

I do not see sealed often in scripts, so just wondering for the best practices

slim solar
# solemn cedar any specific models you recommend?

lol I use GPT, it's good at copy+paste random ass errors, but then again you need those errors. With that plugin you'd be able to see the errors better in game, describe how it was missing from the build, etc. I feel like you just didn't have enough info for it

polar acorn
slender nymph
warm iris
#

what is the current working function?

#

instead of ontriggerenter

slender nymph
#

!IDE 👇 make sure your IDE is configured properly so you can autocomplete methods so you spell them right

warm iris
#

nvm I mispelled it

radiant voidBOT
slender nymph
#

including for methods like OnTriggerEnter?

warm iris
#

yeah I think idk why it didnt work

#

I mean I either didnt use it

#

or I removed the i by accident

teal viper
#

Assigning it to a class field on start/awake and then just reusing that variable should fix it. The issue is that you're assigning a method which basically creates a new delegate.

real thunder
#
  public class Foo
  {
      public void DoSomething() { /*nop*/ }
  
      private Action _doSomethingDelegate;
      public Action DoSomethingDelegate
      {
          get { return _doSomethingDelegate ?? (_doSomethingDelegate = DoSomething); }
      }
  }

hm

#

I think I starting to understand, you tell I can assign them on awake?

#

this piece of code makes it to cache a delegate a first time it gets called

#

I think

slim solar
#

Is this where I can ask about 2D collision issues & colliders?

brisk flume
#

can someone with some background help i am a college student were most of my calsses are in c++,
the only languages i really know are python and c++ so is transitioning into c# as a begginer in unity easy or ???

teal viper
real thunder
#

are there even things which C# can do which C++ can't?

lusty minnow
#

Hi Im doing the unity sprite flight course and so far I've got obstacles the player and a scoreboard that works and I don't just copy paste the code like I can point at almost any piece of code and explain what it does. But I can't write it myself, I just won't remember what to do exactly. So im asking whats a better way to learn all this?? What am i doing wrong

grand snow
teal viper
teal viper
real thunder
#

I have to say I just use

private delegate void DoState();
private DoState doState

And have no clue what Actions are

grand snow
#

Actions are a pre made delegate type

#

(with generic versions!)

slim solar
#

Hey if I have a collider2D on my player and another object, which one triggers OnTriggerEnter2D?

real thunder
#

like assigning float to a float

real thunder
#

instead of a value

slim solar
#

do I need a rigidbody2d on one of them? and does the function only run on that one?

real thunder
#

I thought delegate is a type of a variable

slender nymph
teal viper
teal viper
real thunder
teal viper
#

Why not?

real thunder
#

omitting a step

teal viper
#

You're not. It's just implicit. Just how you can assign an int to a float without explicitly casting it.

slim solar
slender nymph
slim solar
#

Yeah that link doesn't really say much

slender nymph
#

it takes you through everything you need to check. you just need to actually read it

slim solar
#

I read it

slender nymph
#

apparently not

slim solar
#

Here's the player collider, I tried with trigger on/off, dynamic/kinematic

#

And the damage ring, 'ExpandingRing' script should run OnTriggerEnter2D(Collider2D other) but doesn't

#

Both are on default layer

slender nymph
#

okay and what did the link i sent say about a kinematic rigidbody and a static collider with regards to OnTriggerEnter2D?

grand snow
#

erm the collider marked as trigger gets the trigger message (the screenshots make me think you did the opposite)

slender nymph
#

both objects involved in the trigger overlap do

slim solar
#

IsTrigger is off on both

#

that was just in the img as i was trying diff stuff

grand snow
slim solar
#

And tried both on

slender nymph
#

if only there were some convenient Trigger matrix (2D) you could look at to see what settings work to cause a trigger message to be sent

slim solar
#

And opposites lol

#

Those links are always fully understandable to unity beginners

#

That's why discord exists, no?

slender nymph
#

if you won't bother putting in the effort to read the information in that link then i'm done helping.

#

it takes you through literally everything you need to check for this

grand snow
#

unity huh how exists because the same things get asked all the damn time 😆

slim solar
real thunder
slender nymph
grand snow
slim solar
#

I'm trying my best to read that shit man, you're not very nice nor helpful

#

I'm using a trigger, I don't know what a kinematic trigger is

slender nymph
slender nymph
slim solar
#

I have a rigidbody with a collider trigger, and another collider trigger

#

You know how quickly the answer could have been given instead of this circle jerk waste of time

real thunder
#

for some reason I was assuming delegate was a value type

slim solar
#

Why does this discord even exist, just tell everyone to google their problems and read the docs lol

slender nymph
slender nymph
slim solar
#

why are you even helping blackhunter with delegates, all that info is online, send him some links

slender nymph
#

why are you still here if you don't want the help that was provided

slim solar
#

it's just 2 gameobjects with a collider on each and a rigidbody on one. Can't see it being a super complex problem

#

both have trigger on, with a rigidbody

#

you can link me all over the internet, that page says it should work

#

it fits within the matrix

slender nymph
#

great! you made it through step two. have you considered going through the remaining steps

teal viper
#

You should probably have shared your code at the very start to make things easier for all of us.

#

As well as the debugging method.

slim solar
#

If I hot-reload anything it magically starts working, but starting playmode it doesn't work, until I do some hotreload

slim solar
teal viper
slim solar
#

Funnily enough, asking a simple question did the trick, instead of repeatedly telling me to read the docs like im a child

slim solar
#

But yeah everything works as expected now haha, thanks!!

teal viper
slim solar
#

It's 100% on me, but it's nice to know that everything should be working, instead of making me re-read the same beginner shit over and over like im an idiot

#

Sometimes all it takes is knowing that everything looks right, to figure out the problem is elsewhere

teal viper
tiny bloom
#

any idea why this is happening? im adding a new button but it's not showing in editor or play mode

slim solar
slim solar
teal viper
slim solar
#

I guess we all have our good and bad days 🤷‍♂️

edgy sinew
#

boxfriend blushie UnityChanCheer Unity

frosty yarrow
#

public void OnShoot(InputAction.CallbackContext val)
{
if (val.performed)
{
Debug.Log("idk");
}
}

The could should print idk when i hold the shoot and stops when i stop holding

ivory bobcat
#

What does it do instead?

frosty yarrow
slender nymph
#

that's because that's not how input actions work. that OnShoot method is only called when the state of the input changes in some way (depending on how you set these up to be called). you're also checking if the input is in the performed state, so you only get one log
if you want something to continuously happen while holding the button, then you need to subscribe to the started and canceled events, flip a bool depending on which state the input is in when the method is called, then use that bool in Update or something that is called repeatedly

golden notch
#

GameObject instance = Instantiate(item.GroundPrefab, renderModel.transform);
regarding this, is this the same thing as dragging a prefab onto the renderModel? If so, why is it going way outside of where it's supposed to be?

slender nymph
#

take a look at the prefab, what is the prefab's transform position

golden notch
#

it's different every time

slender nymph
#

i said the prefab

golden notch
#

how do I check that?

slender nymph
#

by looking with your eyes?

golden notch
#

you mean this area?

slender nymph
#

great, so it is at 0,0,0. now what is the position of the object you are spawning it as a child of, this would be the object assigned to your renderModel variable

golden notch
slender nymph
#

before continuing further, does that object move at all or does it remain in that exact position at all times?

#

more specifically, is it possible that this object is being moved before the child object is instantiated?

golden notch
#

no?

#

so it seems to be the same area

#

until i move

slender nymph
#

something else is changing the object's position then

#

wait, is this not happening at runtime?

golden notch
#

nope

#

in editor

#

most recent version too

slender nymph
#

and when you cause this code to run, does it perhaps spawn close to the middle of where your scene camera is looking?

golden notch
#

little under middle

zealous talon
#

hello guys, im trying to build my game on my mac m1 and im trying to download the windows standalone support, but the installer always fails in the end. does anyone know why?

golden notch
slender nymph
# golden notch little under middle

yeah so this is because of a setting in the editor for spawning things into the scene, there's a setting that determines whether a prefab instance will be spawned at the world origin or where the camera is looking. and because you aren't specifying a position and this is happening in edit mode, it's probably taking that setting into account

slender nymph
radiant voidBOT
# slender nymph !install 👇 also not a code question. and you should translate errors that aren...
When Unity fails to install checklist
  • Make sure you have enough space including on C: drive.
  • Check that it's not being blocked by antivirus/security programs.
  • Look through the logs for a real reason why the setup fails they are pinned [here](#💻┃unity-talk message).

If you still have issues, perform a clean install in another location:

  • Install the Hub and Unity in a non-system drive or a clean new folder in the root of C: drive.
  • Failing that use the recovery Refresh option or reinstall OS entirely then repeat the previous step.
golden notch
#

well i can't see it regularly either (during runtime)

slender nymph
#

am i supposed to know what you mean by that

golden notch
#

ok so it is spawning where it is supposed to, i just need to rotate it.

slender nymph
golden notch
#

but it's not showing up in the render texture

zealous talon
#

yeah its not unity but the windows support package for build on m1

#

but thanks anyway

slender nymph
#

and yet the troubleshooting steps are the same

#

just because it is a module doesn't suddenly invalidate the steps that were provided. there's nothing special about modules that make troubleshooting installing them any different from troubleshooting the editor install

zealous talon
#

if you say so

golden notch
#

ayy i set the render layer and it's working, but it seems too high now.

golden notch
#

I deleted the instantiation after i used it, why is it still showing in the second iteration?

#

wait why is there 3 in the second pic?

#

i give up... idk why it's showing THREE axes

ashen harness
#

Anyone personally try any good Tower defense tutorials that were actually solid? I have no clue where to get started on the code for one 🤣 (also no idea if i shoulda asked here or in unity talk but yeah)

golden notch
#

it's not destroying the last element before it resumes

#

(Fixed by adding a instance.active = false;)

#

and sometimes this happens too

#

ok so now there's only one like it should be, still sometimes red though

#

and even though the position of the two axes are the same, they are somehow different

cosmic dagger
upper pebble
#

I'm trying to create a monobehavior script but it keeps making this error, how do I fix this? [Worker0] Import Error Code:(4)
Message:
Build asset version error: assets/_unity essentials/scripts/danger.cs.meta in SourceAssetDB has modification time of '2026-01-07T07:00:21Z' while content on disk has modification time of '2026-01-07T07:00:22Z'

#

All I'm doing is right clicking in the project window and creating the script there

#

This chat is dead lol

fickle plume
#

!ask @upper pebble

radiant voidBOT
# fickle plume !ask <@793726806506733578>

: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

median hatch
naive pawn
#

ok we do not need that here

upper pebble
naive pawn
#

ok, let's not start this, it's not gonna be productive

naive pawn
#

in general research is the first step you should take

upper pebble
naive pawn
#

also keep in mind that other people would encounter the error with different file names and different timestamps, so you could remove those from your search query

#

i googled SourceAssetDB has modification time of while content on disk has modification time of and got some concise results, for example

verbal swift
#

Is it harmful to lerp camera movement for small visual effects? I know lerp is frame dependant but I dont know the extent so I was wondering if something small like fov change or movement bobbing would be bad to lerp

faint bough
#

Could I get some help on some code I'm tryna do from a tutorial that isn't working for me

#

So basically I'm following this tutorial

#

In this Unity tutorial we're going to look at how we can implement a robust ground check using Unity's SphereCast method. We'll then use this to prevent infinite jumping by ensuring the Player is grounded before allowing another jump.

This is the fifth video in our series showing how to make a full 3D platformer game in Unity.

The playlist for...

▶ Play video
#

to stop infinite jumping in my game, and I'm following it as close as possible, but I keep getting all of these errors that the person in the video isn't getting. as far as I can see I've done it exactly the way they've typed it, but there's still issues. the main one being "the name '_capsulecollider' does not exist in current context" and the only way I can seem to get rid of it is by removing the underscore, but I'm worried it will mess it up.

#

Ok well I fixed the underscore thing but there's still quite a few other issues

naive pawn
#

imo, you shouldn't use wronglerp for anything

verbal swift
verbal swift
#

could you send the wronglerp again?

#

whats the command

#

nvm got it

naive pawn
naive pawn
#

also the awake message needs to be Awake

#

have you done unity essentials and/or gone through a c# guide before?

verbal swift
#

for smoothing camera movement its close enough

faint bough
#

I'll do it eventually though

naive pawn
faint bough
naive pawn
#

doesn't matter
i feel like you're just being ignorant at this point ngl

faint bough
naive pawn
#

you're following a video?

faint bough
#

Yeah

naive pawn
#

go check it more thoroughly

faint bough
#

Idk man I'm probably wrong but it looks pretty much the same to me

faint bough
#

That's a screenshot from the video

naive pawn
#

and i'm seeing the difference there already

#

"pretty much the same" is generally not sufficient

faint bough
#

I'm blind as hell man you could put a big red circle around it with flashing lights and I'd still probably miss it

naive pawn
#

their code

faint bough
#

Oh man

naive pawn
#

your code

faint bough
#

It appears I'm not very bright

#

That literally solved the entire thing thanks 🙏🙏🙏

naive pawn
#

well that solves the syntax issue, but not the other compile error

#

you haven't fixed the underscore thing

faint bough
#

I solved those a bit ago I just used an old screenshot by accident

naive pawn
#

if you want to actually make anything yourself that is

faint bough
#

You got a point but I'm doing this for an assignment due tomorrow for my uni game design class, I've only been in it a short while and I'm low-key kinda lazy so I haven't been paying attention very much

#

Also they haven't really been teaching us how to use unity they kinda just give us their own video tutorials to follow

naive pawn
#

ah yes, making a game with a month long deadline on the last day, very common occurance here

#

(joke, in case it doesn't come across that way)

faint bough
#

Nah bro you're right on the money 😭

real thunder
#

preparing for facing those deadlines

#

anyway I am curious why can't I assign a delegate before runtime

sour fulcrum
#

Objects in editor and objects in build are two completely seperate instances

#

You can assign a delegate before runtime, it just wouldn’t be on the same object

#

Hence why we serialize and deserialize stuff

eternal needle
faint bough
#

Just downloaded cinemachine, and there's no "Player/look" option in select input action, anyone know why???

naive pawn
#

perhaps because you haven't made it?

naive pawn
#

also please don't use images of screens, they're terrible to look at

real thunder
#

it seems like I have to assign my states to delegates at Awake which is less convinient than if I could just do that while declaring variables

faint bough
naive pawn
real thunder
#

I don't really want to serialize them

#

that's like different thing right?

sour fulcrum
#

You do want to serialise them

real thunder
#

I can still assign private non serialzied variables in the script?

naive pawn
#

i honestly don't know what you're trying to do here

faint bough
naive pawn
sour fulcrum
#

The amount of misinformation [SerializeField] has done to people

eternal needle
sour fulcrum
#

Serializing saves stuff to file, basically. The inspector shows you things that are serialized. Keep in mind these are two seperate things

#

I’d suggest opening a prefab file in a text editor in order to get an idea of what unity serializes

real thunder
#

this is not really a problem-problem but
I would expect something like

private Action ChasingMovingAction = new Action(ChasingMovingLoop);

to work instead of

private Action ChasingMovingAction
void Awake()
    {
        ChasingMovingAction = new Action(ChasingMovingLoop);
    }
naive pawn
#

the inspector shows you want it wants to show
if in normal mode:

  • if custom inspector, show custom inspector
  • otherwise, show serialized, non-hidden fields
    if in debug mode:
  • show non-hidden fields with serializable types
faint bough
eternal needle
#

it just happens with the constructor if it was valid

naive pawn
real thunder
naive pawn
#

no

faint bough
naive pawn
#

if a field has a serializable type, and it is public and/or marked SerializeField, then it's serialized

real thunder
naive pawn
#

like if that was anything else

#

the type doesn't matter

naive pawn
#

i mean, one of those is clearly not true

faint bough
#

Yea but where exactly am I copying this file from I dong have it

naive pawn
#

just somewhere in your project

#

under .../Assets

real thunder
naive pawn
#

i have no idea what you actually want

#

what are you trying to achieve here?

naive pawn
#

it's such a loaded question

#

you can't do anything before runtime, because runtime is where things happen
but technically you're already in a runtime in edit mode already

real thunder
naive pawn
#

you can't

#

it's not saved to the file

#

the assignment happens at runtime

eternal needle
naive pawn
#

oh my god holy x/y problem

sour fulcrum
#

the float is a value, the delegate and the function your wanting to add to it are references to objects

naive pawn
#

this wouldve been so much simpler if you just said so

real thunder
eternal needle
#

well its clearly an error because it isnt valid c#, they were using that as an example for something they cant do

naive pawn
#

just use () => ChasingMovingLoop() goddamn

eternal needle
#

that doesnt work either

real thunder
#

well yes the error is that

naive pawn
#

sorry, (ThisType x) => x.ChasingMovingLoop()

sour fulcrum
#

you can't because of what this says

naive pawn
#

it's nothing to do with the action

#

this is crucial info

#

stop making us guess

faint bough
real thunder
#

sorry, I just had an assumption people here have a solid grasp on such things

naive pawn
sour fulcrum
#

more specifics just help reduce the questions needed

naive pawn
#

it's your responsibility to provide adequate info

naive pawn
eternal needle
#

i dont see where the confusion lies, they were just asking why that line isnt possible while it has to be done in awake

faint bough
naive pawn
real thunder
naive pawn
#

"i have an issue" <doesn't say what the issue is>

#

so many errors are possible

#

you have to say which one it is

real thunder
naive pawn
#

and the error explains

#

if you said you had an error that you didn't understand, it'd be so much easier to explain the specific part you didn't understand instead of guessing what you're actually taking issue with

naive pawn
eternal needle
#

it's less of a quirk when you see it this way, the delegate part might've confused you more here

real thunder
#

oh that makes so much sense

eternal needle
#

usually if im getting confused with syntax around delegates, I just mentally replace it with a separate type to understand it easier

#

i got more used to it over time but there is the occasion where i'm not thinking straight

real thunder
#

now I am thinking why would that work with statics

eternal needle
real thunder
#

heap vs stack?

naive pawn
#

no

north kiln
#

Entirely unrelated

teal viper
#

Has to do with guaranteed order of initialization. Static fields would always init before instance fields and instances in general(the instance need to be initialized before any methods are called on it).

#

I think.

toxic cloak
#

can i use this functions of a button like onpointerdown onpointerup etc? if so how i want to check if pointer down than do this.

naive pawn
tiny island
#

hi , i Instantiated my enemy because when i tried to destroy it unity said it was destroying the assets and couldn't do that but now the death script technically works without that issue but the Enemy object scene isn't getting destroyed (switched the gameobject for a var)

toxic cloak
naive pawn
#

what are you trying to do?

tiny island
#

i'm trying to destroy the Enemy via collision , the collision does work but told me i was trying to delete the prefab in assets so now i'm trying to Instatiate the Enemy as apparently from a unity Q&A Page it would fix the issue

#

i think i see the problem tho now that you mention the creating and detroying part

naive pawn
#

is the enemy the current gameobject?

tiny island
#

yes

naive pawn
#

and you want the current gameobject to be destroyed?

tiny island
#

yes but it seems i need first to instantiate it or it will go for the prefadb asset instead

naive pawn
#

you already instantiated it

#

it isn't "going for the prefab asset instead", it tries to delete what you tell it to delete

#

if you want the current gameobject to be destroyed, then tell it to delete the current gameobject

#

Destroy(gameObject)

#

why do you even have that SelfRef? 🤨

tiny island
#

it does that when i'm trying to destroy the gameObject

midnight plover
# tiny island

You are not destroying a gameobject, you are trying to destroy the prefab assigned which is an actual file on your filesystem

naive pawn
radiant voidBOT
tiny island
#

@naive pawn do i just send the page link?
sorry first time using posting code

naive pawn
#

after you've saved yeah, it should show a unique code in the url

#

you can try opening the link you've copied in incognito/guest mode to see if you've done it correctly

tiny island
naive pawn
#

you can't destroy a class

#

gameObject and GameObject are not the same thing

tiny island
#

oh mb ,tho that doesn't seem to change anything for the all destroying assets thing

naive pawn
#

show the full script of the class

#

wait no, this is coming from a public method?

#

sounds like you're calling Damage on the prefab instead of on the actual enemy in the scene

tiny island
#

yes?

naive pawn
#

look through the stacktrace, for the line the Damage method. where are you calling it from? check to see if you're referencing the prefab there for whatever reason

tiny island
#

i'm using a Instintiated projectile with a collider for the damage

naive pawn
#

ok, and what's Enemy

#

(also you should not be checking layers like that - it's not wrong, but it's easy to make subtle and hard-to-debug mistakes)

tiny island
#

oh...yeah Enemy uses the Enemy prefab , i see now

naive pawn
#

instead of damaging the random Enemy, damage the thing you hit

#

also do you not want the projectile to be destroyed when it hits an enemy?

tiny island
#

yeah i should probably destroy the projectile on collision aswell.
tho do you recommend just using the other variable then?
cause i don't tknow how to call the damage function if that's the optimal solution

naive pawn
#

yes, use TryGetComponent or GetComponent

#

no need to check the layer - just, if it has the Enemy component, call its Damage method

#

assuming layer 6 is a wall or something, you could just have the projectile destroyed unconditionally (and just not have it collide with any other layers)

#

if you do need to check layers, you should use a layermask instead, that way you can set it in the inspector and it's harder to mess up

#

also of note, the damage there, 2, should be a serialized field, so you can configure it in the inspector easily

tiny island
#

@naive pawn just tried it , works now many thanks as for the other suggestion i'll keep them in mind tho first i'll try implement everything i need to first but thanks again

gentle trellis
#

how do I create physics capsulecast the same size as capsule collider

naive pawn
#

pass the same parameters used for the capsule collider

#

if you're in 2d, you can also cast the collider directly, but 3d doesn't have an analog of that it seems

gentle trellis
#

I see, thanks

thick root
#

Hey quick question, does unity have events like I make a event that I can call from script A and calls a function of a bunch of scripts without the main script having reference of the listening scripts? Like event game over and all enemies listen to that and die on game over

midnight plover
thick root
#

Ahh nice thx, I'll look into it and try to use it 👌

fast fern
#

I use visual studio and I don't know how to set mouse click back to normal, I don't want it to select letters

naive pawn
#

press the insert key

fast fern
#

oh thank you so much, that thing was real annoying

smoky raven
#

I need help with my dash script that i probably butchered cuz i didn't know the input thingy was updated and i just copied a movement script for basic movement which made this mess with me trying to copy it. Also i found out the problem was player input was missing. i honestly think i need to redo 6 hours of scripting if i don't manage fix this, since it's probably caused by me copying the input manager and not changing it when i made this dash thing

smoky raven
#

I honestly don't know what's happening

naive pawn
#

how doesn't it work? does it give errors, does it do something weird, does it not respond?

#

you aren't even using _dash or _playerInput in this code, how is it set up

smoky raven
#

it doesn't respond and like only gives the error when i play it

naive pawn
#

ok, what's the error

smoky raven
#

Hold on

naive pawn
#

also that AddForce is not correct

smoky raven
#

it's only this and i don't understand it at all 😭

smoky raven
naive pawn
# smoky raven

that can only be _playerinput, so the issue is that the object doesn't have a PlayerInput component.

#

the Dash.cs:24 means it's line 24 of Dash.cs

#

the first part of the line says it's in Awake

ivory bobcat
naive pawn
#

generally you would look at the specific line, but there's only one thing that can be null and is being accessed inside Awake there, so it's that

#

oh actually... i guess it could also be _playerinput.actions

#

forgot to consider that, mb

#

so, do some debugging to see which one that is

smoky raven
naive pawn
#

do you know what line numbers are

ivory bobcat
#

That wasn't a solution to your problem but rather a remark about the image you had shown

smoky raven
#

this thing?

naive pawn
#

no, that says what line/char your cursor is on (and what your indent is set to i think? and what your line endings are set to)

smoky raven
naive pawn
#

that was a question, yes or no

ivory bobcat
# smoky raven

You've probably got this script on an object that doesn't have a player input component

smoky raven
naive pawn
#

in your ide, to the left of your code there's a region called a gutter, and on the other side of the gutter, there are numbers that count up for each line in the file

#

those are the line numbers

#

(this is a document/file concept rather than a code concept, but code uses this concept a lot)

smoky raven
#

tbh idek how it vanished

#

I havent used this for like 3 years now

naive pawn
#

settings > search "line numbers"

#

or maybe you could right click the gutter or change that from menu bar > view, idk, i haven't used vs

smoky raven
#

I found it and brought it back

#

and also i added the player input component where the dash script was and it just made my movement speed fast without me pressing anything except wasd...

#

should i rewrite this?

naive pawn
smoky raven
naive pawn
#

you should probably step away from code for a bit - figure out what exactly is the flow you want for this behavior, start from an english description, and be as specific as you can without getting into implementation details (it'll make it easier later)
from that description, write out pseudocode
from that pseudocode, implement it into actual code

#

with experience you can do those first 2 steps in your head - planning the behavior, planning the logic
but since you don't have that yet, writing it out separately can help a lot

#

i still do that quite a bit when working with stuff i'm not familiar with, or with complicated algorithms (not in games)

smoky raven
naive pawn
#

good planning will save you headaches later

solar hill
#

You learn the best when you take your time

smoky raven
# solar hill Why the rush?

Cuz of my stupidity and writing it in a homework where i didn't read the part "this will be your product and is worth half of your grades"

solar hill
#

Ah so last minute deadline for a project?

#

Makes sense we get about 12 of those a week here

smoky raven
solar hill
#

But a weeks time is pretty good compared to what some others are starting with here

smoky raven
solar hill
#

A lot of people start the day before the deadline and get mad when nobody will finish it for them lol

smoky raven
mystic hemlock
#

why does unity always opens this when I end the run of the game? it is annoying to edit assets this way

solar hill
#

Oh yeah 3 days for a prototype is very ambitious if you just started

smoky raven
solar hill
#

If i were you i would grab some direct game course/tutorial that creates some kind of semi completed project

#

And just grind that out for a day

#

If passing is the only thing you care about

smoky raven
smoky raven
smoky raven
# smoky raven Mostly but not really

I've been eyeing game dev for like more than half my life and this was kinda a rare opportunity to force myself to learn it due to my lack of time

#

I'll probably comeback here soon

#

Thanks yall

faint tulip
#

whats the difference between 2D built in render pipeline and 2D SRP?

#

just curious

chilly anvil
#

I cant connect the out to the position. why is this

balmy vortex
#

hi is there any chance for inputAction.WasPressedThisFrame() to just not execute properly if say the user lags out really bad or smth?

#

or like are there any downsides to using it?

sour fulcrum
#

i mean i assume it does what it says

wintry quarry
#

possibly you're using some fragment-only nodes

chilly anvil
#

its connected to a sample textutre 2d

wintry quarry
chilly anvil
#

thanks

true pasture
#

Would anyone know why when I put the sticks on navigate it just constantly scrolls through the options. like stick drift but I cranked up the deadzones on both and it had no effect

wintry quarry
#

unplug all controllers and see if it still happens

#

and use the input debugger

#

most likely a stray device you forgot about leaning against a cat

true pasture
#

ok thanks Ill double check that

#

Okay yeah that helped I see the problem on thing is I don't see the controller in bluetooth. It says there a controller there even after I disconnected them all..

#

oh you can jsut remove the device I guess. I bet it was steam..

slate badge
#

hey guys so im currently making a skillcheck lk those things from dbd, how do you on start make an object spawn outside the surface of a circle?

heres a visual:

solar hill
slate badge
solar hill
#

the dot is the pivot of the bar

#

now when you rotate the dot the bar rotates around the circle

golden notch
#

these two axes are at the same position in their transform, but not exactly the same. I thik it's because they were offset in blender, is there a way I can fix this in editor or will i have to mess around in blender again?

solar hill
#

did you apply transforms in blender before exporting?

golden notch
#

i don't think so? how would I check?

#

they both say 0,0,0 as their position

slate badge
solar hill
#

you add an empty which is the parent of the bar

#

the parent acts like the pivot

solar hill
slate badge
solar hill
#

make it a habit to always apply all transforms before exporting

golden notch
#

they are still offset

solar hill
#

they are in the same location

golden notch
#

no

solar hill
#

so they are offset in blender?

mystic lantern
#

can I prom my asset?

solar hill
#

prom?

golden notch
#

yes but their transforms are zero

solar hill
golden notch
#

should i origin to geometry then?

solar hill
mystic lantern
#

I publish my first asset for unity in itch.io . Easy interactions is easy system for creating interactions

solar hill
#

oh youre asking if you can promote your asset?

mystic lantern
#

thank you

red igloo
rough granite
golden notch
rough granite
radiant voidBOT
rough granite
#

:/

#

!ask

radiant voidBOT
# rough granite !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

golden notch
#

the comma probably confused the bot

solar hill
golden notch
#

oh ok

#

and the handles are really red

naive pawn
#

this channel is generally for like, logic issues or compiler errors, or software architecture

solar hill
#

also that code seemed very ai generated idk why, maybe the excessively detailed commenting?

shell kelp
#

hello! am having a hard time getting auto complete into my Microsoft Visual Studio Code 2022 for unity can someone help?

#

ive installed Everything related to C# and Unity from the Microsoft VS installer

frail hawk
#

!ide

radiant voidBOT
slender nymph
slender nymph
frail hawk
#

i think microsoft should really rename these 2 products

#

or one of them to say it

slender nymph
#

with the way they're going they'll probably rename vs code to "Copilot Code" or something stupid like that

sour fulcrum
#

Codepilot 😔

frail hawk
#

that sounds not bad actually

heavy ibex
#

hey i wanted to know how to encrypt asset do that they dont got ripped/extracted

frail hawk
#

not easy, not recomended

heavy ibex
polar acorn
#

Because it's a battle you won't win

keen dew
#

because it's massive amount of work that ends up being at most a minor inconvenience to someone who wants to rip the assets

slender nymph
#

and, no offense, but nine times out of ten someone asking about that hasn't actually made anything that would be worth taking

frail hawk
shell kelp
frail hawk
#

what does that have to do with the previous message

swift crag
#

(Formerly 365 Code Copilot)

faint osprey
#

public enum timeSignature { 4/4, 3/4, 7/8}
is there a way to set my enum variables like this as it doesnt like the '/'

sour fulcrum
#

no

faint osprey
#

sadge

polar acorn
#

Pretty sure it won't like the numbers either

#

at least not starting with one

slim solar
swift crag
#

yeah, you can't even get away with using a verbanim identifier here

#

e.g. @int lets you use "int" as a name

#

/ is simply not legal in an identifier

obtuse carbon
#

Hello! Can anyone help me please? I am trying to make infinitive world generation with premade tiles. The idea: You start off on the starting tile. Each time when you come closer to the tiles edge, a new tile spawns ahead of you if it's not already there. I have two scripts, "WorldManager" that is attached to the empty gameObject "World"(Parent of generated tiles). Each tile has a script "WorldTile" which contains the main logic and parameters. Here's a problem. i don't know how to explain it correctly, so i created am image. On the left side we can see 3 tiles and two arrows. Green arrow points to the direction where player is going. On the right side we see what happened after the player moved to the edge of the top tile. We can see that 3 additional tiles were spawned instead of 1. If the players moves up to the top tile there will be 2 tiles generated instead of 1 because there are 2 tiles in that row. This is wrong! To simplify this we can imagine our world of tiles as a rectangle with 2 variables(x and y). If the player moves to the x side, there will be generated the amount of tiles that equal to the amount of tiles on the x side. The same thing for the y side. This is wrong. We need to only generate one tile ahead of the player when he moves to the edge.

wintry quarry
delicate sleet
#

Hi, Im new to Unity and to the server, hi to all of you!

I have a question tho, can I update a Cursor sprite in an update function? Its not changing even when I put a debug.log and I see its entering but not changing my cursor.

Heres my example of me changing the cursor:
Cursor.SetCursor(idleCursor, Vector2.zero, CursorMode.Auto);

obtuse carbon
wintry quarry
# obtuse carbon What does it mean and what's the problem?

Having each tile keep track of which adjacent tiles is not the best way to do it.

The best approach is:

  • keep track of which tiles are currently loaded in a HashSet
  • periodically (maybe even once a frame), calculate which tiles are within a set distance (e.g. the "draw distance") of the player. For example if you have adraw distance of 1 you draw the tile the player is ON and the 8 tiles surrounding it.
  • Once you have calculated which tiles are "in", compare that with your current collection of loaded tiles.
  • Any tile which is in the currently loaded set and is "in", should not change
  • Any tile which is in the currently loaded set and is NOT "in", should be destroyed/despawned
  • Any tile which is NOT in the currently loaded set, and is "in", should be spawned in
wintry quarry
#

in your case the possible issues are:

  • YOu might have some other code changing the cursor back to something else
  • You might have the wrong texture being referenced by idleCursor
delicate sleet
#

And if im not seeing it change in the play simulation what could be wrong?
For example, the pressed function:

public void SetPressed()
{
Debug.Log("PRESSED");
Cursor.SetCursor(pressedCursor, Vector2.zero, CursorMode.Auto);
}

It does the log. and it doesn't do the idle until I stop pressing. And the textures are these:

wintry quarry
#

It's not really clear when "SetPressed" is being called though. Sharing your full script would be helpful

delicate sleet
#

Yeah, here it is:

using System;
using UnityEngine;

public class CursorManager : MonoBehaviour
{
    public Texture2D idleCursor;
    public Texture2D hoverCursor;
    public Texture2D pressedCursor;

    public static CursorManager Instance;

    bool isHoveringUI;

    void Awake()
    {
        Instance = this;
        SetIdle();
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            SetPressed();
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (isHoveringUI)
            {
                SetHover();
            }
            else
            {
                SetIdle();
            }
        }
    }

    public void SetHover()
    {
        Debug.Log("HOVER");
        isHoveringUI = true;
        Cursor.SetCursor(hoverCursor, Vector2.zero, CursorMode.Auto);
    }

    public void SetIdle()
    {
        Debug.Log("IDLE");
        isHoveringUI = false;
        Cursor.SetCursor(idleCursor, Vector2.zero, CursorMode.Auto);
    }

    public void SetPressed()
    {
        Debug.Log("PRESSED");
        Cursor.SetCursor(pressedCursor, Vector2.zero, CursorMode.Auto);
    }
}```
wintry quarry
#

!code

radiant voidBOT
delicate sleet
#

sorry Praetor :)

obtuse carbon
wintry quarry
#

so which part exactly is not working?

#

Is none of it working? Or just one of the cursor textures? Or what

wintry quarry
delicate sleet
sour fulcrum
#

are the textures correctly referenced

wintry quarry
delicate sleet
#

I dragged and dropped

wintry quarry
#

Also make sure you don't have more than one copy of it in the scene

#

and make sure you don't have any others that also change the cursor

delicate sleet
#

Its a fresh installed Unity, maybe its not showing bec I have to configure something?

delicate sleet
#

Because the default cursor (the Idle one) it is showing

sour fulcrum
#

are those textures the right ones?

#

first two look the same

#

could just be the screenshot

delicate sleet
#

yeah they are, they are very similar, see:

#

I didnt know how to do the hover on the hand, so I did that little change haha

wintry quarry
delicate sleet
#

And when I click it is showing the logs:

(It is showing them by 2x btw, maybe its that?

wintry quarry
#

probably the second copy only has the idle texture assigned in the inspector for all the fields

delicate sleet
#

hahaha, thanks a lot @wintry quarry and @sour fulcrum it was that...

#

haha it is always the silly ones...

#

thanks a looot :)

swift crag
#

classic error!

unkempt crest
#

i somehow cant click on "PlayerLockOn". I remember deleting it but its still there now unable to be klicked on. could someone help?

polar acorn
#

Did you try restarting Unity after deleting it

unkempt crest
#

i found it in the files and proceeded to delete it there, now it works 👍 (wanted to delete it all along)

#

but something else, is it 'normal' for unity to swallow such enormous amout of RAM? I think with visual studio its combined to 3.900 mb

hexed terrace
#

Depends what you're doing ... I wouldn't say 4GB is a lot for a project and VS

sour fulcrum
unkempt crest
#

okay all right

fallow sparrow
#

Hi all, I've started the Create with Code course for Unity but I think something might be off? The tutorial video has some differences than mine when I open scripts in Visual Studio including where the tutorial tab says "Assembly-CSharp" mine says "Miscellaneous Files" and some are lines are different. Is this an issue?

slender nymph
#

!IDE 👇

radiant voidBOT
swift crag
#

If Visual Studio displays "Miscellaneous Files", it doesn't understand that the file is part of a C# project

fallow sparrow
fallow sparrow
swift crag
#

one catch-22 is that the package won't start working until Unity can compile your scripts..but it can be hard to fix your errors until the package is working 😉

grand snow
#

unity moment

golden notch
#

The debug messsages occur but only for one item, and nothing is added to the handbookContainer. No error messages, it just silently fails.

#

handbookContainer is a Transform, not sure if this is my problem or not

grand snow
golden notch
#

hold on

#

i think i figured it out, handbookcontiner is null

#

forgot to set it in inspector

#

it's partly working now, now i have to figure out why it only runs once

grand snow
#

debugger

golden notch
#

how do i do that?

grand snow
#

the basics are attach to the editor in your IDE, add breakpoints, play and wait for them to be hit
Then you can step through code line by line to see what it does (and inspect variables)

upper pebble
#

What am I doing wrong here?

void OnTriggerEnter(CircleCollider2D other){

        if (other.tag == "Player"){
            Destroy(GameObject.FindWithTag("Player"));
        }

    }

// Update is called once per frame
void Update()
{

    OnTriggerEnter();

}

}

polar acorn
upper pebble
#

It just gives me an error that says there is no argument given that corresponds to the rquired formal paramter 'other' of 'PlayerObstacle.OnTriggerEnter(CircleCollider2D)'

polar acorn
upper pebble
sour fulcrum
#

That is not true

#

Compare that and yours

polar acorn
#

So then fix that one

#

And ask about that error instead of asking about the attempted solution you hacked together to try to fix the initial one

upper pebble
#

Alright I changed a bit and it's not giving any errors but nothing is happening when the player collides with the object

private void OnTriggerEnter(Collider other){

    if (other.tag == "Player"){
        Destroy(GameObject.FindWithTag("Player"));
    }

}
teal viper
upper pebble
polar acorn
upper pebble
polar acorn
#

These are 2D

#

Use the 2D function

upper pebble
#

Sorry for the music forgot to turn it off lmao

slender nymph
#

where do you assign that variable

upper pebble
slender nymph
#

no. do you know what assignment means?

upper pebble
slender nymph
#

you should refresh yourself on the absolute basics, there are beginner c# courses pinned in this channel

#

also consider reading the full error message

upper pebble
# polar acorn What is coll

Collider2D. It's defined at the top (don't ask, it's just what was on the example and it didn't work when I went without it)

polar acorn
#

What value did you set it to

upper pebble
# polar acorn But what is it

Unironically enough when you pointed that out, I remembered something the thing suggested when I was throwing it together so I removed that part and changed it to other and now it works.

#

I am so cooked

solid totem
#

you will not get credit when i realse the game

#

because i will forget your name or username

polar acorn
#

!code

radiant voidBOT
solid totem
#

hey i'm making a 2d platformer game and just started making the prototype and almost finshed the movement script done but i have a bug where my rig or player is sticking to the edge of a box collider 2d here my code using UnityEngine;
using UnityEngine.InputSystem;

#

you will not get credit when i realse the game
because i will forget your name or username

sour fulcrum
solid totem
#

ok

#

yea this is my first proper game

#

thanks thou

worldly thicket
wicked cairn
light hearth
#

ive been working on my vr game foir bit now but still havent rly learned c# or anything jus been doing simple stuff and a couple tutorials that i learned some stuff from but anyone know a good tutoria to help me learn c# i mainly jus wanna learn rn if theres one specific to vr tho that would be great

naive pawn
faint bough
#

Anyone know if you can invert the y axis on cinemachine free look camera

#

I thought It would be in input axis controller but I can't find any option to do it

#

Also does anyone know how to make it so when you're looking in a direction with the camera pressing forward makes you move in that direction

naive pawn
faint bough
#

Uhhhh idk how to do that

naive pawn
#

do you understand what i said, to begin with

#

i don't know how much you know - if you don't understand some specific term, just ask

faint bough
#

I don't understand the whole thing tbh, I don't really have any actual knowledge on unity I just follow tutorials and then it goes in one ear and out the other

naive pawn
#

don't treat tutorials as something to copy

#

actually learn from them

#

they're examples

faint bough
#

Yeah Ik I'll do it after this project

naive pawn
#

if you don't learn then you won't be able to make anything beyond the tutorials

#

for example, this

teal viper
faint bough
#

Because I have a project due tomorrow at 2pm and it is currently 3:30 am

teal viper
#

Why do to have a deadline if you "don't really have any actual knowledge on Unity"?

naive pawn
#

huh?

faint bough
worldly thicket
misty helm
#

Can I fill these via code? Or is there some trick? It's tedious to fill this via drag and drop or selecter

teal viper
naive pawn
misty helm
#

child of gameObject xy, maybe. Everything with tag, or label? Maybe even just typing the gameObject Names

naive pawn
#

gotta lock the inspector first

naive pawn
misty helm
#

maybe in start? on build Time? I don't know. I'm new to this.

#

lock inspector and drag and drop multiple was already a nice tip

naive pawn
#

in Reset, probably (if you were to go that path)

#

but just setting them from the inspector is generally easiest to work with

misty helm
#

I imagine this becoming annoying when one creates a real game.

naive pawn
#

if you reach that level you'll probably already have the necessary knowledge to research and implement it yourself, and/or skills to provide adequate info/context if you ask

misty helm
#

yeah.. maybe

bronze fossil
#

while saving info about player's state

I think it is more suitable to use JSON object and saving it for my game

but should i use both JSON and PlayerPrefs to store all the thing s

like use PlayerPrefs to store stuff like volume level/ High score
or should i only keep JSON Serialization since it is going to be there anyway for other things??

sour fulcrum
#

ideally player prefs would just be player (as in the application, not the controllable character) preferences

#

so volume level is a vibe but high score is better suited for custom json

open stratus
#

Hi does anyone used UI Toolkit for mobile ?

keen dew
#

I'm sure lots of people have. Ask a proper question in #🧰┃ui-toolkit and if someone knows they'll answer

open stratus
untold shore
#

General question on organizing code real quick: whenever you're doing longer code, such as with a player, is it better to put different things into different scripts, or to make a longer, single script? Curious as I am doing a talking script where the player sends a raycast to detect things, and didnt know if I should put it in my script with my movement and all that. (Please @ me if you respond, thank you so much!)

smoky raven
upper pebble
naive pawn
#

if you have long code because you have a lot of disconnected things all handled in the same script, then you should split them up
if you have long code because this one feature is pretty complex and involves a lot of steps, you should keep it together

(and then notice that it being long is not really a factor at all - just whether it makes sense to be together)

smoky raven
safe root
#

Why is the button saying it can't convert Object of type, Object to my script even though no object is being called? Is it because the script the button is calling is on the button object?

safe root
safe root
rough granite
safe root
#

Ah, here

rough granite
# safe root Stacktrace?

i think they mean the whole error code usually tells you what line the error occurred (and the calls that lead to it)

safe root
#

Where this is what happens when I pull it up. Right on Line 70

verbal dome
#

Are you sure it isnt the profiler marker line?

rough granite
# safe root Where this is what happens when I pull it up. Right on Line 70

no no i mean the error like example here

NullReferenceException: Object reference not set to an instance of an object
TabHandler.Initialize () (at Assets/Scripts/Menu/Browser/Tab Handler.cs:43)
TabHandler.get_Singleton () (at Assets/Scripts/Menu/Browser/Tab Handler.cs:29)
Menu.BroswerMenu.Close () (at Assets/Scripts/Menu/Browser/Broswer Menu.cs:21)
Menu.BroswerMenu.<Initialize>b__2_0 () (at Assets/Scripts/Menu/Browser/Broswer Menu.cs:13)
UnityEngine.Events.InvokableCall.Invoke () (at <07c12a9d8ce247d18a35c5e3e7bb065f>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <07c12a9d8ce247d18a35c5e3e7bb065f>:0)
UnityEngine.UI.Button.Press () (at ./Library/PackageCache/com.unity.ugui@4ee0fac0c6e4/Runtime/UGUI/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at ./Library/PackageCache/com.unity.ugui@4ee0fac0c6e4/Runtime/UGUI/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at ./Library/PackageCache/com.unity.ugui@4ee0fac0c6e4/Runtime/UGUI/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at ./Library/PackageCache/com.unity.ugui@4ee0fac0c6e4/Runtime/UGUI/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at ./Library/PackageCache/com.unity.ugui@4ee0fac0c6e4/Runtime/UGUI/EventSystem/EventSystem.cs:514)
rough granite
safe root
verbal dome
rough granite
# safe root

i might be wrong but this just looks like a unity bug, restart the editor

verbal dome
#

What action/method have you subscribed to the button?

#

(Although yes try restart first)

#

If TabHandler is your own script, looks like thats where the error happens

TabHandler.Initialize () (at Assets/Scripts/Menu/Browser/Tab Handler.cs:43)

rough granite
verbal dome
#

I'm confusing myself because of similiar-ish names 😅

safe root
#

That fixed it, it was a Unity problem. How FUN

safe root
verbal dome
#

I meant your usernames

safe root
#

Ah, fair enough.

#

Thank you both

safe root
teal viper
safe root
#

Unless that is interfering

teal viper
#

In any case adding a debug log before the color change would help see if that code runs at all.

safe root
#

I seen them it's just a object reference for the current.ToString, future.ToString, etc

safe root
#

But the button itself doesn't change

#

Not to mention everything below runs fine as well. Cause if I rehover my mouse over the button the number do update

teal viper
#

To be honest I've never used ColorBlock and I'm not sure if just updating it should update the button rendering state.

safe root
#

How would I update the rendering state of it?

north kiln
#

Rather frustrating to see a stack trace with a line number, click on the script linked, and the line number doesn't even exist

north kiln
#

The MouseTextSelector on the gameobject called PlayerCash doesn't have some components assigned

safe root
#

I know, just getting it to work before I clean up

teal viper
#

It is color tint though...

#

Add debug that print the new color right before assignment

#

My guess is that this color is only used during transition. Which already happened by the time the event is called.

safe root
teal viper
#

You probably don't want to touch the buttons colors. Set the graphic component color instead.

gilded quail
#

Hello everyone,

Little background before my question, I'm working on a system simlar to the Post system described in the Uncharted GDC talk. I'm also working in a Behavior Tree system (specifically BD Pro but not super important).
I'm at the point where I've got functional cover seeking system that I've been working on for a while, along with a task that revalidated the cover to make sure it's still viable. Now I'm working on bringing in animations and tying the system together in more of a wholistic way and I'm curious for some advice.
I need to make a repeating system that will determine when to duck in and out of cover. I'm considering a few variables on what to look for when to actually crouch behind cover (mainly recent damage, need to reload, and a bit of random peek duration) but my main questions are how you would broadly approach this sort of system. Would this be a sequence of tasks contained in the Behavior Tree and all of the functionality is contained within that, or would you rather have a specific script on the actual NPC which communicates with a manager and a select few tasks in the Behavior Tree? Kind of swapping BDPro to simply be an overall brain to the body (if that makes sense).
I'm asking this mostly to see what others would think as I think I'm leaning down the treating the Behavior Tree as just a brain with most core functionality actually being separate

Any advice would be appreciated of course.

north kiln
#

I'm a little confused why you expect it to do anything, you change its colors when you're hovering it

#

it will not be in Normal Color, it will be in Highlighted

#

I also have no idea why you would be setting that via script only when hovered, instead of just setting the highlighted color in the inspector?

safe root
north kiln
#

Did you then hover the button after setting it?

safe root
#

I thought I did, guess not

#

thank you again

balmy vortex
#

idk if I'm doing smth wrong but yeah

#

the bubbles use pretty much the same logic so I won't repost it

naive pawn
#

doesn't look like youve configured your ide

hexed terrace
#

I don't see an EventSystem in your scene, which I believe is required for PointerHandler

hexed terrace
#

Yes, looks like you're using the new input system...?

I do not know if that makes a difference to PointerHandlers though, worth checking

#

and what are you supposed to be pointer entering on? seein the first video without context I have no idea

#

Also, as an aside..

Don't do this. Find is slow, and if you remove or rename that game object you'll get a null reference on the following line and it's not going to be clear to you why.

var GameObjectEnemyManager = GameObject.Find("Enemy Manager");
EnemyManager = GameObjectEnemyManager.GetComponent<EnemyManager>();

It's best to create exposed fields (which you already have) and then assign directly in the inspector, when you can. If you can't do that, then it's better to just do (when there's only ever going to be one of in a scene)

EnemyManager = FindObjectOfType<EnemyManager>();

lofty nebula
#

Hay ! I try to apply software architecture in my friend project for training

My goal is to make a Player prefab/modules that can be used either if I apply network code with Netcode for gameobject plugin or if I just play offline with a friend

Like this I would make the levels/scene etc way more easily without worries about network structure/code

it's my first try on drawing the Player interface -> (image below)

I asked my teacher and he was more into specilisation of PlayerOffline by making PlayerOnline (PlayerOnline is a child of PlayerOffline) and I think it's a way better to tackle the issue is I don't know if I could fuse that with NetCode lib since PlayerOffline would be a MonoBehavoire and PlayerOnline would be a NetworkBehavoir

midnight plover
# lofty nebula Hay ! I try to apply software architecture in my friend project for training My...

You should first consider what is the difference between online and offline? In the end, it is still a player. So what do those off and online things share? You can still move something local from network with wrapper classes for off and online. Other question is, if you really want to rebuild an offline version of an online structure or just make the local player the host to fake offline

lofty nebula
#

The difference between online and offline is the fact that they have different implementation (NetworkBehavior and MonoBehavior)

#

so I know that i will have the same methods for basic tasks like movement (running, sprint etc) or 2D Physics
The issue would be in the network version since we need to manage the way game update from both end (host and client) and that would mean using the network framework

#

my english sucks dang

strong wren
#

It's a good exercise, but most multiplayer frameworks already implement an "offline" mode. Big advantage is the simplicity of not really having to think about how singleplayer logic is handled.

#

!collab @vague hatch

radiant voidBOT
lofty nebula
#

bro aint linkdin

lofty nebula
#

if it's possible to achieve/use a "offline mode" from Unity NetCode for GameObjects

strong wren
lofty nebula
strong wren
#

Host mode generally implies having a local player, unlike server mode.

lofty nebula
#

wut

#

bro are u real

midnight plover
lofty nebula
#

So at the end of the day I could just make a interface named IPlayer and one Player class with a final attribute isOnline ?

ivory bobcat
lofty nebula
#

It's what I planned to do

lofty nebula
ivory bobcat
#

Hmmm, those would seem more likely to be on something that isn't an interface. Normally you'd want promised behaviors to be on interfaces. But I'm not entirely certain anymore as new C# interfaces allow some level of implementation nowadays.

round sierra
#

Hello, Im new here. Was wondering if its an appropriate time to ask for some advice? Aqua_Peek

lofty nebula
#

just ask right away wtf are u waiting for ? go ahead bud

round sierra
#

oh i didnt wanna interrupt you guys lol

lofty nebula
#

feel free bro

#

love ya

lofty nebula
#

Just a way to specifies how method signature should be implemented

hexed terrace
lofty nebula
#

which is cool i could change a new more optimized player script in the futur or fix some bugs without redoing all my project

round sierra
#

thank you! anyways Im working on this 2.5d game and was looking for advice on what concepts i should learn to improve this movement script to make it less 'spaghetti' as ive heard that too many if statements can be bad. I've heard of state machines but not sure if it applies to this sort of stuff.

mainly asking because i got frustrated trying to get the attackstage to work properly

not sure if this happens to be more of a beginner question than a code one! sweatblob (ill just remove it if so)

https://paste.mod.gg/krltjsvaykdr/0

ivory bobcat
# lofty nebula I assume that C# Interface were the same as Java Interface ?

Interfaces in C# were designed to hold definitions whereas Java allows you to hold data as well. You cannot have variables in C# interfaces. Only definitions (methods and properties) to be implemented by whatever implements the interface. There is default implementation with an interface now.. so it's becoming more ambiguous but overall I mainly use interfaces to promise (a sort of contract for) certain behaviors. For examplecs IShape Area Perimeter``````cs Triangle : IShape float b; float h; Area => b x h / 2; Perimeter => {...};``````cs List<IShape> shapes = new ... shapes.Add(new Triangle(p1, p2, p3)); shapes.Add(new Circle(c, r)); shapes.Add(new Square(c, b, h)); shapes.Add(new NGon(...));``````cs foreach(var shape in shapes) print(shape.Area);//print the area of each shape (how they're implemented and the members that they hold are unimportant)

midnight plover
# round sierra thank you! anyways Im working on this 2.5d game and was looking for advice on wh...

I def. have seen worse code and way more hierarchies of if statements 😉 From your structure, it also does not really look like much spaghetti yet. You got your inputs, your coroutines tied to them and you got your update methods handling the states coming from those OnXXX methods. I am just wondering about your queuedInput system. Why would you want your attack to attack again after the first one? Is it a core mechanic of your game or do you just thought, it is a good idea to keep the incoming inputs and fire them after the current input?

midnight plover
round sierra
# midnight plover And you said, you got frustrated. can you explain why? We do not know, what your...

Ah basically I wanted to have it play an "attack 1" that goes into an "attack 2" if the button is pressed again within a certain window, but it ends up being just attack 1 over and over again. Im not quite sure if its because of how i structured my animator or if its a problem within the attack routine

Perhaps its because of the thing you mentioned about my queued input system aswell

Heres my animator for reference

midnight plover
round sierra
#

Oh thats because its on a separate script, i can send them aswell rq

midnight plover
#

Ah, got it. And if you select your palyer while attacking, what is happening? Is it going back to default? And whats the setting of the arrow between attack 1 and 2?

low copper
#

Hello everyone, For the first time I have a service that wants to use another service. I can avoid this by having duplicate code in my code base. Does anyone have any thoughts on keeping a strict separation of services?

midnight plover
round sierra
low copper
#

@midnight plover : I'm working within a service locator design pattern. In this specific case I have a level manager that, if I let have access to my save game manager, could save me duplicate code in my code base

midnight plover
midnight plover
low copper
#

I'm just new at all this and want to avoid consquences that I am unaware of later in my project

round sierra
hard python
#

can someone help me with level load script

slender nymph
midnight plover
hard python
midnight plover
hard python
#

should i post my code here

polar acorn
hard python
polar acorn
#

So, again, what is supposed to be making it happen when you press E? Start by looking there.

lofty nebula
naive pawn
naive pawn
lofty nebula
naive pawn
#

Since u're here
don't target random people for specific questions, just ask the room.

naive pawn
#

i mean, ask to the channel as a whole, not one person

#

that's the point of a community server

#

you want to support local multiplayer and online multiplayer?

lofty nebula
naive pawn
#

wellll that's not gonna work