#archived-code-general

1 messages ยท Page 387 of 1

merry stream
#

alright, appreciate it

warm badger
#

hi, suppose i have a list and i want to remove some specific elements by index(such as index 1,3,4 etc) from the list, what should i do? a for loop return error in this case

mellow sigil
#

and if you need to remove more than one remember to do it in reverse order starting from the highest index

stable geyser
#

Hey all, having a weird issue with serializing to file. I've created a really simplified code snippet and it even failed with the message: UnauthorizedAccessException: Access to the path is denied. I googled it and it said it could be an issue with my Windows permissions so I did a complete reset and the problem still persists. I've put all the 3 code files into a codeshare, any help appreciated! https://codeshare.io/g8Pp6V

knotty sun
stable geyser
#

omg what a stupid mistake to make

#

ty ๐Ÿ˜›

cosmic fjord
#

guys my (gamecanva) does not show the elements inside it (it was fine) any one has similar issue

#

when i click on the canva it show me where the camera is

knotty sun
cosmic fjord
#

background canvas

knotty sun
#

so you have 2 canvas's active at the same time?

cosmic fjord
#

yes

#

one for background and the other 3 canvas one of them will be active depend on the situation

knotty sun
#

you should use Panels for that, not seperate canvas's

cosmic fjord
#

panels
let me read about it then

cosmic fjord
knotty sun
#

correct

cosmic fjord
knotty sun
cosmic fjord
#

or you can explain it in more details if you don't mind

knotty sun
cosmic fjord
#

you mean like split screen
so each screen is a canva?

snow siren
#

can i ask a question here?

knotty sun
knotty sun
tawny elkBOT
#

:thinking: Asking Questions

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

snow siren
#

I have a problem in Unity where my BalanceUI script is not being found in my ScoreManager script. I'm using FindObjectOfType<BalanceUI>() to locate the BalanceUI object, but it's returning null. Any suggestions would be greatly appreciated!

knotty sun
#

And where do you use BalanceUI there?

trim schooner
#

1- the code you've provided (as Steve says) doesn't mention BalanceUI at all
2- if FindObjectOfType<BalanceUI>() is null, then the object isn't being found in the scene -> either you've not got one in the scene, or it is inactive

snow siren
#

so i meant CashUI not balance mybad

#

yes it is inactive, but the code worked fine for my playerStats and it is also inactive

#

thats my code for playerstatsText

knotty sun
snow siren
#

im sorry its my first game, so im a beginner

knotty sun
#

then you should spend more time reading the docs not less

snow siren
#

but im curious why does it work fine with my PlayerStats?

knotty sun
#

what object is PlayerStats on? Player?

snow siren
knotty sun
#

then you probably have duplicates in your scene so you should debug which PlayerStats has been found

trim schooner
#

That GetComponent<TMP_Text>() is called on Awake().. which is called after you make this object active.

snow siren
#

ahh

knotty sun
#

yeah, where is the FindObjectOfType<PlayerStats> ?

snow siren
#

in my PlayerMovement Script and PlayerShooting Script, where i declare the speed and firerate

knotty sun
#

And which object are those scripts on

snow siren
#

ahh maybe i know the problem now

#

Could the problem be that I am trying to continuously update my balance, which is inactive? Would it be possible to synchronize the score with the balance when I press P and open my upgrade panel?

#

i solved the problem, thank u !

knotty sun
iron phoenix
#

Maybe I should post this in another thread?
I'm trying to debug a Behavior Subgraph. I can select the Behavior Agent to debug in the main Behavior Graph, and that works fine. It shows that the main graph is currently inside the subgraph, but debugging doesn't show any activity inside the subgraph, and I can't select any agents there for debugging.

If I add another Behavior Agent script to the GameObject and attach the subgraph directly, I can enable debugging on that agent, and it works. However, it doesn't seem correct to use multiple Behavior Agent scripts on a single GameObject.

How can I properly debug a subgraph? Or is it correct to use multiple Behavior Agent scripts if you use multiple Behavior Graphs?

prime lintel
#

Anyone has experience with using Aron Granberg's A* Pathfinding package? I am wondering if anyone got a similar issue as me before where .reachedDestination seems to always be false despite being at the destination transform

knotty sun
prime lintel
#

I understand that its not directly Unity related and hence isn't something people are to help out with but I was hoping someone had a similar experience and knows what's wrong because the official Discord for the 3rd Party Package does not really help me out

#

Just hoping someone happened to have a similar issue and know why it is so

whole crystal
#

I'm making a fighting game in Unity and I'm working on the input buffer for it. With this I can dynamically create new special moves and perform them, and also images corresponding to button presses show up on screen for a more visual representation. Everything's working correctly so far except diagonals inputs don't read at all as there are images for when you input diagonals like down-left and down-right etc so that i can do proper motion inputs. I added a debug log to check whether it is actually being processed an no nothing's happening at all. Here's the script: https://pastebin.com/fqj0NYCu

HandleInput() is working correctly but HandleDiagonalInput() isn't working at all

ashen bough
#

How i can get an LocalizedAsset in a Specific Locale?

white jasper
#

Hi guys, is anyone else having issues with unity Version control? My token keeps expiring, I have been unable to commit my code for a really long time, and I cannot find a fix for this

oblique spoke
tawny elkBOT
#
๐Ÿ“ 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

steep saddle
#

Any idea why the ability to rename an object in the hierarchy by double clicking might have gotten disabled? Not sure what I changed, if anything. Right clicking and selecting rename works.

leaden ice
#

After it is selected

#

So yes two clicks are needed:

  • Click once to select
  • Click again and don't move your mouse for a second
steep saddle
#

....huh. Yeah that's working. I've been in Unity every day for the last year and for some reason it has felt different the last couple days. Like double clicking quickly used to be more responsive for me.

leaden ice
#

not sure ๐Ÿค”

real gulch
#

Hey, is this the right channel to post a question about ball physics?

real gulch
#

@somber nacelle โค๏ธ

#

@somber nacelle Found the physics channel, hopefully I can figure out my friction issue ๐Ÿ˜„

low pecan
#

I want to use the OnCollisionEnter2D function to call a function when two objects with the same script touch but i cannot figure out how to get it to not call the function twice

somber nacelle
#

a common solution for that is just comparing their instance id and calling the method only on the higher or lower one (it doesn't really matter which you choose)

dusky perch
#

So I have errors that are leaving me confused. Is this the best place to ask for help?\

simple egret
#

Trying to access anything on a null-reference like you have now will throw that NullReferenceException you're seeing here in the console.

dusky perch
#

Thank you. I finally fixed it

spare dome
#

would anyone know how to use singletons and singleton references? I heard they can be good for certain applications such as referencing certain objects you would use a find method for?

#

I would love to learn how to use them

somber nacelle
spare dome
#

sweet, thanks man

dry jacinth
#

Yall know how to fix this???

#

im following a unclear tutorial

somber nacelle
#

at a guess i'd say you copied the code wrong. make sure your !IDE is configured so you see error underlines in your code and get proper auto complete

tawny elkBOT
dry jacinth
#

i need help at the last line

#

Scenemanager thingy

spare dome
#

read the error completely

somber nacelle
dry jacinth
#

ok

somber nacelle
#

after you do that, it should be more obvious what you've forgotten

dry jacinth
#

totally didnt just scrap the whole thing ๐Ÿ˜ญ

somber nacelle
#

but why . . .? it's an incredibly simple issue that requires literally just paying attention to what you are doing

dry jacinth
somber nacelle
#

okay, well make sure you get vs code configured if you haven't already. using properly configured tools makes this a lot easier

dry jacinth
#

I have for future scripts, but thank you for recommending it.

ember iris
vestal arch
ember iris
vestal arch
#

what's num supposed to be there?

ember iris
#

the number of points that will be in the rectangle

#

the size parameter is not yet implemented

vestal arch
#

sqrt isn't going to implement that correctly

#

3 would yield 1 and 2

#

since there's no clean square for that

ember iris
#

right

vestal arch
#

in fact primes would need to be 1*num

#

so i don't think num really makes sense as the input there

vestal arch
ember iris
#

I see, so what would you recommend?

vestal arch
#

since it's supposed to be a rectangle, use height and width as the inputs

vestal arch
vestal arch
ember iris
#

Alright.

#

Thank you for the help.

ionic grove
#

Do you guys know why I'm randomly getting fading for random methods in VS 2022? I've tried flipping the fading settings off and on again, but to no avail

ionic grove
leaden ice
#

What letters

#

You mean the text in Visual Studio?

left olive
#

it's an issue with VS 17.12. MS have acknowledged the issue.

ionic grove
ionic grove
upper pilot
#

How do I check if my code runs in webgl?
I can't seem to do #if UNITY_WEBGL

#

I want webgl specific code to run in this case

#

some examples I Found require some things that I cant figure out, I was able to do it previous with import __Internal or something, but all examples I see seem to require extra code that I never had to write before.
Is webgl special case that only needs to import __Internal?

#
#if UNITY_WEBGL && !UNITY_EDITOR
#endif

This line doesn't seem to work, maybe I forgot to enable webgl in the project or something ๐Ÿ˜„

#

nvm, VS just doesnt auto complete this line hmm

cosmic rain
upper pilot
#

What do you mean?

#

I just needed this:


        // Only run this in WebGL mode.
        #if UNITY_WEBGL && !UNITY_EDITOR
        
        PromoImageLinkObjectGlobal.SetActive(true);
        PromoImageLinkObjectMenuOnly.SetActive(true);

        #endif

It wasn't clear in VS since it didn't auto complete UNITY_WEBGL for some reason, but it might work, just need to test.

As for __Internal it is needed for other reasons(not this one probably) but to run some scripts in a browser for example.

#

It auto completes tons of other UNITY_ lines but not webgl for some reason, so that got me confused ๐Ÿ˜„

cosmic rain
#

And yes, Internal was probably needed for something else

upper pilot
#

I am surprised but the docs actually have something on it

#

thats actually good to know, last time I had trouble finding any information on that

cosmic rain
upper pilot
#

Ah so those werent showing up because my build platform was windows

upper pilot
#

Is there a better way to ignore certain scripts in webgl mode? In my case I need to disable Steamworks scripts, do I just do #if !UNITY_WEBGL around the whole script?

#

Also its surprisingly quiet here today, what happened? ๐Ÿ˜ฎ

rigid island
upper pilot
#

So I have to do that for all scripts from steam api? ๐Ÿ˜ thats a pain, but I will try, maybe there isnt as much as I think ๐Ÿ˜„

#

I guess that I should do that for the content of a class, but not the class itself so it doesnt break when steam engine is attached to a game object?

rigid island
#

only if you have references to that class it would break in webgl

upper pilot
#

so having it on game object is ok even if its disabled with #if?

#

Because it breaks on compilation, hence why I am not sure, but I will keep trying

#

I wish there was an easy way to remove whole namespace

rigid island
#

if its on a gamobject thats an instance so yeah its expecting the script

upper pilot
#

alright

rigid island
#

assembly definition is worth a look, you can choose dlls/libraries based only on platform

upper pilot
#

I will check it out, but not sure if I can manage to implement it today.

upper pilot
#

Thanks

upper pilot
#

1gb of files in Assets/Resources

#

1.14gb Assets folder as a whole

#

I am expecting issues, so I am asking if I should wait an hour or cancel it ๐Ÿ˜„

cosmic rain
#

WebGL would take more time than a normal windows build simply because it has to be il2cpp and then compiled to web assembly or whatever it needs to be.

upper pilot
#

I see, in that case I will wait till it reaches 1h or so

cosmic rain
#

That being said, I can't say if it's normal or not as it depends heavily on your project and hardware. See if it's stuck on the same thing for more than several minutes. That might point out that it's actually stuck.

upper pilot
#

No errors in the console, in the past I'd get some errors which were ignored by the compiler until I cancelled it, so this one is promising I think.

rigid island
#

compression also takes longer(smaller filesize but long iirc) it really squeezing all that into a webassembly is pretty impressive

sinful marsh
#

what's the error?

rigid island
sinful marsh
#

yes, but what are the errors? the cause of it?

rigid island
#

scroll to the top of the errors, start from there

sinful marsh
#

that's it

#

its 2 error lines

summer heart
#

Does your editor give you more specifics? The language server will usually highlight errors for you

sinful marsh
#

nope is literally just that

rigid island
#

which platform are you building to

sinful marsh
#

plus it very inconsistent, sometimes it builds properly and sometimes it fails

#

pc, 2022.3.16f1

leaden ice
summer heart
#

Also idk how big your project is but with 11000 errors I feel like you could open up any file and see a dozen off the bat

rigid island
#

maybe delete the library folder and try again

leaden ice
#

That is a super old version

sinful marsh
#

where is the engine log files located?

leaden ice
#

2022.3.52 is available

rigid island
#

I used that version as my 2022 for a while so idk if the version is broken

rigid island
tawny elkBOT
#
๐Ÿ“ 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

sinful marsh
#

thanks

#

goddamn it, still nothin' on the logs

rigid island
#

I suspect blank project is fine, it might be something in your project throwing off, I use the same exact version without issues

knotty sun
#

Also don't build into a folder that has contents

sinful marsh
knotty sun
#

Unity's file io is exceptionally fragile so take nothing for granted

sinful marsh
#

true

flat marsh
#

Hey, if an object is persistent, (I.e dont detroy on load) when you load into a new scene does the awake function run?

swift falcon
#

Is there difference between general game loop vs iterative game loop. Exm:

While(true) vs for()

kind willow
#

What the difference could be?
Both are loops, but for different purposes

cosmic rain
swift falcon
kind willow
#

if you need to loop several times with possible jumps I would use for
if you need to do something till something becomes true you need while
that's pretty straightforward tho?

swift falcon
#

For example i have used while loop in my first game to keep game running. And do stuff inside it. Now in unity i used for. minutes ago this question came into my mind.

kind willow
#

well in unity you should just use update or fixedupdate or lateupdate or coroutines ect

cosmic rain
#

Unless you're planning to freeze your game with an infinite loop.

kind willow
#

every frame Update() called, every physic frame FixedUpdate() called, you usually put your code in there

#

you can make your while(true) loop using a coroutine tho, but that's pretty niche

swift falcon
kind willow
#

there are at least 2 (kidna) independent loops of Update which is every frame and FixedUpdate which is every physics frame

#

each block on that page is the place of the code your scripts can be executed within

cosmic rain
soft dome
#

Why are the spline animators so damn slow? Theres 20 spline animations running at one point in my scene and they EACH take 1ms+ to complete, resulting in ~30ms cpu frame times... wtf?

vocal valley
#

Hello! I'm **looking for a talk **that I watched some years ago, about doing math in the unit range (0..1), does it rings a bell for anyone?
I know it's a long shot but for the life of me I can't find it again, my google-fu isn't the best. Thanks a lot!

snow copper
#

hello everyone so im wondering i am not new to coding in fact im really good but i do not know how unity works i whatched game makers tool kit and he said to learn the absoulte basics so what are the absoulte basics?

pastel patio
#

Create a gameobject, 3d objects always has a transform component (UI uses rect transform instead)

#

There you can change it's location, orientation and scale

#

And add components

#

Although honestly, you should look at some beginner unity tutotials

pastel patio
#

That should cover most of what you need to know of 'absolute basics'

vocal valley
# steady moat https://www.google.com/search?q=yourube+lerp&oq=yourube+lerp&gs_lcrp=EgZjaHJvbWU...

Thanks, but it's not there. I did ind this one that scartch the subject https://www.youtube.com/watch?v=mr5xkf6zSzk

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

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

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

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

GDC talks cover a ran...

โ–ถ Play video
soft shard
# vocal valley Hello! I'm **looking for a talk **that I watched some years ago, about doing **m...

If you remember watching it on YouTube specifically, you could try checking your watch history, I believe that is kept for several years back, though I doubt the video may have specifically been titled with "unit range", if it may have been a GDC talk video - the link Simferoce provided is a good way you can use your data with a percentage (between 0 and 1, where 0.5 represents 50%), so if you had a range of numbers between 100 and 1000, and you wanted 750, youd get a lerp(100, 1000, 0.75f) or if you wanted to smoothly transition between 2 points you can lerp with a Vector or Quaternion (for rotations) - you can also mathematically calculate numbers to fit a percentage if you know your range, for example if you wanted 50% of 500, thats 500 * 0.5, or if you wanted to know what percentage 250 is from your max value, thats (250 / 500) * 100 - not 100% sure if that is what you mean with "unit range" or if your referring to a different kind of math, you could try looking up the math terms for that specific kind of math otherwise

vocal valley
#

Sorry, I should have said that I'm not looking for advice on how to do it, but talks about it to share these ideas

soft shard
prime lintel
#

How are C# arrays initialised? If I declare an array of 64 CustomStruct type, will called new() on the declaration assignment initialise empty structs in the array? Or will it be some form of uninitialized garbage value?

thick terrace
prime lintel
#

Okay thanks

prime lintel
snow copper
thick terrace
pastel patio
thick terrace
#

if you want a type that can only be constructed by its contructor, you need a class

prime lintel
#

I see, thank you

spare dome
spare dome
snow copper
#

oh i saw it ima go read it cya

glass tiger
#

Hey guys, anyone got experience with Unity Version Control? Working on a Uni project with my mates, but they can't check in their changes. They keep getting the error "You don't have add, ci permission on [file name]", even though they're all marked as owner in the organization which is inherited on the project.

#

Nvm, it doesn't automatically assign seats to people joining the project, even if they're an owner from the organisation.

prime lintel
#

How do I assign refs to members of a struct? I wish to pass refs as part of the members of a struct so that a child may store direct refs to data of its 'grandparent'

#

Or is this not possible

rain minnow
prime lintel
rain minnow
prime lintel
#

it seems that my struct is storing a copy tho

rain minnow
#

are you storing the component or a value from the component?

steady moat
prime lintel
steady moat
prime lintel
steady moat
#

ref float damage is not something you would expect to work with in a C# environment.

steady moat
steady moat
rain minnow
prime lintel
prime lintel
small schooner
#

you can do not use Constructor at all and you can just initialize via new var mad = new MobAttackData{hasInit=hi,damage=d,interval =inter}

rain minnow
steady moat
steady moat
small schooner
#

if u use MyClass name -> method with same name is Constructor in your case -> public MobAttackData (ref float damage, ref PropertySet interval) is constructor that have no sense

steady moat
prime lintel
# rain minnow maybe seeing the entire code/hierarchy can give us a better picture. also, what ...

Struct

public struct MobAttackData
{
    public bool hasInit;
    public float damage;
    public PropertySet interval;

    public MobAttackData(ref float damage, ref PropertySet interval) : this()
    {
        hasInit = true;
        this.damage = damage;
        this.interval = interval;
    }
}

LaserDrone : Mob : Monobehaviour

protected override void Start()
{
    base.Start();

    m_health = new(0, m_maxHealth, m_maxHealth);
    m_attack01 = new(0, m_maxAttack01Interval, 0);

    AttachEventHandlers();

    m_weaponSpriteRenderer = transform.Find("Weapon").GetComponent<SpriteRenderer>();
    m_weaponColor = m_weaponSpriteRenderer.color;
    m_bodySpriteRenderer = transform.Find("Body").GetComponent<SpriteRenderer>();
    m_bodyColor = m_bodySpriteRenderer.color;

    m_contextMob.TransitionTo(new LaserDroneType_Mob());
    m_contextMob.RegisterAttackData(new(ref m_maxAttack01Damage, ref m_attack01), 0);
}

MobContext : Monobehaviour - Another component running alongside Mob(Type)

public void RegisterAttackData(MobAttackData attackData, int idx)
{
    m_type.RegisterAttackData(attackData, idx);
}

IType_Mob

public void RegisterAttackData(MobAttackData attackData, int idx)
{
    m_attackData[idx] = attackData;
}
prime lintel
#

Thank you anyways

rain minnow
#

you can create a Stat class if you want to track changes of that value and pass the class instead, or add a method on the struct to update that value for a simple fix, though, you'd have to track when that value changes and update the struct accordingly . . .

prime lintel
#

Nw! It's alright I've refactored my code already, I was under the assumption structs in C# were similar to C/C++

#

Along with references

late lion
#

But if you use unsafe, you can do whatever you want.

rain minnow
thick terrace
#

there are no value/reference types in C++, everything is a "value type" in C# terms

rain minnow
late lion
rain minnow
thick terrace
#

the C# equivalent of a shared_ptr containing a struct is just a C# class, idk why you wouldn't just use that ๐Ÿ˜…

late lion
prime lintel
rain minnow
thick terrace
rain minnow
thick terrace
#

to be honest it's probably better to compare the unsafe features in C# to plain old C than C++ because C# is missing all features like RAII which you can use to make C++ a bit safer

short quiver
#

Hi, I'd like to use a graphical interface to plot a velocity curve and turn it into an array of values. Are there any utilities that exist for this? E.g. in this video, they present visual curves representing the vertical velocity of the character, and these values are hardcoded on a per-frame basis, which is what I want to try in my game
So in the video, for Yoshi, his double-jump velocity is probably something like [-1, -.5, 0, .5, 1, 2, 4, ...], and I want to be able to plot these values and convert them into an array

crude mortar
#

you could either use the intended curve functionality of using a few plotted points (2-4 points) with interpolated handles, or you could technically plot every frame manually by placing points at a certain interval

#

you could then just use the Evaluate method on the AnimationCurve in a for loop to assign the results to an array

short quiver
twilit rune
#

so i'm trying to create a melee attack hitbox for my player character, but i'm struggling a bit on the enemy detection, should i be turning on an object with a box collider trigger with a script to detect OnCollisionEnter, or create an array with OverlapBox?

#

i'm trying the former, since its easier to change its position/size, but i want to know if there's a better option

leaden ice
#

turning on a collider and waiting for a callback has all kinds of weird timing and coordination issues

patent turtle
#

Anyone know why there is no option to merge branches in Unity Version Control?

leaden ice
patent turtle
#

Branches

#

I've looked everywhere for an option to merge but it doesn't seem possible

leaden ice
#

Not sure - try updating everything to the latest. If still not working, there are otehr ways to do it, including from the command line, or on the unity cloud dashboard

#

I'm not super familiar with UVC, I normally use git.

patent turtle
#

I was told Git use in Unity was a paid feature. Or did they get rid of that?

leaden ice
#

Git is and always has been free and open source software

#

What you are using (Unity Version Control) is a paid feature (after certain limits)

patent turtle
#

Maybe I've already hit the limit? I am a solo dev so this seems incredibly limited.

leaden ice
#

doubtful

#

I'm not convinced the plugin in the uNity editor ever had the ability to merge branches

#

But then again, I haven't used it much

leaden ice
#

Yeah that's what I linked above

#

but that's talking about the desktop Gui app

patent turtle
#

There is supposed to be an option when I right click so I don't understand.

leaden ice
#

not the Unity Editor plugin

patent turtle
#

It's just a 3rd party plug in? That's seems like a major oversight.

twilit rune
leaden ice
unique ivy
#

Is there a way to tween Transform.LookAt(), or achieve a similar result through other means? (Slerp probably) LeanTween makes me feed in the necessary rotation, which I don't know how to calculate

leaden ice
#

To calculate the LookAt rotation you'd do this:

Vector3 direction = targetPos - myPos;
Quaternion targetRotation = Quaternion.LookRotation(direction);```
#

You could also tween an object between where you're currently looking and where you want to look and LookAt that object.

#

Same effect.

soft shard
# patent turtle I was told Git use in Unity was a paid feature. Or did they get rid of that?

Git is not a paid feature, though there are a few steps involved to get it setup with a proper .gitignore file for Unity, and there can be limitations with pushing large asset files, using git LFS becomes paid for increased storage, but aside from that, its essentially free and you either access it through a website, console/terminal or with a gui program like "github for desktop" or "source tree", etc

leaden ice
#

using git LFS becomes paid for increased storage
For the record git LFS and Git itself are completely free and open source software.

If you choose to use a cloud hosting Git Repository provider such as GitHub, you will need to pay for certain things.

#

But if you want to self-host a git repository you can do so without any limits

patent turtle
#

I just used Unity Dev Ops Version control and I nearly lost everything.

soft shard
patent turtle
#

Like it said it merged branches but I didn't see any of my changes once I switched back to my main branch.

leaden ice
#

Yeah I'd really recommend using real battle-tested version control aka Git

#

There's way more support and knowledge for it in the world

patent turtle
#

It just seems weird that it doesn't work. Don't pro studios use this?

leaden ice
#

I'm sure a few do

#

I would wager most use Git

patent turtle
#

I'm just weary of using anything that isn't meant to work with Unity

leaden ice
#

Although some may be swithcing to it to fulfill certain contractual obligations for enterprise customers these days

leaden ice
#

There's nothing special about a Unity project in terms of version control

lean sail
#

At least when I looked into it a year ago, some other version controls didnt even have the same basic features as git.

lean sail
#

I dont remember exactly what it was, but some dont even let you edit a file the same time as someone else.

soft shard
#

Unity has also rebranded their version control I think 3 times now (used to be "Collab" then Plastic, then UVC), as there seemed to always been a feature youd find in a regular git missing or not functioning as expected, im sure its a great tool because its integrated with managing asset files like scenes and prefabs well, but you can also do that with a few more clicks outside of Unity (though I havnt used UVC in a while)

patent turtle
#

I don't want my prefabs and assets getting messed up.

vestal arch
#

they won't most likely

#

use the premade unity .gitignore and you'll be set

leaden ice
#

they're just files

lean sail
vestal arch
#

slap a .gitattributes with * text=auto eol=lf if you feel like it

soft shard
vestal arch
#

git is meant to work with everything else, it's a much more general tool; ides have git integration, and if you learn git you'll be able to use that for any other project since it's nonspecific

patent turtle
#

Github is a paid service unless I want to expose all of my work to the rest of the world right?

vestal arch
#

no

soft shard
vestal arch
#

you can make private repos for free on github

leaden ice
#

it's free to have private repos

vestal arch
#

(has anyone mentioned the *hub comparison to explain git vs github yet)

patent turtle
#

Yeah I get the difference. I've used github for a few mobile projects. I was under the assumtion that you couln't have private repos without paying monthly for them.

lean sail
spare dome
leaden ice
#

I think because GitLab or BitBucket started offering free private repos GH had to start doing it

somber nacelle
#

the change was in like 2019

lean sail
#

Oh wow, til

patent turtle
#

Same

spare dome
#

correct they were not

#

they updated it now, which is nice

soft shard
lean sail
#

I havent looked at the actual pricing/plans ever since I got my student deal ๐Ÿ˜‚

spare dome
#

I just use github for free and it has been working for me ever since

soft shard
#

Tbh, neither did I until I compared github to gitlab a while back lol

spare dome
#

I would like to look at more git based Version control but I don't know of many other than github

soft shard
#

Ive only ever used github, gitlab, bitbucket and " TortoiseSVN", the latter was my least favorite

spare dome
#

TortoiseSVN is a version control software? I did not know that or I'm confusing it with something else

thick terrace
#

kind of, SVN is the version control bit, tortoise is a gui for it

rain minnow
spare dome
soft shard
#

Yeah, ive only used TortoiseSVN on one project and it was... Much more awkward than using github/lab for sure, but im sure it came down to unfamiliarity... At least thats what the boss on that project said

leaden ice
#

I used SVN/Tortoise in my first job out of college, it was alright.

Git is better ๐Ÿ™‚

spare dome
#

yes git is 110% better, its very easy to use as well and the GUI's (most of the time) are great, I have not used git's SLI either at all or not to much, I do not remember

limpid ibex
#

Hello, what is the most optimized method for placing an object picked up in the hand?
Simply have all the 3d items placed in advance and activate the one you've picked up and deactivate the others?

latent latch
limpid ibex
#

yeah. Otherwise I guess you'd have to store the mesh item on the object and retrieve it dynamically?

#

I'm working on a multiplayer project, and I want to avoid sending too much data to the server.

latent latch
#

If we're talking about Doom, and similar type of games where you've got like 10 weapons max then I'd go with the activate/deactive route. If it's Borderlands where there's hundreds of different weapons that can be generated, then you're looking into new()ing/Instantiating the weapon onto the player when they retrieve it most likely

#

Rather, if you're doing some drop system that has weapon variance then you'd instantiating on the drop, then read in its configuration and childing it to the player on pickup*

limpid ibex
#

so read the object's data and update the player's hand with the data.

#

I don't know how many items I'll have in play.

latent latch
#

Least of your problems though relating to networking serialization

glad idol
#

Hey, i would i appreciate if I got some insight on this problem

#
Quaternion rotationY = Quaternion.AngleAxis(currentRotation.y * parallaxRotationScale.y, Vector3.up);
Quaternion combinedRotation = rotationX * rotationY;

Quaternion finalRotation = Quaternion.Slerp(
    combinedRotation * Quaternion.Euler(rotationOffset),
    rotObj.transform.localRotation,
    slerpScale
);
rotObj.transform.localRotation = finalRotation;```
#

i've been struggling with this for a couple of days; im trying to have an omni-directional rotate for the obj rotObj based on player perspective, aka the Camera

#

the rotationX works just fine, leaning up or down no matter what orientation, due to it being based off the camera POV,
but rotationY is being stubborn, and refuses to pivot on the Y axis

latent latch
#

also when you're combining rotations in xyz fashion usually it's ~~z -> y -> x ~~ z -> x -> y like Andy mentioned below (but assuming you don't use unity's eulers methods you can order however you want as long as you stay consistent)

glad idol
#

Might be the issue, I think that was left behind from old solutions

latent latch
#

yeah, they aren't communitive

#

or is it associative. I forget which is which

glad idol
#

Interesting, Iโ€™d have to research more on Quaternions and Eulers

latent latch
#

eulers , as far as unity methods go I think default by multiplying ~~z -> y -> x ~~ z -> x -> y

placid summit
#

it is z,x and y as per docs

vocal drift
#

hello, so i have weird problem, and thank you if anyone helped,

i don't know why, but my private variable suddenly changed on runtime, even nothing change it both in the inspector or in its own script,
the weird private variable is inside ScriptableObject, and the ScriptableObject is inside an enemy
name of the variable is enemyGroup with type List<Character>,
i thought something wrong with my unity, so i tried to restart my laptop
here's the full script of it : https://paste.ofcode.org/ND377n7fS3HGXcMurcVyRJ
and i also provide a video

thick terrace
#

well, clearing it next time that method gets called i guess

#

you also have methods returning enemyGroup by reference so it could be cleared from elsewhere in the code

dusk apex
vocal drift
#

Wait let me turn my laptop on

vocal drift
knotty sun
#

do you not understand that when you do list = list they become the same list

vocal drift
#

is that what you mean?

knotty sun
#

no not at all
ListB is just an alias of ListA, it is not a List in it's own right

vocal drift
#

ListB is independent, so if i change anything in ListA, ListB will still the same unless i change ListB

knotty sun
#

no

crude mortar
#

not in this example

#

I think what you want to do is ListB.AddRange(ListA)

#

otherwise ListB ceases to exist. You would be left with just ListA in memory (ListB variable would just point to ListA internally)

vocal drift
#

wait, let me think

vocal drift
crude mortar
#

adds all the elements in ListA to ListB

vocal drift
#

so basically, what happend in my code is ListA value is connected to ListB, so if i change one of them, others will also changed?

crude mortar
#

yes

vocal drift
#

ahh ok, i just realize that, thank you btw

knotty sun
#

be careful though. AddRange is a shallow copy.
in your case the Character references pointed at by the Lists will still be the same ones, not copies

vocal drift
#

okay

thin aurora
#

I suggest you learn the difference between reference types and value types because it's actually really useful to understand what these are

#

If you want to create an independent list, create a new list and use the constructor that accepts an existing list. This effectively clones the list

#

Note that if the list holds reference types by itself, these will also be the same as the entries in the other list

#

I see SteveSmith also pointed this out already

vocal drift
#

i have to translate all of that then read it carefully phrase by phrase, but thank you

thin aurora
#

That's the important part

wispy raptor
#

i wanna do a function to restart a video player and when it is called:
1- Video stops
2- Video is reseted to the first frame
3- texture showed is the first frame of the video.

i dont have issues with 1 and 2, but how can i do 3?

tight raft
#

Hey guys, don't know where's a good place to ask this so I'll ask here. Does anyone know of an Ad SDK that permits you to reward rewarded ads with crypto? AFAIK Google's policy disallows this, specifically any reward with financial value.

jagged plume
#

how would you guys call the button in the credits to go back to the main menu ? Like "Back" ? "Menu" (like here) ? "Title" ?

vagrant blade
#

Call it whatever you want, or use a an icon, this isn't a coding question.

jagged plume
#

I don't really get when one should use Awake() vs Start()

rain minnow
tawny elkBOT
leaden ice
gaunt raven
#

I have a problem with my 3D player character that can slide and crouch. For some reason, if the player slides into a wall and then jumps, the jump detection system stops working. Specifically, this part of the code stops functioning:
Physics.Raycast(origin, direction, out hit, ray_Distance);
I have no idea how to fix this.

leaden ice
#

What debugging steps have you taken?

#

Is the code still running?

#
        Physics.Raycast(origin, direction, out hit, ray_Distens);

        if (hit.collider.CompareTag("Ground"))
            can_Jump = true; // if it found ground                                                       
        else
            can_Jump = false; // if there is no ground```
I will say onet hing - that this code isn't even making sure there was actually a raycast hit
#

You are ignoring the return value on Raycast

gaunt raven
#

Yes, everything else works. Debugging involved slowly and painstakingly figuring out whether the issue was with the Raycast or something else. It turned out to be related to this part: Physics.Raycast(origin, direction, out hit, ray_Distance);. After the event, it doesnโ€™t update.

When I say it "stops functioning," I mean it stops updating the can_Jump variable.

leaden ice
#

if the raycast doesn't hit anyhting, this code is going to cause an error

leaden ice
#

assuming it's still runing, and there is no exception

#

are you looking at the console window?

#

This is why i asked what debugging steps you've taken

#

you need to check

  • If any exceptions are being thrown
  • If this code is actually running
  • What the result of the raycast is if it is running
gaunt raven
#

aaa

leaden ice
#

Debugging involved slowly and painstakingly figuring out whether the issue was with the Raycast or something else
But what debugging steps did you take?

With Debug.Log figuring this out would take about 2 minutes, it would not be painstaking

gaunt raven
#

ill come back with debug lists and come back

gaunt raven
#
private void JumpingPlayer()
{                                                                                                           
    Vector3 origin = transform.position + ray_Offset_Down;                                               
    Vector3 direction = Vector3.down;

    Debug.DrawRay(origin, direction * ray_Distens, Color.red);
    //hit = Physics.Raycast(origin, direction, ray_Distens);

    Debug.Log($"DEBUG JUMPING : hit colider object = {hit.collider}");

    Physics.Raycast(origin, direction, out hit, ray_Distens);

    Debug.Log($"DEBUG JUMPING : Physics.Raycast reslut = {Physics.Raycast(origin, direction, out hit, ray_Distens)}");

    if (hit.collider.CompareTag("Ground"))
        can_Jump = true; // if it found ground                                                       
    else
        can_Jump = false; // if there is no ground

    Debug.Log($"DEBUG JUMPING : can jump is = {can_Jump}");
}
leaden ice
#

Like I said you need to actually check if the raycast hits something

gaunt raven
#

how do i do that

leaden ice
#
if (Physics.Raycast(origin, direction, out hit, ray_Distens)) {
  // we hit something
}
else {
  // we didn't hit anything
}```
gaunt raven
#

thanks

#

ill be back

#
private void JumpingPlayer()
 {                                                                                                           
     Vector3 origin = transform.position + ray_Offset_Down;                                               
     Vector3 direction = Vector3.down;

     Debug.DrawRay(origin, direction * ray_Distens, Color.red);
     //hit = Physics.Raycast(origin, direction, ray_Distens);

     Debug.Log($"DEBUG JUMPING : hit colider object = {hit.collider}");

     Physics.Raycast(origin, direction, out hit, ray_Distens);

     Debug.Log($"DEBUG JUMPING : Physics.Raycast reslut = {Physics.Raycast(origin, direction, out hit, ray_Distens)}");

     if (hit.collider.CompareTag("Ground"))
         can_Jump = true; // if it found ground                                                       
     else
         can_Jump = false; // if there is no ground

     Debug.Log($"DEBUG JUMPING : can jump is = {can_Jump}");

     if (Physics.Raycast(origin, direction, out hit, ray_Distens))
     {
         Debug.Log("raycast hits somthing");
     }
     else
     {
         Debug.Log("raycast did not hit anything and makes me sad");
     }

     Debug.Log($"raycast hits : {hit.collider.name}");
 }```
#

sorry i am so lost

somber nacelle
#

notice how you've just put that if statement after your actual raycast and the code that is throwing the exception when the raycast hits nothing

gaunt raven
#

aaaaa

#

fuge

rigid island
#

hit.collider is outside raycast if statement that defeats the point of having that if statement, you can only log hit.collider.name, if the hit actually happened

lyric belfry
#

Don't be afraid to snag the code line numbers in screenshots lol

rigid island
#

or just share the code properly and not screenshots

#

โฌ‡๏ธ

tawny elkBOT
somber nacelle
#

do you understand what the actual purpose of the if statement is?

somber nacelle
#

wdym "in what part"?

rigid island
#

the raycast

#

returns a bool.

gaunt raven
#

aaaaaaaa

#

this hurts

rigid island
leaden ice
gaunt raven
#

so then one can get the result of it hitting an object form there it saves values (or well i thing )

rigid island
leaden ice
#

Then it should be pretty straightforward and you would realize it doesn't make sense to have multiple Raycasts here

rigid island
# gaunt raven

yes, how could you log the name of a collider that might be null? hence your error

gaunt raven
lyric belfry
gaunt raven
rigid island
gaunt raven
#

man i must look like a bit as troglodyte rn

#

XD

lyric belfry
#

Not really. You are learning.

rigid island
gaunt raven
#

well i know enuff i just thot of somthing else and my mide was not set that i had fliped up the raycast system (meaning the understandment)

#

becues i got a hang of it in the 2D verson and now realising 3D in a bit more compleax

rigid island
#

in this channel you should be expected to know the purpose of the code you post or how nullref works

#

anyway, the fix is simple and you should remove the raycast without if check

gaunt raven
#

ye like this

rigid island
#

the compare tag can still throw null, do you not see why

#

read the logs again carefully, you wrote them lol

gaunt raven
#

aaa

#

if it isint null and that hit has tag

#

like this

rigid island
#

I mean.. you could've just put it in the if statement of raycast

#

that works too

gaunt raven
#

XD

jagged plume
#

is there a way to prevent "assuming" the case for the asyncLoad variable initialization?

#

e.g. I'd rather have this format

somber nacelle
#

just pass in the actual name of the scene you want to load as nextSceneName and pass that to LoadSceneAsync

gaunt raven
jagged plume
#

holy fuck man

#

i'm tired

#

thanks lol

rigid island
#

if else is redudant though you can just make a variable for the raycast

gaunt raven
#

ye like this

rigid island
#

bool hitSomething = Physics.Raycast(etc..
isGrounded = hitSomething && hit.collider.CompareTag(etc.))

gaunt raven
#

aaaaa

#

meaning is just a bit eayser to rework it a bit more. thanks guys for all the help. and next time ill be in the beginner XD

jagged plume
#

Do you guys know how to prevent the preselection of the first button ? (canvas)
Setting Navigation to None does not seem to change anything

hidden compass
#
    public void ClickReset()
    {
        menuEventSystem.SetSelectedGameObject(null);
    }``` my menu script calls this function everytime I click a button or slider so it doesn't remain selected afterwards..
probably could call it in Awake() or Start() for ur usecase
quasi gull
#

Hello fellas, can somebody help me with Unity's Behavior Graph? Just tried to test it, but seems like serialization of private non-BlackboardVariable doesn't work or maybe I just do it wrong somehow?
Following docs: https://docs.unity3d.com/Packages/com.unity.behavior@1.0/manual/serialization.html
Right now I use 1.0.5 version and this is content of custom action node:

[Serializable, GeneratePropertyBag]
[NodeDescription(
    story: "Search <b>Ability</b> in [unit] and saves to [saveTo]",
    category: "VOIDRPG/Blackboard",
    id: "30d4a9d03c14e6ada6372d4db5d07924"
)]
public class GetAbilityAction : Action
{
    [SerializeReference] public BlackboardVariable<UnitObject> unit;
    [CreateProperty] public Node Child => m_Child;
    [SerializeReference, DontCreateProperty] private Node m_Child;
    [SerializeReference] public BlackboardVariable<BasicAbility> saveTo;
    
    protected override Status OnStart()
    {
        Return Status.Success;
    }
}
#

And this is result in Behavior Graph:

oblique hamlet
#

!vscode

tawny elkBOT
#
Visual Studio Code guide

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

https://on.unity.com/vscode

storm lagoon
#

ok so uhh idk if this is good for this channel but

#

uh how do i fix the package named "com.unity.settings-manager" failing

#

Library\PackageCache\com.unity.learn.iet-framework\Editor\Core\FrameworkSettings.cs(3,19): error CS0234: The type or namespace name 'SettingsManagement' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)

#

i cant find ANY solution

#

i just wanna do some MR things :(

cosmic rain
#

Version compatibility issue probably

storm lagoon
#

wha-

#

these are the packages that come when u make a project

#

trying to use

#

the MR package

cosmic rain
storm lagoon
#

yes

#

the MR one

#

also

cosmic rain
#

No clue what MR is

storm lagoon
#

it didnt install becuase unknown command futime

#

and it stands for

#

Mixed Reality

cosmic rain
#

But make sure that you're using the same editor version

storm lagoon
#

its for VR headsets

#

im using the latest

cosmic rain
#

Do they?

storm lagoon
#

well the editor version is the latest

#

on the unity project

cosmic rain
#

Do they use the latest editor version?

storm lagoon
#

WDYM

cosmic rain
#

Share the page where you got this project from

#

You said it's a unity learn project, so it must be from a tutorial?

storm lagoon
#

this is what i mean

#

i think this is unity learn

#

idk

cosmic rain
#

It's the hub. Has nothing to do with unity learn.

#

Try deleting the library folder

spare dome
#

do you have the settings manager package?

storm lagoon
#

what is that

#

i havent used unity in SOOOO long tbh

spare dome
#

it's a package it looks like you need in the package manager as it is missing a reference to it

#

I have never used it though

storm lagoon
#

yea uh

#

its com.unity.settings-manager

spare dome
#

so you do have it? That is the package name yes

storm lagoon
#

no

spare dome
#

if you do have it you can try what dlich said

storm lagoon
#

it says

#

invalid command: futime

#

or something like that

cosmic rain
#

Sounds like that's the underlying cause of the issue. Either a connection problem or access rights

storm lagoon
#

i srs do not know

#

im using a usb

#

i have 19 gb free

#

fat32

spare dome
#

usb?

cosmic rain
#

USB?๐Ÿคจ

spare dome
#

you have unity installed to a USB??

storm lagoon
#

...yea why

#

i dont have 12 gb on my computer

#

and i dont wanna delete steamapps/common (90gb :D)

cosmic rain
#

Well, it's probably not gonna work correctly with an external storage.

spare dome
#

No wonder it cannot access anything, you are not supposed to have it on an USB

storm lagoon
#

but it let me

#

i used the actual EXE

spare dome
#

what .EXE?

storm lagoon
#

the unity 6 installer

cosmic rain
# storm lagoon but it let me

"not work correctly" doesn't mean you wouldn't be able to launch it at all. It means that there would possibly be problems, like the one you're facing.

storm lagoon
#

well it could load into the editor but with that error

cosmic rain
#

Well, try to install it on an actual internal storage.

storm lagoon
#

i cant

spare dome
#

so you offline installed it onto a USB, which you are not supposed to do. You should instead install it via unity hub online and on the actual C: drive

cosmic rain
storm lagoon
#

i cant load it in like 4gb

#

how am i meant to fit 12 gb in 4

#

wait no

#

6.91

cosmic rain
#

Do you only have 4GB on your PC? Is it 20 years old or something?

spare dome
#

you cannot, also you shouldn't push your hard drive to the limit like that as it could cause damage over time

storm lagoon
#

actually

#

6.91 gb FREE

#

outta 471 gb

cosmic rain
#

Well, delete something

spare dome
#

how did you fill up 512 gb hard drive that much ๐Ÿ‘€

storm lagoon
#

its like 90

#

and the rest is idk

#

90 GB*

#

man even with deleting downloads TWICE i still had like 400gb left after a while on my old 2tb pc lol

#

and i had like a bajillion UNITY versions on that

#

but this is off topic

sleek bough
#

@storm lagoon This is not tech support channel. Install Unity properly to any location through the Hub.

storm lagoon
#

ok ill stop

#

and go be sad because i cant even try doing something fun

cosmic rain
storm lagoon
#

its just alotta >1gb files lol

spare dome
#

better purge some of those files

storm lagoon
#

bro id rather not delete shit

#

i alr have like ten filled drives

#

(usb's)

sleek bough
#

@storm lagoon I'd rather you stop posting off-topic.

storm lagoon
#

ok

#

ill stop talking

worn flare
#

does anyome know how to allow the player to drop an audio file into the game

worn flare
#

yes

fleet gorge
#

Quick search led me to this

worn flare
#

very epic thank you

fleet gorge
#

Only on windows and must be built

worn flare
#

i think the thing im using to convert audio files is windows only too so its okay

scenic birch
#

GRAAAAAAAAAAA

#

this might not be the place to ask but does anyone know what might be causing my monobehaviour functions to be showing up as unused in VS

#

i have the visual studio extension installed

#

this only started happening a few days ago

rain minnow
spark stirrup
scenic birch
#

i know it's not literally manually called but is there a way to get rid of this?

#

just for the monobehavior functions

rain minnow
scenic birch
#

you probably have this set to 0

rain minnow
#

they already have a FixedUpdate method and they do handle movement in FixedUpdate . . .

scenic birch
#

i am stupid.

rain minnow
#

also, using deltaTime in FixedUpdate automatically changes it to fixedDeltaTime . . .

spark stirrup
scenic birch
#

i shouldnt have tried to help ๐Ÿ˜ญ

#

i honestly didnt know that

spark stirrup
#

But I don't want to increase drag because it doesn't get rid of the problem, it just makes me have to increase my player speed, which also increases the amount of slippage so it's basically useless to increase it

scenic birch
#

this might be helpful, hopefully i'm right this time xd

#

set your ground/player to a physics material with higher friction

spark stirrup
leaden ice
#

If you want to immediately set the velocity to zero, there's nothing stopping you from doing that in your code

spark stirrup
leaden ice
#

But physical objects don't act that way naturally

scenic birch
#

@leaden ice thank you for helping me with my many mirror questions a few years ago :)

leaden ice
spark stirrup
leaden ice
#

Yeah that's not right

#

rb.velocity =

spark stirrup
#

that throws an error

#

it told me to use Set()

leaden ice
#

Not generally no

#

You did something wrong

#

What did you write and what error did you get

#
rb.velocity = new(0, rb.velocity.y, 0);```
#

E..g

rain minnow
spark stirrup
#

So now the player doesn't slide, but for some reason the camera like bounces let me take a video rq

leaden ice
#

If you mean it's jittery that's generally due to a lack of functioning interpolation on your Rigidbody

#

That can happen if you didn't enable interpolation or if you do something to break the interpolation, such as directly modifying the object's Transform

upper pilot
#

How do I prevent "selecting" buttons?
In my project I use space for certain things, but when clicking a button space would activate that button until I click outside to "deselect" it.
I never experienced it before, but it seems like a big issue to me.

thin aurora
#

Before it would correctly show it as methods called itnernally and not unused

vocal drift
#

hello, so i want to use event with parameter, but functions that subscribe the event don't have to use the parameter

i know i can do this, but i don't want to

void Start()
{
  eventProvider.OnSomethingHappend += Subscriber;
}

void Subscriber(string blank)
{
  // blank is never used
}

instead, i want something like this

void Start()
{
  eventProvider.OnSomethingHappend += Subscriber; // no error in this line
}

void Subscriber()
{
  
}
thin aurora
#

Alternatively, pass the parameters and have the event handler method call another method that doesn't use the parameters

#

These things are basically required so you can't work around them

#

You can also place a delegate on the event directly but I suggest you don't do that since you can't unsubscribe from these since they're not tied to an actual method. Even then, the delegate must reference the parameters regardless

vocal drift
#

what's actually happend in my case is, i have one event with parameter, and there's two function that subscribe it, one that require parameter, and other one that don't require parameter, i don't really want to make a mess so i don't use code example above

#

or maybe i should use two different event

thin aurora
#

This is very common with events

#

Also, event handler methods should purely exist to handle the method, so it would be clear why a parameter is unused

#

But, if you want it to be even more clear, you can make your parameters _, __, ___ and so on to indicate they are discarded

#

This is an actual .NET feature, albeit usually for method variables and not parameters so they are not actually supported in this case

#

It indicates you are aware there is a variable, but you don't use it

vocal drift
#

Okay then, maybe i should ask my senior first

thin aurora
ornate swallow
#

Anyone know how to make unity games require double swiping when using gesture navigation in android? and how to make it recognize as a game?

#

I already tried using a custom manifest and adding android:isGame=true and android:appCategory=game

cosmic rain
ornate swallow
#

should've clarified

cosmic rain
#

Well, you'll need to implement it. There's no built-in double swipe feature.

ornate swallow
#

I'm pretty sure it's part of android gesture navigation tho

#

fullscreen apps typically require double swiping from the bottom to go to the home

#

altho google hasn't been very helpful with figuring this out, so I could be wrong

cosmic rain
#

I don't seem to have such a feature on my phone. If it is an os feature, it should work with any app, including unity games.

ornate swallow
#

do you have the 3 buttons on the bottom of your screen when you use your phone?

#

back, home, task view?

#

(also, about to go in a meeting, will return ASAP)

trim schooner
trim schooner
# cosmic rain Yes

Android has an option to change to gesture controls, making it the "same" as iOS - no idea when this got added

#

(in case you weren't aware)

fluid siren
trim schooner
buoyant vault
trim schooner
#

read id:browse .. read the topic channels, don't pick a random one and ask ๐Ÿ˜›

buoyant vault
vocal drift
shy oyster
#

I have a quaternion, how do i get the angle for a specific axis from it? like the rotation on the Y axis

cosmic rain
shy oyster
#

ah okay

thin aurora
tawdry kite
#

Hฤฑ, i followed a car movement tutorial with wheel colliders and rigidbody but my car is so slow. Do anyone know how to make it faster

#

Ive tried to fix it with chatgpt but none of his ideas fixed

thin aurora
tawny elkBOT
thin aurora
tawdry kite
rustic ember
#

Hi! When loading a scene asynchronously, does it also run the Awake() and Start() functions of enabled objects asynchronously? Or will the game crash/freeze if there are too many operations?

thin aurora
#

I.e. if the method returns Awaitable, it will be asynchronous just like anything else

#

There's not really an async in Unity I believe. It's all synchronous with some tricks

#

I'm still not fully sure what it does

leaden ice
rustic ember
#

Thank you both. Can I make the LoadSceneAsync wait for an IEnumerator to run?

rain minnow
rustic ember
thin aurora
#

I believe Start works independetly and your scene loading has nothing to do with it or the order of execution

#

I believe Unity only ensures Awake runs first, then Start

rustic ember
thin aurora
#

Well same thing

#

Is your issue that you must wait for something to initialize in another scene?

rustic ember
#

The thing is, I have a world generator that is an IEnumerator, and I want it to finish before switching scenes

maiden heath
#

https://pastebin.com/74eZXpGf

I want to make a system where:

  • if there's a yield return, then it will wait for the animation to finish before executing the next animation
  • if there's a StartCoroutine(), then it will execute the next animation without waiting

But for some reason, when I run the game, the longer animation (which is _drumsInstrument) wont wait for the shorter animation (which is _fluteInstrument) to finish.

#

Nevermind; fixed the issue.
It was the Has Exit Time property ๐Ÿ™ƒ

ornate swallow
#

from what I understand I have to use setSystemGestureExclusionRects in android to make it defer the home gesture in gesture navigation mode, but it's not clear where I should do that. does anyone have any tips?

sonic venture
#

How do I load an animationclip into a Unity project from files?
I have an .anim called Idle and I want to modify a game's idleAnim. How do I do it? I'm talking about modding here, but I'm curious about the Unity specific 'loading'. Do I use assetbundles, or resources.load?

unborn elm
#

Hi,
I have a base dictionary with a generic object and an enum for my stats that all scene objects use and its working well.

public class StatsInfoDic : IEnumerable<KeyValuePair<StatsInfoTypeEnum, object>>
{
    private Dictionary<StatsInfoTypeEnum, object> _dict = new Dictionary<StatsInfoTypeEnum, object>();

    public void Add<T>(StatsInfoTypeEnum key, T value)
    {
        _dict.Add(key, value);
    }

    public T GetValue<T>(StatsInfoTypeEnum key)
    {
        if (_dict.TryGetValue(key, out var value) && value is T)
        {
            return (T)value;
        }
        Debug.LogWarning("key value does not exist of " + key.ToString() );
        return default;
    }
    public IEnumerator<KeyValuePair<StatsInfoTypeEnum, object>> GetEnumerator()
    {
        return _dict.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return _dict.GetEnumerator();
    }
}

The problem is that is quite a lot of work to get values (statsInfoDic.GetValue<type>(StatsInfoTypeEnum)) so right now I have started to build a wrapper class that basicly does things like this:

public class Stats
{
  public StatsInfoDic statsInfoDic;
    public void Add<T>(StatsInfoTypeEnum key, T value)
    {
        statsInfoDic.Add(key, value);
    }
    public T GetValue<T>(StatsInfoTypeEnum key)
    {
        return statsInfoDic.GetValue<T>(key);
    }
    public Stats()
    {
        statsInfoDic = new StatsInfoDic();
    }
    
}

And I started adding functions like this:

    public Faction GetFaction()
    {
        return statsInfoDic.GetValue<Faction>(StatsInfoTypeEnum.faction);
    }

The question is if there are any better ways around this or do I need to add this for all my enums? I could of course do something like GetString, GetFloat etc but wondering if anyone has done anything similar and come up with anything smarter

steady moat
unborn elm
steady moat
#

However, you will not be able to return generic type like you are doing, instead I suggest that you return an object such as Statistic that will be implicitly cast to the type you want

#

In other words, something like.

Dictionary<StatsInfoTypeEnum , Statistic> dict
this[StatsInfoTypeEnum type] => dict[type];

public class Statistic
{
    public static implicit operator float(Statistic s) => s.GetValue<float>();
}

#

It really is just something I would try.

#

I did once something similar but it did not fit my needs.

unborn elm
#

Great, reading up on it now, havent used it before

steady moat
# unborn elm Great, reading up on it now, havent used it before

Also, the reason why it did not work for me is because I had to feed parameters (Context, because of my statistic are context aware) to my GetValue which is not possible with implicit conversion.

However, down the line, I feel it was a mistake to make them context aware so I would suggest to not do that (-do not make them context aware-).

unborn elm
dense edge
#

hello, im having trouble in my game using navmesh. im making a city builder that uses navmesh, but the map is quite big, there is also verticality with bridges and otehr things of the type. i cant find a decent way to add walkable navemesh areas after i create a bridge. is its possible to make update the navmesh winthout rebaking everything?

rigid island
dense edge
rigid island
dense edge
#

can you give the component name or functions that can do that?

rigid island
#

I just told you lol Navmesh Surface component, then look at the different modes of baking / collecting objects to bake

dense edge
#

oooh ok

grand skiff
wheat cargo
#

Source generator dll's stored in the Assets folder are not supposed to apply to to assemblies in packages right?

leaden ice
wheat cargo
#
Assets\Behaviours\Systems\Input\Panels\DEPInput.cs(10,6): warning CS0436: The type 'EnumGeneratorAttribute' in 'Supernova.Enum.Generators\Supernova.Enum.Generators.EnumSourceGenerator\EnumGeneratorAttribute.g.cs' conflicts with the imported type 'EnumGeneratorAttribute' in 'AsyncImageLoader.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'Supernova.Enum.Generators\Supernova.Enum.Generators.EnumSourceGenerator\EnumGeneratorAttribute.g.cs'.
#

What I mean by "apply" is that the source generator runs for that assembly

#

At this point, I may just fork it and manually define the attribute

somber nacelle
wheat cargo
#

I had to fork and modify the generator anyways, since it isn't configured for Unity

north dove
#

Im working on a project that is a 3d modeler kind of like inventor assembly, but with specified parts instead of making your own; like certain sizes of metals. One feature that my friends are trying to add is an ability to create custom parts. But these custom parts are only made with like a plastic sheet. so they are like 1/8 inch thickness but any shape you want on a plastic sheet. (image for example).

#

i feel like this has been done before and wondering if there is any documentation on it?
Another solution would be to have the user import .svg, .fbx. or .obj files but i havent found any ways to do that yet. If someone could help me with that it would be super appreciated.

hexed pecan
#

Project seems cool

#

Are you asking how to implement the custom sheet?
And would players make the sheet ingame or in an external software?

north dove
#

so i have 2 options for it, either they make the sheet ingame, which really i just mean like they trace out some design they want and then it gets expanded into 3d but only 1/8 in long.
or the second option they can just import their own 3d model they made on like inventor or something

north dove
hexed pecan
north dove
#

and for the in game editor, ill have to look into that, i havent experimented with stuff like that

hexed pecan
#

Seems like it would work at runtime

#

You can always write your custom importer too if you want to.

north dove
#

hmm yea thats what we do a lot of the time, but like the scripting API is the difficult part.

#

i mean writing our own is better but does unity have that built in?

cold parrot
#

you likely want to be able to import shapes made with 3rd party tools that you only arrange in your unity tool.

faint hornet
#

why is this not working?

public static async Task LocalPosRoutine(Transform transform, AnimationCurve curve, Vector3 startPosition, Vector3 endPosition, float duration)
  {
    transform.localPosition = startPosition;
    transform.gameObject.SetActive(true);
    float et = 0;
    while (et < duration)
    {
      et += Time.deltaTime / duration;
      if (et > duration) { et = duration; }
      float eval = curve.Evaluate(et);
      transform.localPosition = Vector3.LerpUnclamped(startPosition, endPosition, eval);

      if (et >= duration)
      {
        transform.localPosition = endPosition;
        break;
      }
    }
    await Task.Yield();
  }```
somber nacelle
#

define "not working"
but at a guess, i'd say you're probably doing something like using Task.Run to start this which means it is scheduled to run on the threadpool which may not be the main thread, so when you try modifying a unity object the thread silently fails because you cannot use the majority of the unity API off of the main thread

hexed pecan
#

You are yielding outside the loop

#

So all of the while loop iterations happen at once

#

But yes, be explicit about what is not working

faint hornet
somber nacelle
#

also note that awaiting Task.Yield does not guarantee that it waits for the next frame. if you're on unity 6 you should be using the Awaitable class to await the next frame

somber nacelle
#

if the system decides to continue execution multiple times per frame then you'll get more iterations of the loop than you'd expect. or if it doesn't continue execution for several frames then you'll get fewer iterations. and Time.deltaTime is not the difference in time since the last iteration, but the difference in time since the last frame so those extra long/short yields would end up with weird behavior

faint hornet
# hexed pecan So all of the while loop iterations happen at once

so what you said fixed it but now i'm getting some other weird snapping like it's not fully running the while loop but ending on the correct position.. this is the function that calls it.

  {
    List<Task> tasks = new List<Task>();
    int delay = (int)(iterationDelay * 1000f);
    foreach (var transf in diceComps)
    {
      Vector3 start = transf.transform.localPosition;
      Vector3 end = transf.transform.localPosition;
      start.y -= 500f;
      tasks.Add(TransformUtility.LocalPosRoutine(transf.transform, curveDiceMove, start, end, duration));
      await Task.Delay(delay);
    }

    await Task.WhenAll(tasks);
  }```
#

anything wrong with this function?

#

the iterationDelay can be any float i want it to be and works fine.. but the duration variable only works if it is set to 1 sec...?

simple void
#

You're adding all commands to 'move' as their own tasks without actually moving them within the loop. Then it does it all your "move commands" at once when you say Task.WhenAll(tasks). It doesn't actually move anything during your loop

faint hornet
simple void
north dove
faint hornet
faint hornet
simple void
faint hornet
#

so instead of tasks.Add(TransformUtility.LocalPosRoutine(transf.transform, curveDiceMove, start, end, duration));
do this? Task t = TransformUtility.LocalPosRoutine(transf.transform, curveDiceMove, start, end, duration); tasks.Add(t);

simple void
#

No to run it you have to await the task or call task complete

#

I.e. await t

faint hornet
simple void
#

So you want to delay it then move the next component?

#

Right now none of your move commands are done until all the components have been delayed for

faint hornet
#

litterally the only issue that isn't behaving properly is when i adjust the "speed" at which this whole things happens.

simple void
#

No thereโ€™s a fundamental flaw in your code. When task.Add(awaitable task) is called it simply schedules it to be run at some point. It may be run right now or anytime in the future itโ€™s up to the scheduler. When you call Task.WhenAll() it actually does the commands, but since this function is async it finishes at any time relative to the game loop

#

You want to call move directly not queue it to await at once

faint hornet
faint hornet
simple void
#

If your code works itโ€™s simply a fluke and should not be relied upon

faint hornet
#

got it, ok so how do i acheive what i need to?

simple void
faint hornet
simple void
#

Assuming localpositionroutine spends duration to move the input, the fix is to not add the extra delay

faint hornet
#

for example:
all dice have the same animation duration lets say 1sec.
but their is also a itteration offset delay. lets say its .5 sec.

dice one goes. wait .5 sec then send dice 2. when dice 2 starts, dice one will be half way done with its own animation.

faint hornet
somber nacelle
#

is there a particular reason you switched from using coroutines to using tasks for this? coroutines can do what you are attempting much more easily and are actually intended for time/frame specific waiting unlike tasks which aren't exactly suited for what you appear to want

faint hornet
simple void
#

Make a new async function like this
tasks.Add(async () => {await Task.Delay(delay); await TransformUtility.LocalPositionRoutine(โ€ฆ);})

#

Sorry Iโ€™m on a mobile device itโ€™s really hard for me to type code

#

Then await all these tasks at then end using Task.WhenAll()

somber nacelle
faint hornet
simple void
faint hornet
faint hornet
simple void
#

Youโ€™re delaying when your movement is being added to the list not when itโ€™s executed

somber nacelle
faint hornet
faint hornet
#

also it won't let me use the lambda function to make it

simple void
simple void
somber nacelle
#

and you would get the benefit of actual proper frame timing instead of what i described earlier regarding Task.Yield.
or switching to using unity's Awaitable class (if you are on unity 6) would lead to better results with your current code

faint hornet
#

can i break this down a bit more.. idk why but i feel like i'm not understnding and their might be a miscomunication on my end.

this is what i'm trying to acheive, forget the animation stuff for now.

  1. a coroutine to handle 1 single animation.
  2. a coroutine that takes in an array of transforms and the a coroutine (the number 1.) and assign it to each transform with a delay between all of them. ex. (Transform[] transforms, Coroutine/Task routine/task, float iterationDelay)
hexed pecan
#

So you want to perform the same coroutine on several objects in a sequence

#

And be able to pass the coroutine into the second coroutine as an argument

faint hornet
#

exactly. but i want it to be a pure function that i can reuse in any project

#

my reasoning for wanting it this way to to be able to pass in new "animations"(coroutines) to the same function for different aspects of my game or multipe games

#

I've made this Coroutine function many many many times. and i'm tired of remaking it. so i figured Tasks are the only way to go since i can store it statically.

#

@hexed pecan

hexed pecan
#

Uhh there might be a better way of going about this but this is what came to mind...cs void Play() { Transform[] targets = ... StartCoroutine(AllAnimsCoroutine(targets, t => AnimCoroutine(t))); } IEnumerator AnimCoroutine(Transform t) { /* Do stuff */ yield break; } IEnumerator AllAnimsCoroutine(Transform[] targets, Func<Transform, IEnumerator> coroutineGetter) { foreach (var target in targets) { IEnumerator coroutine = coroutineGetter.Invoke(target); yield return StartCoroutine(coroutine); // Waits for the coroutine } }

#

So passing in a Func that gets the coroutine for that transform

#

Could be generic too instead of using just Transforms

faint hornet
#

so do this work in a way to make it static?

#

and how would i be able to have my game state waiting for all routines to end?

somber nacelle
#

that code, as written, could not be made static because it is calling StartCoroutine on this, but as i said before, it's incredibly trivial to just spawn an object that you slap a monobehaviour on to use for starting the coroutines

hexed pecan
#

I sometimes do use a singleton that runs coroutines that aren't attached to a particular gameobject

faint hornet
#

I'm trying really hard to make a clean setup for this since i use this type of thing often and in almost everyone of projects... there is not other way other than to create a singlton or DDOL object?

#

@hexed pecan

hexed pecan
#

If you use coroutines, you need a monobehaviour, that's it

somber nacelle
#

if you want to use a coroutine then you need a MonoBehaviour. that is not negotiable.
if you want to use async methods then you would ideally use unity's Awaitable over Tasks so you have the proper control over the execution timing that you want

hexed pecan
faint hornet
#

and btw, i don;t want people to think i'm just trying to get all the code written for me. i'm trying my best to understand this fundamentally so i can iapply this knowledeg to alot of other things in the future without having to ask for more help

hexed pecan
#

So you don't have to place it in the scene beforehand

faint hornet
hexed pecan
#

Need more specifics then

#

Maybe give an example code of how you would like to use it

civic girder
#

is there any guide about using namespaces to reduce domain reloading?

fallen lotus
#

Can anyone help me with this issue? I'm using tilemaps for the first time to layout the map. I have the red tiles set to have a collider and the blue one (top left) and green one (bottom right) to not have colliders. I'm trying to send raycast out to detect if the user hit a wall. however, I need to assign certain tiles a layermask. Right? How do I do this?

somber nacelle
#

it is the number of static objects in each assembly that is being reloaded that determines the time domain reload takes. split your code up into different assemblies and only the ones that have changed will be reloaded

somber nacelle
# faint hornet i'm aware of how to make all this work the way you have been showing me. I'm jus...

this is not optimal, hasn't been tested, and was written in notepad++ so there may be issues, but theoretically should work for what you are trying to do (you'll obviously need to add the correct using directives, i was too lazy to do so)

https://paste.myst.rs/fp0w8328
it's based on what Osmal posted before, and even includes a callback for when all of the coroutines have completed. you can then build on this to do more than just start a bunch of coroutines in sequence

spare dome
#

would I create a class for projectiles that contains such variables and Booleans such as damage, isexplosive, speed, dropoff, etc and access them in the script of which instantiates the projectiles or would for a global bullet variables or is it a waste to do such and I would instead just include these in the class of which instantiates the projectiles?

daring pine
#

Guys i am using playerprefab to save data i want to save data for scene 1 when i go to scene 2 and when i come back to scene 1 it loads

#

how do i do that?

cosmic rain
daring pine
#

everytime i try it doesnt worlk

cosmic rain
daring pine
#

how do i write it

cosmic rain
daring pine
#

private void ???

daring pine
cosmic rain
daring pine
#

burh

#

ok

cosmic rain
#

You're not gonna get a complete solution here

#

At least show some effort

#

There are many resources online on how to do that.

daring pine
#

i acctually searched

#

and did

#

this is my last effore

#

i came here as a last choice

spare dome
#

sorry for the lack of context

cosmic rain
cosmic rain
daring pine
#

i want to use it for scene entry Load Scene exit Save

cosmic rain
#

As for loading, you can do that in awake or on scene loaded callback.

spare dome
cosmic rain
spare dome
#

sweet

cosmic rain
#

So you can define many different bullets scenes with instances of the class.

spare dome
#

nice, I'll look into it, Thanks Dlich as always.

faint hornet
somber nacelle
#

ah, it's probably because i named the property the same as the class, change one or the other

#

Mono isn't a good name for it anyway, so i'd recommend changing it to something more descriptive

faint hornet
#

is it because this Mono.StartRoutine should be named _mono.StartRoutine

somber nacelle
#

no, you need to use the property

faint hornet
somber nacelle
#

i am aware. and i've told you how to resolve that

faint hornet
#

i'm just not sure what part you are talking about... what is mono in "Mono.StartRoutine(InSequence(objects, routineGetter, delay), onComplete);" reffereing to?

faint hornet
somber nacelle
#

it should be the property, but as i've pointed out i named the property the same thing as the nested class so it's trying to use that directly instead

somber nacelle
#

are you just unaware of what a property is?

faint hornet
#

yeah what property are you talking about. it's not that i'm not listening to you, i just don't know what you are saying

somber nacelle
#

the one on line 4. did you just not read the code or what?

faint hornet
#

is Mono something that already exists in Unity boilerplate code or something?

somber nacelle
#

alright so you just copy/pasted the code without reading it. that's good to know

faint hornet
#

no i didn't actually, i read the code for 5 min trying to understand it. then i realized i have to go, so i copy and pasted it into my vscode. to look at later but their are a ton of errors. im just asking what's wrong with it

somber nacelle
#

and let me guess, those "ton of errors" are that one error and then a bunch of errors about missing a using directive because i already told you that i did not include those

#

i already told you how to resolve this issue though, but you didn't bother reading the code so do whatever you want with it ๐Ÿคทโ€โ™‚๏ธ

faint hornet
#

have a great night. i gtg

faint hornet
somber nacelle
#

oh of course, i'm supposed to read your mind to know you've changed something?

arctic steeple
#

What is the different between update and fixedupdate, I was looking for how to implement addtorque and they say I should use fixedupdate instead of update, why ?

somber nacelle
#

Update runs every single frame. FixedUpdate runs at a fixed timestep that is in step with the physics engine. It is typically best to perform all physics operations inside of FixedUpdate so that those operations are performed along with physics updating and so they are performed on a fixed timestep

arctic steeple
#

Even with movement ? Should Transform.translate or transform.position be used in FixedUpdate ?

somber nacelle
#

neither of those use physics

#

in fact, if you want an object to interact with physics correctly you shouldn't use either of those and should instead use a rigidbody (or a character controller if you only want it to react to colliders in its movement path)

arctic steeple
somber nacelle
#

yes, both of those interact with physics

arctic steeple
#

And everything which use rigidbody is physics so I should put them in the fixed update ?

spare dome
#

all of the rigidbody methods yes

arctic steeple
#

Is it necessary to use time.deltatime in fixedupdate since they use physics based instead of framrate based ?

somber nacelle
#

it depends on what you are doing

cosmic rain
arctic steeple
#

I was trying to get the ball moving like this, should I add time.deltatime ?

somber nacelle
#

no

cosmic rain
#

No, as you're assigning it to velocity.

errant flame
#

Hey , I am trying to manage my async processes with UniTask. In the UniTask tracker, the process is always pending, if I exit gameMode, only then it completes. I can't find anything to block the code.

Any idea ?

public static async UniTaskVoid LoadSceneAsync(int sceneIndex, Action<float> onProgress = null, Action onComplete = null, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();
            AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex);
            
            if (operation == null)
            {
                ELog.LogError("Scene Loader", $"Failed to start loading scene with index: {sceneIndex}");
                return;
            }
            operation.allowSceneActivation = false;
            try
            {
                while (operation.progress < 0.9f)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    Debug.Log($"Progress: {operation.progress}");
                    onProgress?.Invoke(operation.progress);
                    await UniTask.Yield(cancellationToken);
                }
                
                onProgress?.Invoke(1f);
                operation.allowSceneActivation = true;
                await UniTask.WaitUntil(() => operation.isDone, cancellationToken: cancellationToken);
                onComplete?.Invoke();
                ELog.LogInfo("Scene Loader", $"Successfully loaded scene with index: {sceneIndex}");
            }
            catch (OperationCanceledException)
            {
                ELog.LogWarning("Scene Loader", $"Scene loading cancelled for index: {sceneIndex}");
            }
            catch (Exception e)
            {
                ELog.LogException(e);
            }
        }
SceneLoader.LoadSceneAsync(1).Forget();
cosmic rain