#💻┃code-beginner

1 messages · Page 732 of 1

zinc tundra
#

idk why i get so much issues w it

languid pagoda
#

whell they could disable the character controller component before they upload it to the asset store...

rocky canyon
#

b/c it helps to know the basics before jumping into the water...

#

even teh most basic scripts involve lot of game-dev magic..
1 misspelling can break a whole game

#

plus it helps to know the structure...
what parts make up that object..
(this is one of the problems occuring right now)

zinc tundra
#

i mean how copying a yt tutorial cant work

slow blaze
#

what is this lmao

winged ridge
slender nymph
winged ridge
#

And the OnStateExit has to come from an inherited class, of which contains that method to be overridden etc

slender nymph
#

it's convention to put the modifiers in that order but not necessary

slow blaze
#

oh yeah I forgor to inherit

#

thanks

winged ridge
slender nymph
#

sounds more like you put the return type before an access modifier

winged ridge
zinc tundra
#

i fixed it

#

the problem was the physics settings was set to none

gusty stone
#

Hello,
I am making a 3D beat 'em up with light attacks and heavy attacks.
what is the best way to handle damage done by the Player?

rocky canyon
#

two variables similar function Damage(variable1);

#

altho doesn a single swing destroy every little piece anywhay?

#

health -= variable;

if health < maxHealth -> destroy()

mint imp
#

I've looked all over for help but have had no luck
How can i shoot a "ring" of projectiles around and outwards from my enemy.
It needs to be variable dependant on how many projectiles i want but still evenly spread out in a circle

//for (int i = 0; i < amountOfProjectiles; i++)

?? somehow get a direction for each bullet

Instantiate bullet at enemies position, with new custom rotation.

I imagine it has something to do with dividing 360/ amountOfProjectiles
Then converting that into radians or something but im not sure how to do that...

winged ridge
#

Mathf.deg2Rad() double check spelling, but it converts degrees to radians for you

slender nymph
mint imp
random lodge
#

I need some math help for a Unity script (that I want to create). Not sure how to math this. I have two floats that can be between scaleSizeMin=0.4f and scaleSizeMax=3.0f. I use a Random.Range to pick a # between those. I want to set Rigidbody mass depending on that # chosen so we increase mass between say +1 - 4. How would I do that? (I know how to set mass itself).

slender nymph
grand snow
random lodge
#

smh.

grand snow
#

perhaps it needs explaining a different way

mint imp
slender nymph
#

show what you actually tried

random lodge
#

The mass would be increased depending on the randomized number and the range itself. Look at it like 0.4f - 3.0f and 3.0f is 100% of the range. The mass would be increased depending on a percentage of that range. So if our scale increase 25% we increase mass by 25%.

slender nymph
#

inverse lerp between those values, then use the returned value as the multiplier to increase your mass by

#

but also why not just use a number from 0 to 1 at that point if you aren't even using those values directly?

grand snow
#

Yea i was confused by this, what is the point of doing a random value between this other range to then not need it in that range 😐

mint imp
random lodge
#

Well I'm using those values directly to increase the sprite size

slender nymph
# mint imp

why are you still using a position for the second argument for AngleAxis?

grand snow
#

Right, well a random value from 0-1 is easier to work with, can be used to inc mass easier
then with a normal lerp you can do the other range

slender nymph
#

you're also using a value called "angleIncrement" but then not incrementing it

mint imp
slender nymph
#

if only the docs said

random lodge
#

Got ya

grand snow
#

Yea it makes more sense to do it that way round instead of requiring an inverse lerp

random lodge
#

Yea I see what you mean now

grand snow
#

0-1 number range ❤️

random lodge
#

Also could maybe move the decimal over and use it for size hmmm

mint imp
slender nymph
#

it absolutely does not say to use a position

mint imp
slender nymph
#

well you need to use the axis you want the rotation to be around, not just some random guess

random lodge
#

thinks out loud so if my random is 0.35 I can move the decimal over, get 3.5 and increase the size by 3.5. If I get .85 and that's too high I can just set a limit. Nice. Cool.

#

that works

#

right on I like it lol

mint imp
grand snow
#

a value from 0-1 can be used with Mathf.Lerp() to select a value in a custom range
and then can also be used directly with mass via mass += mass * rand to increase it by 0%-100%

slender nymph
mint imp
#

Got it working

errant osprey
#

Hi All, I'm trying to learn Unity and am making a really simple VR scene where when you touch a block it explodes. I can make the block explode if it's touched with anything else other than the player's hand which is the one thing I want to trigger the explosion. I've tried adding a rigid body and collider sphere to the OVRRightHandVisual & OVRRightControllerVisual and added a cube that I verified triggers the explosion of the block to the hand/controller visuals. Neither method will trigger the blocks. I've tried updating the code on the block for OnTriggerEnter and OnCollisionEnter and neither works if it's the player, but works ok if its the floor plane or another block, etc. Is there something special you have to do to make the player interaction work?

slender nymph
winged ridge
slender nymph
#

don't use string equality for tag checks, use the CompareTag method. Not only is it marginally faster (and can be made a little better using a TagHandle) but more importantly it throws a relevant error when a tag doesn't exist (like if you've misspelled it) instead of just failing silently

errant osprey
slender nymph
#

make sure you go through that link i sent, it will walk you through everything you need to check to make sure physics messages work

stoic summit
#

Hey, I tried to program a wave function collapse algorithm without a tutorial. I've got everything done except socket rotations, and it works great. Would anyone be willing to review my code? Just looking for ways I can improve, or anything incredibly stupid I might be doing. It's across these three scripts:
https://pastebin.com/1WA1ws0w - Grid Generator
https://pastebin.com/1TgW9VXu - Grid Cell
https://pastebin.com/ane5e6fG - Prefabs

slender nymph
#

you've already got a thread in #1390355039272439868 , there's no need to crosspost the question to here as well. just bump the thread if it hasn't gotten attention

stoic summit
#

my bad, how do I bump a thread?

#

I'm dense as fuck

slender nymph
#

sending a message in it will bump it up to the top of the list

stoic summit
#

wise thanks bro

nimble apex
#

vector math

Vector3 displacement = cameraTransform.right * input.x + cameraTransform.forward * input.y;
displacement.y = 0;
displacement.Normalize();```

is this equal to

```cs
new Vector3(right.x * input.x + forward.x * input.y ,0,right.z * input.x + forward.z * input.y).normalized;```
#

im trying to compress them into single line

slender nymph
nimble apex
#

ok i will stop then 👍

#

i just want to save as much loc as possible

slender nymph
#

you can also use TransformDirection instead of manually doing the math and it will be even clearer what the code is supposed to do

nimble apex
#

nice

slender nymph
nimble apex
#

oh its new function for unity 6?

slender nymph
#

no TransformDirection has existed for years, it's even in the Unity 5 docs

#

just turn your input into a Vector3 then pass that to TransformDirection and it will return the correct world space direction

nimble apex
#

ty👍

elfin isle
#

helloooo i have quite a problem on my hands

im trying to make a pause menu, and have made several before using this exact method b ut for some reason, it just doesent work? when I press escape, the pause menu turns on, right? though, the time scale, the camera, and the cursor script are all not doing what the code is telling it to,

the only things working ist eh UI turning on and off, the cursor stuff, and the "paused" bool. why are these things not working? i feel like ive tried everything and feel ver stupid

slender nymph
#

any errors in the console?

elfin isle
#

yes and no? I mean that as in uh, these few errors pop up once and awhile but not specifically when im messing with pause menus tuff

#

i also have no idea what they mean

winged ridge
elfin isle
slender nymph
winged ridge
#

also, is it a typo or intentional that what appears to be camera is spelt wrong?

elfin isle
elfin isle
slender nymph
elfin isle
#

where should i add logs then?

slender nymph
#

inside your if statements and also anywhere that code is running that you think shouldn't be. and make sure you are printing useful info like the value of any properties you are changing or relying on rather than generic messages like "this runs"

winged ridge
#

youd hate my debug.logs lol a lot of mine are along the lines of "This works" or "This should work but doesnt" but I do understand them and what aspects dont work from the error report 😛 just funny you mentioned it

elfin isle
#

i added logs with the if statement and yeah, it says that its working as intended but its not, the scripts are stuck on enabled and the timescale isnt moving

something i found a bit ago while testing though is that, the script can turn stuff on. but, it cannot turn stuff off. say i manually disable the script and then i hit resume, it turns the script back on??

winged ridge
#

thats a very depends situation..lets say you have a box, and you have a script attached to it, and the script disables the box.. it disables the script too (so it cant be re-enabled) if however you have a script attached to another gameObject, that disables a component in the box (using same example) it can re-enable it

elfin isle
#

im not disabling its own script lol, its the pause menu script disabling the palyer script so that it cant move while paused

slender nymph
#

you can put logs in OnEnable and OnDisable and see the stack trace for what is enabling/disabling something

winged ridge
elfin isle
slender nymph
#

you just said you added logs, so surely you know how to write a log, yes?

ivory bobcat
ivory bobcat
#

Escape causes the Editor to lose focus which may behave in a way you're not immediately expecting.

elfin isle
slender nymph
#

it's not a specific log? it's just a log inside of OnEnable and/or OnDisable . . .

winged ridge
#

in the OnEnable just type Debug.Log("OnEnable Method Called"); etc

#

if it doesnt appear, it didnt work

elfin isle
#

well yeah, i know that i just didnt konw what me meant by seeing the stack trace

slender nymph
#

then ask that instead. that's not even part of the code, that's what you see in the editor

elfin isle
#

wait- then how come ive never gotten that bug in all the other projects ive made? ive always done it the same way

slender nymph
#

the editor losing focus should not have resulted in the behavior you described

#

if any of the code in the if statement was executed and there were no errors then all of it would have been

elfin isle
#

idk what to tell you man

#

tahts why i was confused too

ivory bobcat
#

The loss of focus will only apply to launching the application from the Editor so it'll be fine to use the escape key in your actual builds-release.

elfin isle
#

thank you guys so much

#

i was freaking out cause i have a game jam due in 2 hours lmao

winged ridge
#

I usually keybind pause to p or tab.. just out of habit I find it nicer

untold shore
#

Hey! Having some trouble at the moment with some raycasts. Im still new to using them - this is actually my first time with them.
Anyway, whenever I am attempting to find a wall on either side of the player for a Wall Jumping mechanic. Basically, if a player is near a wall, it will output "rightWall = true" or "leftWall = true"; however, when the player jumps, it will always say leftWall = true, which messes up the rest of the code. Here is the snippet that checks for walls:

    {
        rightWall = Physics.Raycast(transform.position, playerObjectOrentation.right, out rightWallHit, wallCheckDistance, whatisWall);
        leftWall = Physics.Raycast(transform.position, -playerObjectOrentation.right, out leftWallHit, wallCheckDistance, whatisWall);
    }

And here is the full code: https://paste.ofcode.org/8SVReqU6mweFkUjWGjXTja
Any idea why this is happening? Thank you! (If you respond, please @ me. Thanks!)

hardy maple
untold shore
#

Gotcha. Im using the Unity 3d Starter Kit, let me put the script into a paste of code real quick.

ivory bobcat
untold shore
winged ridge
#

code for jumping, checking the ground, and using the new Input System

ivory bobcat
#

== and ||

#

Unless you're really intending on assigning left wall and using a bitwise OR operation

hardy maple
#

This is a shot in the dark, but it might be good to console out the name of the objects that the raycasts hit. If I was going to guess, there’s some collider that’s either enabled only for jumping or is changing shape during jumping, and is messing with your raycast

untold shore
proper bobcat
ivory bobcat
untold shore
#

I dont know what bitwise means, but def was going for an or function. Guessing its || then?

#

Fixed it, but its still giving me that leftwall hit.

ivory bobcat
#

Did you save the script?

hardy maple
winged ridge
#

use the code I sent you, it will do ground check, create the Ground layer mask, allocate it in script using
public LayerMask groundLayerMask; allocate this in inspector, the variables can be changed to suit your wishes

hardy maple
#

If you assign leftWall equal to true it’s not hard to imagine why your getting the result you are getting

untold shore
slender nymph
#

the = was the cause of the actual issue. the | just forced it to check both sides even if the left side evaluated to true. || will short circuit which means it will not evaluate the right side if the left side evaluates to true

untold shore
#

Oh ok! Noted. Will use || then, since I dont want it to worry about both sides if a player is close enough to one already. Thank yall so much

elfin isle
#

im abckk agaaiinnn, and im not sure if this is the right channel but when i build my game it gets flagged as a trojan because of scripts- anyway to fix this?

slender nymph
#

it gets flagged as a trojan? that definitely doesn't seem right. can you show exactly what it says?

winged ridge
#

i have had this issue before but was in Python, it was a windows anti virus issue, you have to whitelist the application

#

unless im mistaken the error would be "win32 trojan"

elfin isle
slender nymph
#

what did you actually put in the zip file

elfin isle
#

the game..?

#

the build for the game

slender nymph
#

be specific

elfin isle
#

wdym be specific

#

the build that unity creates when you press "BUILD"

slender nymph
#

let's pretend that i cannot see your computer or project at all and that this is a beginner channel where people very frequently do things incorrectly. thinking that way, read my question again and try answering it one more time, being specific. using screenshots if you have to.

elfin isle
#

idk what more you want me to say

slender nymph
#

that is exactly what i wanted you to say

elfin isle
#

those are just normal build files-

slender nymph
#

so other than including the DoNotShip folder, it's correct. so unless you have some third party assets that are doing shady shit in there, it's a false positive

winged ridge
#

I mean... We can test it, dm me the folder

slender nymph
#

take that to DMs entirely if you do so as it is against server rules and any risk you take there is 100% on you

winged ridge
#

yes, do directly in dms not this server

winged ridge
#

Can confirm there's something wrong in the file, it won't even download, only anti virus I have is Microsoft's, doing a scan now, if you have any 3rd party scripts in your app, you may want to read through and delete them

elfin isle
winged ridge
#

Then it's a conundrum, I'm running on a special network that's not connected to any device but my own laptop. It's a personal WiFi, so when Google stopped it, Microsoft also did, recommend re reading your program and ensure nothing gathers system data or reads anything from system

elfin isle
#

how do i check that?

winged ridge
#

I'll DM you

#

Follow up @slender nymph just in case anyone else wanted to know, it was seemingly couple lines of script that were wrong, deleted them and they worked

cunning bramble
#

hi guys :)

frail tapir
#

Hi all, is there any specific channel for modding unity games?

cunning bramble
#

Good Morning pepole i am look for an good Unity coding basics tutorial does any one have a good tutorial?

slender nymph
#

there are beginner c# courses pinned in this channel and the pathways on the unity learn site are a good place to learn the engine

#

!learn

radiant voidBOT
cunning bramble
#

ahh okay thank you

#

Have an nice day :)

mighty peak
#

Is that for me?🙂

#

If yes so yes im talking about ui buttons and need to make them for movement controller

naive pawn
#

yeah there are existing components for that

#

there's also an onscreen joystick

vivid kestrel
#

hey i want to make animation which engine should i use

#

for begiiner

#

for cutscenes

rich adder
vivid kestrel
#

but i am making game in unity

mighty peak
mighty peak
# naive pawn there's also an onscreen joystick

So I just need to make buttons now left right up and at the end i need when button get down and up for that to make it like hold click and when leave button you understand me i think so how should i do it in same script?

radiant voidBOT
#

:teacher: Unity Learn ↗

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

limber turtle
#

if i want to make a hitscan weapon wider than a typical raycast, what methods do i need to use? if someone could point me in the right direction with this i should be all good

#

i'm thinking something like the charged revolver in ultrakill

#

or railgun

keen dew
#

Spherecast (3d) or circlecast (2d)

limber turtle
#

that would make sense actually

#

are there any ways to display those visually, like Debug.DrawRay does for raycasts?

naive pawn
#

could do 2 offset drawrays

keen dew
#

Not out of the box but there are assets for it, or drawing the outlines with a bunch of rays is usually good enough

limber turtle
#

alright

#

feeling a bit lazy for now and i can do graphics stuff later so i might stick with a drawline between the start and end

#

is there a way for me to make it return more than one collider, or go infinitely?

keen dew
#

SphereCastAll and CircleCastAll

limber turtle
#

thank you very much

#

i'll add a raycast at the start to check for where the shot hits a surface, then do a CircleCastAll for enemies between the start and the end

rugged beacon
#

im trying to read a text that should come with the game
i attempted this, then found out that unity apis can only be used on mainthread?
Task.Run(() => Resources.LoadAsync<TextAsset>
i suppose i can switch to traditional file io but idk if resource folder destination exist after build
how can read the text without blocking the game ?

keen dew
#

[SerializeField] private TextAsset file; and drag in the file as usual. The contents are in file.text

rugged beacon
#

no, i need to load the level datas, it created alot, i want to load specific one

keen dew
#

Serialize an array, put all of them there, read from the array

naive pawn
#

this kinda sounds like an xyproblem

sour fulcrum
#

The levels are just in a text file?

naive pawn
rugged beacon
#

yes json

#

there level_0 ,1,2,3,4,...

rugged beacon
sour fulcrum
#

I could be mistaken but in your initial comment your using a pretty generic file handling function when unity has some more tailor made json parsing utils

#

just a quick google on async json parsing unity has some interesting results

rugged beacon
#

json from util? but i still have to access and read that entire text file right ?

keen dew
#

So do you have one file or multiple? If you have "the file" then why can't you treat it as a normal asset like everything else?

rugged beacon
#

maybe cant count

sour fulcrum
keen dew
#

So when you said "the text file that should come with the game" you meant "the text fileS" as in multiple?

rugged beacon
#

yea i think thats sound right

keen dew
rugged beacon
#

and choose specific one

#

i dont think thats a good solution, anyone feel thats way?
do i just keep 500 text file on that array?

#

i want to only load wat i need

sour fulcrum
#

i agree that that doesnt sound ideal

keen dew
#

Unless the files take up several megabytes, the simplest solution is the best

rugged beacon
#

hmm i thought this problem is common
i guess i can throw it a loading screen let it freeze a few sec for now

grand snow
#

If needed you can get the text/bytes from the asset first on the main thread and then parse on another (e.g using json.net)

#

but if efficiency is important then json should be replaced

rugged beacon
#

do addresable help?

grand snow
#

just an alternate way to load the assets. I dont know if that forces main thread usage

#

or use streaming assets to load the files with non unity file io

rugged beacon
#

alr sound like there still a lot to try

timber tide
#

i've done addressable loading in webgl which works meaning it is single threaded loading unless there's more options I've not really fooled too much with

grand snow
#

well that could do some alternate time sliced loading specially for webgl but i guess its quick to try to use the addressable api on another thread

rugged beacon
#

gonna be a few days for me fr need to see guides never touched addresable

grand snow
#

I've used it a lot so ask in #📦┃addressables if you need help. It uses asset bundles so this means asset dependencies can be duplicated in some situations. Read the docs carefully

limber turtle
#

when using a raycast to find all objects between two points, is there an easy way to have the returned list ordered by distance or will i have to do a bubble sort on the returned list?

keen dew
#

You have to sort it yourself but you don't need to implement your own sorting algorithm, Array.Sort is much faster than bubble sort

#

or List.Sort

limber turtle
#

oh alright

#

how do i sort it by distance if all the objects are RaycastHit2D

#

or should i not be doing that

#

the unity docs says Array.Sort() is javascript only but i don't know if it's outdated

keen dew
#

result.Sort((RaycastHit2D a, RaycastHit2D b) => a.distance.CompareTo(b.distance)); (untested)

#

You're looking at some ancient version's documentation. In any case collection sort is pure C#

blissful jungle
#

Hello

queen adder
#
[Conditional("UNITY_SERVER")]
private void StartServer()
{
    networkManager.ServerManager.StartConnection();
}

Where can I find a list of all the conditional strings I can use?

blissful jungle
#

Is moving platforms hard

silk night
silk night
silk night
blissful jungle
queen adder
#

ah

#

thanks

silk night
silk night
silk night
#

uhh i think the bot is lazy

#

!learn

radiant voidBOT
silk night
#

<@&502884371011731486> crypto scam i assume, they didnt even manage to link the images right

blissful jungle
#

In the code

silk night
silk night
# mighty peak ?🙂

Can you reformulate that question a bit clearer? No offense but I think I had a stroke while reading that 😄

blissful jungle
silk night
blissful jungle
#

Ok

mighty peak
mighty peak
silk night
mighty peak
blissful jungle
midnight plover
silk night
mighty peak
#

Now you know the ui buttons to make the character move right?

#

Right &left &up 🙂

mighty peak
#

I'm tired of explaining this. You can go back to my last messages, I think.

silk night
mighty peak
silk night
#

Well make your own, put buttons on the screen and map them to a script

#

There is no built-in solution for that

mighty peak
silk night
#

You can map each button to a different method in the same script

mighty peak
midnight plover
#

This is a coding channel and not about how to setup a UI, just to remind you

mighty peak
#

Just ask for example for make status for each Buttons in same script

#

Almost nothing else about it.

mighty peak
#

Just one click

#

I've seen almost all of these things.

#

So no comment

midnight plover
#

Start typing full sentences with ponctuation, so people know what you want

mighty peak
midnight plover
#

well, you have been told otherwise just some minutes ago

mighty peak
#

And when I asked before, he didn't tell me that he didn't understand, but I asked for an example of how this is done, and I haven't received one yet. So..

midnight plover
#

your attitude is one of a kind. Im stepping out as well as the person did before for good reason. I gave you the solution for mapping to a button via script. Now its up to you to do your job.

mighty peak
#

Hope you understand

midnight plover
#

yeh, welcome to how to use unity documentation. Get on the button class and read the documentation what other options there are, that could help you.

#

If you dont start to get the habit of reading documentation at all, you gonna have a hard time in the future

mighty peak
midnight plover
#

And what did you search for?

mighty peak
#

All told me yes you can buy no one send something 🙂

mighty peak
#

But do script for Each button individually

midnight plover
#

Im out

mighty peak
midnight plover
#

And that is your biggest issue, you keep waiting for others to do your job

mighty peak
#

I think stack overflow will help

mighty peak
#

And i didn't find anything else so thats why im asking now

#

So if anyone else knows how I'm supposed to do this I'm waiting to hear back.

frosty hound
#

Going forward, if you're going to occupy this channel as much as you do currently, please start using threads. Thanks.

limber turtle
#

i'm not good with lambda expressions so i don't really know what to do here

#

sorry for taking a while, i had a lesson to go to

hollow zenith
#

Hey, is there any point is assembly definitions if 2 of my scripts need to talk to each other?
Afaik Assemblies are meant to be 1 way right?

#

Do I need to look into ways of fixing my scripts that will only work 1 way or create a manager class that would let them talk to each other?

keen dew
limber turtle
#

should i replace array with the name of the array? i would have thought that would be what you mean by result

#

sorry for my incompetence

keen dew
#

No, replace result with the name of the array. It's a static method

limber turtle
#

oh

#

now it's saying the name 'Array' does not exist in the current context

#

do i replace it with Type[]

#

(obviously not verbatim)

keen dew
#

Array with capital A

limber turtle
#

yeah i forgot to mention that

#

i did that

keen dew
#

add using System; at the top

limber turtle
#

oh yeah i should do that

#

thank you very much

#

i believe it works now

zinc tundra
polar acorn
#

"item scratch"?

keen dew
#

stretch I assume

#

when the item is parented on picking it up, make sure all of the parents have uniform scale

zinc tundra
slow blaze
#

private void PlayExplosionEffect(meleeEnemies enemy)
{
Instantiate(explosion, enemy.gameObject.transform);
}

I tried using this to spawn an explosion gameobject with an animator to play an vfx on an enemy

but nothing is spawning? what could be issue?

#

I see the object in the hierachry but no visual

naive pawn
#

check the object, see if it has all the necessary renderers and they're all enabled and have assets set etc

polar acorn
zinc tundra
polar acorn
#

In general, don't use non-uniform scaled objects.

#

If you need a rectangle, model a rectangle instead of stretching a cube

zinc tundra
#

imported into unity, added a rigidbody and box collider on it and thats it

keen dew
#

If you didn't change its scale in Unity then it doesn't have non-uniform scale

keen dew
#

well don't do that

#

change the scale in Blender

zinc tundra
#

w8 i try it with another object

#

well, it does the same

polar acorn
#

Do you know what we mean when we say "non-uniform scale"

keen dew
#

What's the scale of the object?

zinc tundra
#

100x100x100

#

basicly

keen dew
#

What does "basicly" mean? Is it or is it not that?

zinc tundra
#

it is, from every perspective

keen dew
#

What are these values in its inspector

zinc tundra
winged ridge
keen dew
#

And what's the scale of the parent?

strange jackal
#

I just want to confirm my understanding, trees and other objects place in the terrain cannot be interacted with like chopping them down, correct?

silk night
zinc tundra
keen dew
#

When you pick up the object, you parent it to another object. What's the scale of that object?

zinc tundra
#

oh

#

its

#

1/1/1

#

that could be the issue?

keen dew
#

It's uniform so not the issue. Are you sure you parent it to the capsule and not the camera?

polar acorn
#

Does the object become a child of that capsule? Or does it become a child of hold position which seems more like what you would be doing

keen dew
#

Show a new screenshot while playing after you've picked it up

polar acorn
#

If it doesn't become a child of holdPosition you should honestly consider renaming that object

winged ridge
#

Easiest solution, upload your code, it may well be an issue there rather than anything else

zinc tundra
#

there u go

#

commented literally everything cuz i finished last night plus ai helped abit

keen dew
#
heldObjRb.transform.parent = holdPos.transform; //parent object to holdposition
zinc tundra
#

i think ya found the issue

queen adder
#

Why is it that when I reload the scene, the ui buttons stop working?

zinc tundra
#

after deleting the line, its fixed but the item isnt like infront of me

keen dew
#

The code is not the problem.

queen adder
#

I made sure to only reference to objects that are static and are in DontDestroyOnLoad

keen dew
#

Put that line back and check that:

  • holdPosition has uniform scale
  • Camera has uniform scale
  • CameraParent has uniform scale
  • FirstPersonController has uniform scale
zinc tundra
#

now everything works

#

after setting it to 1/1/1, but now my character is too small PepeHands

keen dew
zinc tundra
#

am on the ground

winged ridge
#

welcome to coding lol

keen dew
#

well make the character bigger

#

you have to change the positions now that the scale has been fixed

winged ridge
#

if you want to change tranform of an object independent of its parent use the .localPosition and localScale etc

polar acorn
queen adder
#

Yes

polar acorn
queen adder
zinc tundra
#

but how do i make it taller without the gravity making it small again? MLH_pofa_lmao

polar acorn
polar acorn
#

Maybe change the size of colliders if necessary

queen adder
keen dew
winged ridge
# queen adder

Can you double check your Event System doesnt get deleted

queen adder
zinc tundra
#

now i have to figure out how to do the playercamera to now see the capsule and its shadows

queen adder
#

oh this

winged ridge
# queen adder What event system>

When you add a Canvas, it automatically adds EventSystem in your Hierarchy, this handles UI Input calls, when you refresh, in your hierarchy, where it says Sample Scene make it show all items and check to see if its deleted or not by mistake

queen adder
#

it's not in DontDestroyOnLoad

#

It doesn't get deleted when the scene reloads but it's probably not the same one?

#

I'm not sure

#

Can I make it a child of the UI gameobject?

silk night
#

As long as you have one eventsystem active its fine

winged ridge
queen adder
#

Well

#

Nothing changed

#

Buttons still only work before I reload the scene

winged ridge
#

okay, so that possible issue seems eliminated, have you checked that all the scripts are attached after the reload happens and they dont get deleted from the gameObject in the process

queen adder
#

But wouldn't I still see the hover effect?

#

I don't even see that when I hover over the button

#
 public void RejoinServer()
 {
     string currentSceneName = SceneManager.GetActiveScene().name;
     SceneManager.LoadScene(currentSceneName);
 }

Is this how you're supposed to reload a scene?

winged ridge
#

I dont see why youd want to stop and restart the client...

queen adder
#

I shouln't have included that, it's unrelated

winged ridge
#

!code

#

hm one second

queen adder
#

I figured it out

#

It was the fact that the Cursor was set to Locked mode

#

In the editor it can be in locked mode and you can still see the mouse sometimes

#

And in that state the UI doesn't work

winged ridge
#

well that works lol, either way one other way of using the Load scene is LoadSceneAsync which I was going to show but forgot the formatting command for code

zinc tundra
vernal thorn
#

Seemingly random it sometimes instantly dissapears instead of fading out (the "if health" is in another part of the script ive just put it out for this text)

if (health <= 0)
{
    c = sr.color;
    InvokeRepeating("FadeOut", 0, 0.01f);
    Invoke("Destroying", 1);
}

 private void FadeOut()
 {   
     transparency -= 2;
     transparency = Mathf.Clamp(transparency, 0, 255);

     c.a = transparency / 255f;
     sr.color = c;
 }

  private void Destroying()
  {
      Destroy(gameObject);
  }
winged ridge
#

Have you tried calling your Invoke("Destroying", 1) from within the FadeOut() method

eager elm
vernal thorn
#

so the fadeout only gets called once

winged ridge
#

c#
private IEnumerator FadeOut(){
transparency -= 2;
c.a = transparency / 255f;
sr.color = c;
yield return new WaitForSeconds(2f); // Change the 2f to a suitable
}

eager elm
vernal thorn
winged ridge
#

also dont forget the clamp line..I forgot to add it, but general gist of a coroutine

eager elm
# vernal thorn i havent thought about that thanks

also make sure you disable colliders and stuff like that for the one second between being killed and despawning. Or alternatively, disable the object instantly and spawn a "dummy object" at the same position that fades out.

vernal thorn
polar acorn
vernal thorn
#

ive done now

 private IEnumerator FadeOut()
 {
     for (int i = 0; i < 125; i++)
     {
         transparency -= 2;
         transparency = Mathf.Clamp(transparency, 0, 255);

         c.a = transparency / 255f;
         sr.color = c;
         yield return new WaitForSeconds(0.01f);
     }

     Destroy(gameObject);
 }
naive pawn
#

since it's a float, you could make that really smooth

#

to have it update every frame

vernal thorn
#

I dont need it very smooth for my purpose tho

#

but still thanks

winged ridge
#

I mean, I used his code alone, but theres a few ways to do it, ill include how I did it
Also how did you get that cute box for the code

naive pawn
#
float elapsedTime = 0;
while (elapsedTime < TIME) {
  elapsedTime += Time.deltaTime;
  c.a = Mathf.InverseLerp(0, TIME, elapsedTime);
  yield return null;
}
#

this is a very handy pattern that you should get accustomed to

vernal thorn
naive pawn
radiant voidBOT
naive pawn
#

see the lower section

vernal thorn
winged ridge
#
    public IEnumerator FadeOut(float time)
    {
        while (canvasGroup.alpha < 1f)
        {
            canvasGroup.alpha += Time.deltaTime / time;
            yield return null;
        }
    }

    public IEnumerator FadeIn(float time)
    {
        while (canvasGroup.alpha > 0)
        {
            canvasGroup.alpha -= Time.deltaTime / time;
            yield return null;
        }
    }
naive pawn
vernal thorn
#

` not '

winged ridge
#

now be careful, the canvasGroup cannot go past 0 or 1, but sometimes the variables can, so clamp values and do checks, any comparison against a float variable can pose issues of precision

naive pawn
#

any comparison against a float variable can pose issues of precision
not necessarily - it's equality checks in particular that may have issues

vernal thorn
#

I found out the error it was also another script not just this 🥀

slow blaze
#

also StateBehavior.OnStateExit() Does it execute on the last frame of the current state, or when the state is actually exitted?

winged ridge
vernal thorn
umbral bough
#

Hey, I was wondering if there's a way to make this curve be linear or sm by default, kinda like what unity usually does by default in the inspector:

public AnimationCurve Curve;

Since this is a struct, I tried this:

public CameraAnimationSettings(float duration = 0, EasingType easing = EasingType.Linear)
{
    Duration = duration;
    Easing = easing;
    Curve = new(new Keyframe[] { new(0, 1), new(1, 1) });
}

But it sadly didn't work, it gave me a (1, 1) (1, 1) curve.
Please @ me and thanks in advance!

umbral bough
naive pawn
#

you would assign it on the field

umbral bough
slow blaze
#

hey I'm trying to destroy an Object once this state has cycled through itself once, I thought this would be work but the OnStateEnter works but OnStateExit doesnt, I thought it would be called ont he end frame of that animation?

naive pawn
umbral bough
#

I mean, I can just switch to a class, no big deal in this case

naive pawn
#

that's the mechanism for default values afaik, so.. im lost

naive pawn
#

perhaps add a transition to End with exit time 1

slow blaze
#

that works, thanks!

slow blaze
#

why does it spawn one with Z=0 , and the rest Z= 180 lmao

polar acorn
#

If you ever find yourself modifying the individual values of a quaternion, don't.

slow blaze
#

oh I always assumed they were the rotations

naive pawn
#

well, they are, but not in a format you'll understand unless you're a mathematician

#

they aren't euler angles

#

valid quaternions are normalized as well

slow blaze
#

fair

#

I'll use Quaternion.Euler then

grand snow
#

Yea that constructs a Quaternion from Euler angles which is much easier for most of us to understand

polar acorn
junior vapor
#

I updated from 2022.2 to 6 (Yes I know) and my tileset won't show, anyone has pointers?

#

like, I get the outline, but not the tiles themselves

fickle plume
#

Make sure you are using correct renderer and matching shaders

junior vapor
#

how can I check this?

fickle plume
#

You can create a new scene and compare against default components

junior vapor
#

Oh, I got it now, and it works just fine, thanks!

balmy vortex
#

are there any easier ways to make an object move based on the players position? cuz the code I'm using rn is really clunky even if it's just covering the X axis

rich adder
#

anyway, did you try just moving the transform itself and see if same thing happen? if it doesn't then it could be rigidbody or like interpolation issue

rich adder
#

Personally I would use a better solution for an enemy, if they're meant to move around the map I would combine A* / Navmesh agent with a bit of strategy to move it from point to point (if its within range of player then you could do a local strafe)

balmy vortex
#

I'm just asking if there's a more efficient way of doing it

#

the code technically "works" fine

rich adder
keen dew
#

It's doing kind of the reverse of what would be natural. The closer it gets, the faster it goes. Usually it would do the opposite

#

Now it speeds up and suddenly stops when it reaches the player which causes the choppiness

#

You could try something like this:

float distance = PlayerBody.transform.position.x - transform.position.x;
rb.linearVelocity.x = distance * speed;

which would make it slow down when it gets closer

#

(I don't remember if you can change velocity.x directly)

rich adder
#

var vel = rb.linearVelocity
vel.y = distance * speed;
rb.linearVelocity = vel

keen dew
#

yeah that

rich adder
#

Ridibody2D has rb.linearVelocityX and Y dunno why we dont have it for 3D shakes fist

slender nymph
#

to be fair, all that does is new Vector2(value, rb.velocity.y), can easily create an extension method to do the same for 3d RB

rich adder
#

tru tru..
it would just take unity like no time to implement an extra property when they added linearVelocity but who knows why they didn't

mild furnace
#

Any vscode users getting auto-generated 'GlobalUsings' files?
Its throwing a bunch of errors for me for one specific script, and there are no changes on my .git aside from the obj.meta that keeps reappearing
Not sure what extension is causing this

#

Seems like a recent update thing

rich adder
#

I use VSC but never seen such an issue :\

mild furnace
#

This is so annoying :(

rich adder
#

are you sure it VSC causing it ?

#

you tried just flushing all cache? delete the Library folder and all that already?

mild furnace
#

Yeah, seems to be the case

keen dew
mild furnace
#

I also have this project on my laptop that doesnt have vsc installed, and the editor has no issues

mild furnace
#

Might do a clean reinstall of vscode

rich adder
#

ohh thats strange.. did you add any extra extensions that would cause such a thing

mild furnace
#

Nah but i've noticed it has been gradually adding extensions on its own

#

Intellisense is different, autocomplete has changed, its annoying

#

All I want is the C# tools to see references to everything

rich adder
#

really ?
my autocomplete (intellicode) hasnt been working for a while.. just intellisense

#

maybe its the new c# update? now Im scared to update it lol

mild furnace
#

Yeah it keeps suggesting things based on patterns instead of if they exist, methods, objects, etc

rich adder
#

ohh...hmm I would check your extensions, doesn't sounds standard

mild furnace
#

gonna clean reinstall yeah

rich adder
#

weird...I have intellicode but seriously it worked like once I think half a year ago.. it havent wokred since..

glacial berry
#

Can someone please tell me how to make a slide mechanic using unity's visual scripting

glacial berry
#

mb

silver fern
glacial berry
#

i did

glacial berry
silver fern
polar acorn
rich adder
glacial berry
rich adder
#

you learned how to write words / english

#

its the same exact thing

silver fern
#

!learn

radiant voidBOT
silver fern
#

try this

polar acorn
#

All the hard parts of programming are still there in Visual Scripting. If you can use that, you can learn code

#

The syntax isn't the hard part

rich adder
#

once you learn the syntax, its just like writing a pargraph / sentence

rocky canyon
#

IDE will basically be ur spell-checker in real-time

#

just need to know how to structure the words

rich adder
#

instead of a bunch of arrows going all over the place.. the code has benefit of hiding your spaghetti visualy at least xD

rocky canyon
#

virtual spaghetti

rich adder
#

ma spaget!

silver fern
#

mom's spaghetti

cunning rapids
#

There must be a better implementation for slowing down the player when he charges up a weapon (in this case, a sniper-like weapon). Please help

PlayerMovement has a few blocks of code responsible for that

This is in the Update method (weapons is a list of all the weapon game objects):
https://pastebin.com/G4XN75d0
Those are the methods in the PlayerMovement script:
https://pastebin.com/ec4Lku4e
And this is the Sniper script:
https://pastebin.com/GPtknJQG

rich adder
#

code is heavy.. moms spaghetti

glacial berry
#

my brain sees code and thinks nah it's too complicated

rocky canyon
#

speedVariable = 10 if no weapon;
speedVariable = 5 if big weapon;
Move(direction * speedVariable);

cunning rapids
#

Whatever weapon you're holding doesn't change your speed. What matters is the state (is charging up, is not, etc)

rocky canyon
#

oh.. well same thing can apply to that too

rich adder
rocky canyon
#

if in this state speed = this;

#

if in that state speed = that;

warm tree
#

Is there a way to reduce a boxcollider2D from the top instead of it being reduced from both below and the top? I'm asking that because when I crouch, my character doesn't go from IdleState to CrouchState for example, but from IdleState to AircrouchState to CrouchState, since it's briefly in the air (because of the raycasts that detects the ground) before the offset takes effect.

rocky canyon
#

Move(direction * speed);

rocky canyon
rich adder
rich adder
#

its a giant puzzle you dont slap all the pieces at once and expect a picture.. You build it piece by piece

glacial berry
rocky canyon
rich adder
rocky canyon
#

just in case u can click the Edit button in the inspector and do the same ^

rocky canyon
rocky canyon
#

u can also do it manually by hand in the Size and Center/Pivot slots in the inspector

glacial berry
rich adder
#

do a bit of both.. microsoft site + unity learn

#

unity learn kinda expects you to know a bit of basic c# last time I checked maybe they changed it?

silver fern
rocky canyon
#

i did crash course like this ^ to understand the basics... and then i just jumped off the deep end

rich adder
#

for example it gives you this

#

but doesnt explain about how to structure code, variables , ddata types etc

glacial berry
rocky canyon
#
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    public float horizontalInput; // Stores input from left/right (A-D or Arrow Keys)

    void Update()
    {
        // Capture horizontal axis input every frame
        horizontalInput = Input.GetAxis("Horizontal");
    }
}```
rich adder
rocky canyon
#

it doesn't make sense until u start trying to work with it urself..

glacial berry
rocky canyon
#

u can look at it all day and it doesn't do u any good until u start trying to do it urself

polar acorn
#

This is just that

#

Code isn't magic, each word means something

glacial berry
rich adder
#

its literally
psuedo code then turned into real code

rocky canyon
#

PlayerController.cs is the script <- goes on a gameObject
public float horizontalInput <- is just a variable of type (Float) that stores a value..
Update() <- a built-in unity function that runs once every frame
soo every frame
the code sets horizontalInput to whatever ur computer is grabbing from the Input.GetAxis("Horizontal") which is just ur W/S and Up and Down arrows (traditionally)

polar acorn
#

You already know the concepts behind the words. If a French person points at a grapefruit and says "Pamplemousse", you can discern that what they've just said is the word that means "Grapefruit"

polar acorn
#

How do you get something to run every frame in Visual Scripting

rocky canyon
#

functions are just a set or block of instructions

#

has a name like MyFunction()

glacial berry
polar acorn
polar acorn
rocky canyon
#

good to start small like that..

rich adder
#

and importantly, in a couple lines instead of a bunch of blocks and arrows going all over the place

rocky canyon
#

maybe make two numbers add up and display itself in the console 💪

rich adder
#

the basic c# projects, calculator is always a good start to get the basics

naive pawn
#

holy shit i don't know any of you

#

the blue is so unfamiliar

rocky canyon
#
float a = 1;
float b = 2;
float result;

void Start() // <-- another Unity function runs when the game Starts
{
      MyAddFunction(); // <-- call the function below
}
void MyAddFunction()
{
       result = a + b;
       Debug.log(result); // <-- prints it to the console window
}```
rich adder
rocky canyon
rich adder
#

wasnt like Unity employee badge this blue?

silver fern
#

why is it blue now anyway

rocky canyon
#

ya but they upgraded to Gradients 😉

naive pawn
#

i haven't been around long enough to know

#

shit i derailed the convo

rocky canyon
#

thats all

silver fern
#

damn

polar acorn
rocky canyon
#

edgy

rich adder
#

a float based calculator scares me

rocky canyon
#

he'll swap it for int im sure of it

rich adder
#

aww shit..division will break it 🙁

rocky canyon
#

part of the learning process 💪

rich adder
#

fr..why is 3/2 = 1 🙁

glacial berry
# polar acorn Why no?

how would i come to the conclusion of them saying grapefruit? like if a Japanese person came up to a car and said これを見たらあなたはバカだ i woundn't think they are saying これを見たらあなたはバカだ

rocky canyon
#

ur procrastinating already

rich adder
#

well the whole "points at a grapefruit " you can deduce it visually at least

glacial berry
#

indeed i am

polar acorn
rocky canyon
#

points at orange
"look its orange" 🟠

#

2 factoids 1 statement

unique sigil
#

Hello everyone! I'm having some trouble working with the Addressables package, I'm running VRChat Creator Companion with VRChat SDK 3.7.6.

These are the errors I'm getting:

Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Tasks\CalculateAssetDependencyData.cs(126,30): error CS0117: 'ExtensionMethods' does not contain a definition for 'ExtractCommonCacheData'

Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Tasks\CalculateSceneDependencyData.cs(89,30): error CS0117: 'ExtensionMethods' does not contain a definition for 'ExtractCommonCacheData'

Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Tasks\CalculateCustomDependencyData.cs(91,30): error CS0117: 'ExtensionMethods' does not contain a definition for 'ExtractCommonCacheData'

Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Tasks\CalculateSceneDependencyData.cs(157,82): error CS0117: 'ExtensionMethods' does not contain a definition for 'FilterReferencedObjectIDs'

Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Tasks\CalculateSceneDependencyData.cs(198,67): error CS0117: 'ExtensionMethods' does not contain a definition for 'FilterReferencedObjectIDs'

Do you guys know anything I could do in order to fix it?

radiant voidBOT
rocky canyon
#

you could try the ole
Shutdown Unity
Delete the Library folder
Re-open Unity

glacial berry
#

im going to actually try to learn this and will get back to yall when i Inevitably quit or when i need some motivational words

grand snow
unique sigil
# rich adder !vrchat

Welp I guess that I'll go there, but I came in here since Addressables is not a package used for making VRChat avatars

#

Thanks for the info tho o/

rich adder
rocky canyon
#

best we got.. unless its something specific to the VR packages and stuff

#

which VRChat would know more about

rocky canyon
unique sigil
#

You guys have a great day alright? :)

rich adder
mild furnace
#

Alright did a fresh install and it has only these extensions.
Still getting weird auto-generated globalusings files

rocky canyon
#

should script u something that tells u the "Distance" in miles/km that ur mouse travels to do a specific project

rich adder
#

you just typed in numbers, timers and all that were just premade "components"

#

I started as artist mainly, code was very intimidating at the time

rocky canyon
rich adder
#

sadly no and had to learn the hard way haha

rocky canyon
#

fun fact.. the outward bits of a puzzle piece are called "tabs" sometimes called knobs
and the inward bits of a puzzle piece are called "blanks" sometimes called holes

#

i love trying to find fun words and descriptors to use in my scripts, im on TX -> RX system right now..
but Tabs -> Blanks could work..

rich adder
#

basically I felt familiar with Game Maker because I learned on Klik & Play ❤️

rocky canyon
#

Game Maker is the paid asset/plugin for Unity right?

#

Bolt/ VS etc

rich adder
#

noo Game Maker was a game engine

rocky canyon
#

ohh

#

im confusing it with Playmaker i guess

rich adder
#

well still is but now its more "modern"

rocky canyon
#

ohh yea!! its got that whole WinForms feeling

#

like powerpoint for game-dev 😄

rich adder
#

ops it was small

glacial berry
rocky canyon
#

yup, if thats how u make decisions.. Visual scripting is probably best

glacial berry
#

its process of elimination

rich adder
#

regardless the concepts are pretty much the same

#

components too..A Rigidbody is a rigibody no matter if Visual or Code

rocky canyon
#

Best out of three
Mine says u should keep visually scripting as well

using UnityEngine;

public class DecisionMaker : MonoBehaviour
{
    public string Option1;
    public string Option2;

    [Header("Decision")]
    public string Decision;

    [ContextMenu("Make Decision")]
    void MakeDecision()
    {
        if(Random.Range(0,2) == 0)
        {
            Decision = Option1;
        }
        else
        {
            Decision = Option2;
        }
    }
}
sour fulcrum
#

The biggest Unity game of the year so far is heavily reliant on visual scripting, it has it’s place

rocky canyon
#

except my version i can create artificial biases 😈

rich adder
#

bool shouldIDoVisualScripting = Random.value >= 0.5f

#

or put the odds in the favor of code bool shouldIDoVisualScripting = Random.value < 0.2f

rocky canyon
#
    public float Bias = 0.5f;

        if(Random.value < Bias)
        { ...
sour fulcrum
swift elbow
#

oh i had no idea that was even made with unity

sour fulcrum
#

😛

#

Silksong and Hk use a ton of Playmaker for enemy ai and general level design logic afaik

rich adder
sour fulcrum
#

i be poking at places

#

But theyve talked about playmaker use in hk in the past

rich adder
cosmic quail
rich adder
#

mostly the idiots who think every game is made with like unreal

mild furnace
#

Okay every time I try to open vscode through a specific file it generates all this stuff, in this case, i opened Billboard.cs
Its definitely the c# extension doing it because it says "restoring Billboard.cs" in bottom right

#

Something is also causing vscode to lag everything else out, trying to disable ai features

rich adder
mild furnace
#

This is the same project ive been working on since 2021 with no changes

rich adder
#

ohh.. why is there a .net 10 core folder?

mild furnace
#

No idea, it appears after the corner dialogue says "restoring <filename>" when extensions start up

#

fresh install, only these 4

rich adder
#

weird.. could it be your .csproj /sln in your project are messed up or something ?

mild furnace
#

maybe

rich adder
#

have you tried other projects / blank ones? is it just this?

mild furnace
#

I'm not using any special dependencies, just this

rich adder
#

weird..no idea what those folders are .. mine just shows /Assets and the Solution Explorer

mild furnace
#

yeah it generates inside of whatever folder my script is

rich adder
rich adder
#

you tried another project?

mild furnace
#

nah gonna do that now

#

I hate when updates break things

naive pawn
#

(there's a word for it btw, "regression")

mild furnace
#

Still happening, lags the hell out of my pc

rich adder
#

well shit...maybe clean install VSC? I have no idea what it could be

mild furnace
rich adder
#

which version ? I'm on 1.1.3

#

says latest release is actually August 22

mild furnace
#

taking a look at extension settings

rich adder
#

hmmm I guess thats when you last updated it, but update came out in august

mild furnace
#

Had no issues last week

rich adder
#

so rollback to 1.1.2 ?

rocky canyon
mild furnace
#

What are you on?

rocky canyon
#

umm okay

#

it says im on 1.1.04

rich adder
#

thats the Unity extension not VSC version btw

rocky canyon
#

ohh thats what u mentioning

rich adder
#

Im trusting that OP says updating the Unity extension started problems lol

rocky canyon
#

yea im good

mild furnace
#

Haha yeah, made no progress today due to this

rich adder
rocky canyon
#

i did have a never-ending loading bar yesterday

#

made my entire pc laggy... but a restart fixed it

rich adder
#

I uninstall as soon as any traces of Github Pilot are mentioned

rocky canyon
#

ohh it was Intellisense

#

where it says "Projects" bar was going insane yesterday

rich adder
#

yeah intellisense gotten a bit slower lately

#

I think they added something that caused a slower startup...

#

reminds me VS days

rocky canyon
#

lol

#

i tend to try to keep it open all the time

rich adder
#

yeah once it gets going is non issue. I usually got 4 different Unity / C# projects open

mild furnace
#

What do your external tools settings look like?

#

I unchecked embedded and local packages to see if that would fix, no change

rich adder
#

ahhh

#

i always have these two

rich adder
mild furnace
#

trying now

rich adder
#

one time i had to do that when I renamed my project / folder

mild furnace
#

The project did change names earlier this year

rich adder
#

even when project was a Visual Studio project it was all weird..so I just deleted and refreshed

rich adder
cunning rapids
# cunning rapids There must be a better implementation for slowing down the player when he charge...

Took me a while, is this a good implementation?

in Update in PlayerMovement

            var weapon = activeWeapon.currentWeapon;
            if (weapon != null && weapon.releasedButton && weapon.isCharging)
            { 
                SlowDown(0.3f);
            }

activeWeapon is referencing the weapon switch script

public SwitchWeapons activeWeapon;

currentWeapon is a property in the weapon switching script

    public Sniper currentWeapon
    {
        get
        {
            if (weapons == null || weapons.Count == 0) return null;
            var weapon = weapons[selectedWeapon];
            return weapon != null ? weapon.GetComponent<Sniper>() : null;
        }
    }
#

It still feels like spaghetti

#

Although it's a thousand times cleaner too

rich adder
#

there could be some possible issues

#

selectedWeapon index must be accurate .
repeated GetComponent calls when you could just cache it

cunning rapids
#

How to implement memoization in here?

#

It's a property

#

Not all objects hold the Sniper component

rich adder
#

maybe only do it if the index changed from last time

#

also not sure I would put any movement control in a weapons / weapon switching script

#

doesnt scale well. I would use an event and listen for those in a separate script that controls the player move speeds

#

weapon should not care about the player, what if you want to add a weapon to other entities? or want to only affect specific movement (player has a buff that removes slowdown for charge etc..)

rich adder
mild furnace
#

rips off beginner-programmer disguise and dives into pile of empty monster cans

rich adder
#

ah so it was C# Devkit not unitys..interesting..

mild furnace
#

Its 2:41pm, I can now get started for the day

random lodge
#

On what I was talking about earlier in #unity-talk I've seen these examples all over the Internet that don't appear to work anymore (maybe Unity changed over the years and it's no longer possible). They claim you can call a method in another gameobject this way.

polar acorn
#

that still works fine

#

That's completely allowed

#

You were specifically asking for solutions that didn't involve dragging in references

random lodge
#

They are saying in these examples that it doesn't.

polar acorn
#

That what doesn't

random lodge
#

That you only need this code and nothing else is involved

polar acorn
#

That was never the case

grand snow
#

thats a big fat lie wtf 😐

polar acorn
#

At any point in Unity's history

#

You would have needed to drag an object into the inspector to do this in literal Unity 1.0

#

You have to tell it which ScriptB you want to call DoSomething() on

rich adder
#

maybe some type of reflection or Broadcast Message ?

#

Animation event is a wierd one, if you don't select the same animation from specific animator it doesn't let you use a dropdown and you have type a string for method

random lodge
#

What would cause a type mismatch when you attempt to drag another gameobject that has the script attached using that example above?

rich adder
#

putting a scene component in a prefab

random lodge
#

Does the object you drag into that field have to be a prefab?

rich adder
#

you can have prefabs or not in scene component, not opposite

#

they are assets and can only contain other assets

winged ridge
random lodge
#

I just have an object with a sprite sitting off screen to attach things to (currently "ScoreHandler" script). And tried to drag that over.

slender nymph
#

prefabs cannot reference objects in the scene because objects in the scene only exist while the scene is loaded but prefabs basically always exist. you can't have quantum references

#

so prefabs can only reference things in themselves or other assets. scene objects can reference anything in the scene as well as assets

random lodge
#

When I decided to create scripts that wouldn't actually be "seen" (on an object) I just placed a sprite off screen to attach scripts to so I can use the scripts

polar acorn
#

If it's never going to be seen why does it have a sprite

slender nymph
#

you do know that a component can be on a gameobject that doesn't have a renderer, right?

polar acorn
#

you can just put components on objects

#

they don't have to have any sort of visuals

random lodge
#

It's just kind of a visual reference to what that object is used for (currently a folder)

rich adder
#

hell if you really want visuals put the included icon, at least it lets you put proper visual and not something that then you have to hide offscreen

#

thats why these exist

random lodge
#

Wasn't sure how else to use the scripts because they didn't need to be on anything in-game that was spawned or might get destroyed

polar acorn
rich adder
#

^ if its a monobehaviour then its a component and needs to be on a gameobject to run.

winged ridge
#

A game object consists of a transform at minimum, digiholic is correct, an empty game object is great for manager type scripts

dense goblet
#

quick question, in the junior programmer course, this script is brung up.

" Instantiate(obstaclePrefab, spawnPosition, obstaclePrefab.transform.rotation);"
so can I use this same idea to get the same rotation, and position as the original prefab?

rich adder
winged ridge
slender nymph
polar acorn
#

if they're not provided, it will use the prefab's values

dense goblet
rich adder
winged ridge
#

Quaternion is a type of rotation calculation, but it takes on the base rotation of your prefab

dense goblet
#

Oh thanks for telling me thats sick

polar acorn
slender nymph
#

and before you try it, don't confuse the axes of a Quaternion with euler angles (angles in degrees) because they aren't and should not be used that way. you can however construct a Quaternion out of euler angles using Quaternion.Euler

rich adder
#

^^ almost always work with Eulers for your sanity

#

if you want to know how quaternions work.. you're gonna have an easier time learning how to become a surgeon and do open heart surgery

dense goblet
#

honestly, before I try it I'll have to remember how to spell it ;-;

slender nymph
#

good thing you have your IDE configured so that you get intellisense and autocomplete, right?

rich adder
#

ah yes apparently intellisense is case sensitive and always puts the Unity.Math ones first thinksmart

slender nymph
#

i mean, why wouldn't the IDE assume you are trying to use Mathematics.quaternion if you start typing with a lowercase letter? That's literally the more accurate suggestion based on what was typed

rich adder
#

oh yeah for sure its just something to be aware I guess, but they both work interchangeably anyway right

slender nymph
#

they do cast to and from each other, but the methods work differently

#

for example quaternion.Euler expects radians, but Quaternion.Euler expects degrees

winged ridge
#

I was working through and rewriting all those methods but put on hold trying to work out how to calculate root values of numbers

rich adder
#

ohh shit..radians..my old mistress

rich adder
#

aka "do this complex ass math for me "

winged ridge
#

Yeah, wanted to make a giant unified one that also included engineering and physics calculations as well as the entire Math and Mathf methods

#

The engineering aspect made me laugh.. there were 3 different methods that boil down to a = b / c

rich adder
#

all I know was the spline class made it akward working with cause its all Unity.Math shit

#

I guess it makes sense in a way since splines do have lots of math forumals

winged ridge
#

I decided to create a vector4 which included the variable time

rich adder
#

had the "pleasure" of working with float3s instead :p

#

mathematics library is like "vector who?"

winged ridge
#

I have no issues rewriting their entire maths library to do what I want, just sad they pushed us away from HLSL scripting

rich adder
#

wait don't the new shaders still use HLSL ? or am I confusing it with something else

winged ridge
#

So they are pushing more towards using Script graph, and writing HDRP and URP shaders became more of a hassle as there seems to be less instructions available. Their goto shader guru (great guy, Chris) mainly focuses on shader graph too

random lodge
#

Alright so I have a script "ScoreHandler". I attach that script to an object in the heirarchy which is placed in the scene off the edge of the camera. On another object there is a script "LifeHandler" and I write "Public ScoreHandler scoreHandler" in that script which creates the field. I attempt to attach the other object with ScoreHandler script attached and that gives me the mismatch. Still pretty lost to why.

rugged beacon
#

i trying to invoke a ondestroy on a gameobject without a script on it
collider.GetCancellationTokenOnDestroy().Register(() =>
{
Registry.Remove(collider);
});

is this ok?

slender nymph
random lodge
#

Well, I'm opening a prefab (enemy) and attaching it. Might be why. Not sure.

rich adder
slender nymph
polar acorn
slender nymph
winged ridge
polar acorn
#

Prefabs cannot reference objects in the scene

random lodge
#

Yea I was confused about that

rich adder
polar acorn
rich adder
rugged beacon
rugged beacon
random lodge
#

Hmm, not sure how else to "log kills" then

slender nymph
#

hey remember how i provided a link that explains how you can pass a reference to an object when it is spawned from a prefab? perhaps give that a read

#

or look into events

slender nymph
rugged beacon
#

i want to avoid attach script on that object
i can reference to it but i do object.Ondestroy() from outisde ?

#

ehhh i think this will do

slender nymph
sour fulcrum
# random lodge Yea I was confused about that

When editing Prefab assets you can only reference things that exist in the context/“scope” of that prefab asset. Instances of this prefab can reference other things in scene or do stuff via code.

Imagine you are creating a microwave that will be sold at stores. The power cord can reference the body of the microwave but you obviously can’t know what the power cord is going to be plugged into, but when someone buys your microwave and plugs it into their kitchen wall they obviously can connect the two

rugged beacon
# slender nymph can you not just have whatever destroys the object remove it from the static dic...

should have post full context i suppose, im trying to make clickable object

public static class ObjectClickRegistry
{
    public static Dictionary<Collider2D, Action> Registry { get; private set; } = new();

    public static void Register(Collider2D collider, Action action)
    {
        Registry[collider] = action;

        collider.GetCancellationTokenOnDestroy().Register(() =>
        {
            Registry.Remove(collider);
        });
    }

    public static void Unregister(Collider2D collider)
    {
        Registry.Remove(collider);
    }
}
rich adder
#

if the object is clickable why doesnt it just have a component on it?

rugged beacon
#

yea a collider

rich adder
#

myb I mean like your own component

sour fulcrum
#

What’s in charge of providing that action?

rich adder
#

seems like 1 script would avoid having to do the entire song and dance around

random lodge
#

So basically if I dragged that prefab into the scene its instance would allow it, but not any prefab that isn't instantiated yet

rich adder
polar acorn
random lodge
#

Yea I got it it was confusing to me at first

rich adder
#

if you try to apply scene references on scene instance to the original prefab it wont let you

sour fulcrum
random lodge
#

gotcha thanks

sour fulcrum
rich adder
rugged beacon
sour fulcrum
#

Not saying yes or no to that, nav’s questions/thoughts seem solid, just wanted to point that out

rugged beacon
#

i just trying to seperate out the logic

#

but ijust realize that this can be hard to debug later, with these action

rich adder
#

the logic from what? what problem do you want to solve where is necessary to not keep it simple with a Method / Event called in OnDestroy of the object you want

rugged beacon
#

i was thinking if i have to make everry object a clickable object, the logic now tied to that script and not the one relate. kinda thing

rich adder
#

I mean you can still approach it where it just acts as child invoker then parent / manager does whatever

rich adder
rugged beacon
#

rn if the obj is destroy, the dictionary still hold something there like a null or smt idk right? it will keep growing non stop
but im scraping this out rn cause i want to debug easier

rich adder
#

correct Destroying an object in any collection does not remove it

rugged beacon
#

yea so i intent to remove on destroy

rich adder
#

yes we understand that part, what seems unclear is why you cannot tell whats destroying to tell the manager of them to remove it from collection

#

like

Destroy(clickableThing.gameObject)
OnClickableDestroy?.Invoke(clickablething)```
// on manager
```cs
void OnClickableDestroyed(Clickable clickable)
myDict.Remove(clickable)```
rugged beacon
#

what if the destroy not through that Destroy()? like changing scene, go back and forth kinda thing

rich adder
rugged beacon
rich adder
#

so put the event in OnDestroy

#

and let event live on the Clickable component

rugged beacon
#

put it on the script on the object ?

rich adder
#

for scene changes Destroy unless you do it in like a scene switch method

slender nymph
#

we really don't have the full context for what all you are doing here so it's impossible to give the best suggestion. like why is this dictionary static in the first place

rich adder
#

^ also true.. goes back to the question, what are you trying to solve here exactly.. whats the end goal here

rugged beacon
#

click object

slender nymph
#

that is not an answer to the question

rich adder
#

thats pretty vague though..

#

that part we know, its gonna be a clickable object..

#

whats the setup, what is it for (i swear if you say clicable ima throw a brick at you), whats destroying it, we don't know these things as we are not in your head or git collab lol

rugged beacon
#

idk how to explain but it does quite a few
maybe can be very long and just go through the entire project fr
i scraping this out rn tho. so i think we can rest rn

earnest wind
#

hey, is the use of this safe?

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
#

it just makes the function work when scene loads

#

but it kinda looks scary lol

rich adder
rugged beacon
#

alr bet

rich adder
slender nymph
earnest wind
#

yeah thanks

#

after scene load is fine too

slender nymph
earnest wind
#

thanks

earnest wind
slender nymph
#

at that point why not just call a method from Start?

earnest wind
slender nymph
#

call the method from one object in Start?

earnest wind
sour fulcrum
earnest wind
#

wait a second, i need to remake this whole thing, its not worth it

slender nymph
#

why do you need to reset variables after Start anyway? shouldn't whatever objects using those variables be able to initialize them theirself?

rich adder
earnest wind
#

but i dont want to make it with a helper script

slender nymph
#

that's incredibly vague

earnest wind
#

so that the gameobjects wont need to search one another for the player

#

so that only one script from all of the scripts will be chosen to search, and then will give to each

slender nymph
#

sounds like you want an event instead

earnest wind
#

and the others will just wait until they are given