#archived-code-general

1 messages Β· Page 354 of 1

gray mural
#

So I have an impression that it was a goal

jovial valley
#

perhaps I was unclear with my wording, when I said "instance" of a base prefab I meant an "Instantiated Instance" of a base prefab.

gray mural
#

Alright, modify data, anyway

spring creek
jovial valley
#

doesnt matter you know what I meant, a gamobject which was created with Instantiate(base prefab).

spring creek
#

It very much matters that terms are understood imo

gray mural
#

In a custom Editor, Awake is called when the script is added, and OnEnable when the script is loaded, both on script compilation and when enabling the object.
Is there any easy way to make a method, called when the script is added, or when the scripts are compiled (to avoid issues when modifying code manually)? When using OnEnable, assigned variables get messed up on object enable.
I have just discovered the CompilationPipeline.assemblyCompilationFinished event, so wonder whether using it along with Awake is the best thing

full elk
#

Hey i have a problem with unity pool system ObjectPool<GameObject>
InvalidOperationException: Trying to release an object that has already been released to the pool.
it seem because my pool is small that I get the same gameobject and he is upset when i release it back again...
https://paste.ofcode.org/wqt238s3JeA3p6T9NJ89Xg
did i do something wrong?

jovial valley
#

internal static extern void ApplyPropertyModificationToObject([NotNull("NullExceptionObject")] UnityEngine.Object target, PropertyModification value);
is there a way I can see what this method is doing?
(i need propertyModifications to work during runtime, so ima copy some of this code and slap it onto a script)

gray mural
jovial valley
#

ctrl + c

gray mural
#

Go copy it and get some errors

jovial valley
#

i cant see the body of it

gray mural
jovial valley
#

soo... is there a way to see the body of it??

gray mural
jovial valley
#

rip

gray mural
#

The thing that I'm sure about is that what you're trying to do it pretty useless!

jovial valley
#

huh, yeah i was just tryina be lazy and not figure it out

zinc parrot
#

if I use tasks for multithreading, is there a way to not make them be able to run on the main thread?

rigid island
#

but Unity API functions cannot run on anything besides main thread

zinc parrot
#

I mean, if I dispatch like 10 tasks at once, and only have 8 threads
How can I make the tasks only run on 7 of the threads, leaving the main thread alone

#

wait i think im being dumb

lean sail
full elk
#

I subscribed and unsubscribe the event on get and release so if the event handler is triggered it must be from an active gamepbject

grizzled ferry
#

could that be so?

full elk
#

But im not sure 100%
Because it is the same gamepbject id after all

grizzled ferry
full elk
#

Sure, though I changed the code already to delegate the action πŸ˜…

grizzled ferry
#

hold on

#

doesnt have anything to do with it, sorry, my mistake

grizzled ferry
#

idk what I was thinking on

grizzled ferry
#

i mean, the script the code you sent comes from

full elk
full elk
lean sail
#

It is just defining how it gets released

full elk
#

and the release was in handleFaintedMember whch triggered by OnFained in the prefab

lean sail
#

I dont really have the time to go through all this. It should be pretty simple for you to debug and see if and when you're calling release on these objects though

full elk
grizzled ferry
#

check it

full elk
#

sorry i didnt show the baseClass

#

you might be right though!

full elk
# grizzled ferry check it

what is the better design for it? the manager listen to events from the prefabs or pass a function with the logic of "handleFaint" to the prefab?

grizzled ferry
grizzled ferry
lean sail
full elk
full elk
grizzled ferry
#

depends pretty much on your context tho

full elk
grizzled ferry
#

in that case, for the single responsability principle, I'd make them invoke an event when they die

#

the manager would listen to that event and make them respawn

queen saffron
#
KeyNotFoundException: The given key '0' was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <787acc3c9a4c471ba7d971300105af24>:0)
UnityEngine.ProBuilder.WingedEdge.GetWingedEdges (UnityEngine.ProBuilder.ProBuilderMesh mesh, System.Collections.Generic.IEnumerable`1[T] faces, System.Boolean oneWingPerFace) (at ./Library/PackageCache/com.unity.probuilder@5.1.1/Runtime/Core/WingedEdge.cs:366)
UnityEngine.ProBuilder.MeshOperations.ExtrudeElements.ExtrudeAsGroups (UnityEngine.ProBuilder.ProBuilderMesh mesh, System.Collections.Generic.IEnumerable`1[T] faces, System.Boolean compensateAngleVertexDistance, System.Single distance) (at ./Library/PackageCache/com.unity.probuilder@5.1.1/Runtime/MeshOperations/ExtrudeElements.cs:396)
UnityEngine.ProBuilder.MeshOperations.ExtrudeElements.Extrude (UnityEngine.ProBuilder.ProBuilderMesh mesh, System.Collections.Generic.IEnumerable`1[T] faces, UnityEngine.ProBuilder.ExtrudeMethod method, System.Single distance) (at ./Library/PackageCache/com.unity.probuilder@5.1.1/Runtime/MeshOperations/ExtrudeElements.cs:32)
BrushKit.ExtrudeFaces () (at Assets/Source/Script/BrushKit.cs:333)

I'm using ProBuilder Plugin for Mesh Manipulation sculpting but i'm getting this unfamiliar error in runtime

lean sail
#

Though really I'd just abandon probuilder and go to blender if you're having issues. Havent used it in some time but iirc a lot of probuilder functionality is experimental or just straight up crashed unity for me.

fringe ridge
#

I have a weird error, and not sure where to post it. I basically get this :
'Event' is an ambiguous reference between 'Unity.Services.Analytics.Event' and 'Unity.Services.Analytics.Internal.Event' in EventWrapper.cs file, which is part of unity I guess. When i try to fix the error by changing Event to Unity.Services.Analytics.Internal.Event, the file reverts. On windows, after a few times it just stays that way, but on Mac i can't seem to make it stay that way. I can't edit the file at all, because it just reverts back to the old state. It's so stupid. The file is part of Unity push notifications

#

this is the file :

using Unity.Services.Analytics;
using Unity.Services.Analytics.Internal;

namespace Unity.Services.PushNotifications
{
    interface IPushNotificationEventsWrapper
    {
        void RecordCustomEvent(string eventName, Dictionary<string, object> parameters, int version);
    }

    class EventsWrapper: IPushNotificationEventsWrapper
    {
        public void RecordCustomEvent(string eventName, Dictionary<string, object> parameters, int version)
        {
            Event evt = new Event(eventName, version);

            foreach (KeyValuePair<string, object> parameter in parameters)
            {
                evt.Parameters.Set(parameter.Key, parameter.Value);
            }

            evt.Parameters.AddUserCountry();



            AnalyticsService.Instance.RecordInternalEvent(evt);
        }
    }
}
queen saffron
wanton finch
#

can somebody explain what's void start and update, explain it beginner friendly way i don't know how i should use those

spare island
wanton finch
#

ohh

#

@spare island thats on me my bad

subtle spoke
#

How do I need to set up a function in a C# DLL to be called and how would I call it?

subtle spoke
indigo tree
subtle spoke
#

I wrote it in C# beause I'm not as familiar with C++

#

so it would be C# to C#, but not sure how to make this work

#

maybe I import UnityEngine? But right now it straight up says "Can't be found"

flat marsh
#

Hello guys! I am having a couple issues with my player movement, specifically with the wall jump. I have tried to make it so that after wall jumping, I cant move for 0.2 seconds, to make it so that my player can get stuck if they are pressing the a / d key (left and right). However, this does not work for some reason. I have looked over the code several time, and I cant find why it doesn't work. If I wall jump, when not pressing A / D, I can move for that time, but if I wall jump when pressing pressing w and a/d it doesn't work. Here is the code: https://gdl.space/avevinomiy.cpp

indigo tree
subtle spoke
indigo tree
#

Ah my mistake

#

Hold on lemme get resource.

indigo tree
cosmic rain
#

You call the function from a dll just like any other function.

subtle spoke
#

I think this might be because I've excluded editor in the Plugin Inspector. This is because I use some namespaces like Windows that causes errors in the code when Editor is included

subtle spoke
cosmic rain
#
  1. Make sure it's referenced correctly in the editor. Check it's settings in the inspector
subtle spoke
#

right now it's not throwing errors anymore in the Editor console, but it is in the file.

#

and when I run it, it hits me with

GameObject references runtime script in scene file. Fixing!

And my code has no effect.

#

Now not even my script is erroring

#

it's just a the warning I wrote about above

cosmic rain
spring creek
tawny elkBOT
cosmic rain
cosmic rain
subtle spoke
subtle spoke
#

also, this error just appeared

#

I unfortunately didn't see when, but I didn't touch anything

cosmic rain
#

For starters config your ide how Aethenosity pointed out

subtle spoke
spring creek
#

It is not configured

subtle spoke
#

I have just done it again

spring creek
#

Go to external tools and click regenerate project files while the ide is closed

subtle spoke
subtle spoke
spring creek
cosmic rain
#

I'd just recommend switching to VS instead. VS code is too much of a headache for what it provides imho.

subtle spoke
#

Not sure where to find the console

#

no errors in the terminal, debug console, or problems

#

none of these

spring creek
#

Ok, well the configuration is just not taking then. As far as I see, you have done everything correctly

#

Vs code just shits the bed sometimes

subtle spoke
#

OK lemme switch to VS then

subtle spoke
cosmic rain
subtle spoke
#

I'll move through with Visual Studio then

#

@cosmic rain @spring creek

cosmic rain
#

What are you trying to do? When does this message appear? Did you actually install VS correctly for use with unity?

subtle spoke
#

I am updating it right now

cosmic rain
subtle spoke
#

every step before updating, yes

cosmic rain
#

Then try regenerating the project files, or even just deleting the sln and csproj files manually

flat marsh
#

Hello guys! I am having a couple issues with my player movement, specifically with the wall jump. I have tried to make it so that after wall jumping, I cant move for 0.2 seconds, to make it so that my player can get stuck if they are pressing the a / d key (left and right). However, this does not work for some reason. I have looked over the code several time, and I cant find why it doesn't work. If I wall jump, when not pressing A / D, I can move for that time, but if I wall jump when pressing pressing w and a/d it doesn't work. Here is the code: https://gdl.space/avevinomiy.cpp

cosmic rain
flat marsh
cosmic rain
flat marsh
cosmic rain
#

Well, what did you confirm then?

flat marsh
#

So I was printing out CanMoveOnX, to check whether the values were actually correct

#

and it was giving me less that 0.2,

#

but still allowed movement during that time

cosmic rain
#

Well, what part of your code is responsible for movement? Did you not check why it works regardless of that condition?

flat marsh
cosmic rain
flat marsh
cosmic rain
#

This is simple debugging. You should be expected to be able to do it if you're asking in this channel.

flat marsh
#

Ok, ill go over it again

#

I GOT IT WORKING

#

Ahh I see now what was wrong XD

#

It is simple but hard to see

#

So basically, I was setting the last on wall timer for when I left the wall, however, it didn't regester I had left the wall cause I was pressing A.

#

So I changed it so that last on wall is when I just try to jump, not when I actually leave the wall

#

which solves the issue

jagged plume
#

Any idea how to access particleSystem rate over time?

#

It seems that a lot of docs / forums offer deprecated solutions

#

I'm getting this error by the way with the code above:
Assets\Scripts\MC\MCController.cs(184,13): error CS1612: Cannot modify the return value of 'ParticleSystem.emission' because it is not a variable

spring creek
jagged plume
#

is ps.emission passed by reference somehow?

#

Maybe it's me not understanding C# properly

#

but in my current understanding, values are typically passed by value and not by reference when initializing variables (?)

spring creek
#

Classes are reference types btw. Not value types

jagged plume
#

oh

#

Isn't PS.emission a struct though?

#

Are structs passed by reference too ?

#

So is it like a Unity specific thing?

quartz folio
leaden solstice
#

Unity thing

fallen lotus
#

I'm trying to make it so that the minimap rotates with the third person controller direction and the pointer rotates based on the players direction they are facing, although i cant get the pointer to work correctly. it is spinning with the third person controller and i can't figure out why

rigid island
fallen lotus
#

omg πŸ€¦β€β™‚οΈ forgot to attach it πŸ˜…

fallen lotus
#

let me know if youneed more pictures of explanation

jagged plume
rigid island
fallen lotus
#

hmmm is there a better solution that you know of?

quartz folio
rigid island
fallen lotus
#

no worries

#

im trying to make a minimap similar to gta 5

#

cause i like that one so much

rigid island
#

yeah just be ready second camera consider performance hit

#

you're rendering the world twice essentially

#

most radar maps are just 2D textures anyway

fallen lotus
#

yeah ill mess with the performance aspect later but ima just do this for now

warm badger
#

why am i getting 12+ ms while drawing only 10000 instances of a cube using Graphics.DrawMeshInstancedIndirect? what am i doing wrong here?

rigid island
warm badger
#

@little meadow did you mean how i got that 12+ ms? i got that from the game stats

fallen lotus
#

it just holds it in an organized manor

rigid island
fallen lotus
#

wdym?

#

like when does the pointer start rotating when it shouldnt?

fallen lotus
#

its kinda hard to tell

#

it just kinda starts

#

ill try to get a better video to show you

fallen lotus
#

its like as soon as you start moving and spinning the camera around is when it starts to spin weirdly

#

and it shouldn't be spinning when the player stands still and only the camera moves around

rigid island
fallen lotus
rigid island
# fallen lotus what do you mean by that

maybe try cs [SerializeField] Transform minimapCamera; var relativeRotation = player.eulerAngles.y - minimapCamera.eulerAngles.y; pointer.rotation = Quaternion.Euler(0, 0, -relativeRotation);

fallen lotus
#

and this would go in minimap display?

#

That worked!

#

You are the goat!

rigid island
#

nice!

knotty sun
#

this
var relativeRotation = player.eulerAngles.y - minimapCamera.eulerAngles.y;
is very dangereous to rely on, it may not return the values you expect

rigid island
#

would it be better to use Atan2 ?

fallen lotus
rigid island
# fallen lotus What would I need to do better

probably something to ask @knotty sun I'm not exactly good with rotations πŸ˜…
I was thinking with radians you can do

var playerForwardRelativeToCamera = minimapCamera.InverseTransformDirection(player.forward);
var angle = Mathf.Atan2(playerForwardRelativeToCamera.x, playerForwardRelativeToCamera.z) * Mathf.Rad2Deg;
pointer.rotation = Quaternion.Euler(0, 0, -angle);```
fallen lotus
#

That code has some weird behavior

#

its like horizontal and rotates but also flips horizontally sometimes

rigid island
#

ah yeah then not sure lol

knotty sun
#

I think

var relativeRotation = player.rotation * Quaternion.Inverse(minimapCamera.rotation)
#

or Quaternion.Angle will give you the angle difference between 2 quaternions

#

so you could do

var angle = Quaternion.Angle(player.rotation, minimapCamera.rotation);
pointer.rotation = Quaternion.AngleAxis(angle, Vector3.up);
#

it's way too early in the morning to be thinking in Quaternion math, lol

rigid island
#

same lol 4am here

knotty sun
#

definitely not something to do with the brain only firing on 2 cylinders

warm badger
#

why am i getting 12+ ms while drawing only 10000 instances of a cube using Graphics.DrawMeshInstancedIndirect? what am i doing wrong here?

little meadow
#

12ms does seem a bit high for this... is it 12ms for the GPU? where do you see it?

cosmic rain
#

I bet that the main issue is allocating a huge buffer every frame

cosmic rain
knotty sun
# fringe ridge anyone?

why do you have both of these?
using Unity.Services.Analytics;
using Unity.Services.Analytics.Internal;

fringe ridge
fringe ridge
cosmic rain
warm badger
fringe ridge
cosmic rain
cosmic rain
cosmic rain
fringe ridge
#

I updated to a new version, and it's good now. Thanks

ocean hollow
#
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (GameIsPaused)
            {
                Resume();
            }
            else
            {
                Pause();
            }
        }
    }

void Pause()
    {
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible = true;

        GameIsPaused = true;
        pauseMenuUI.SetActive(true);
        Time.timeScale = 0;
    }

i have a couple functions to handle my game pause logic and it works fine for the most part. However, ive noticed that whenever I use this script in any of my projects, and my GameIsPaused variable is a static bool, i have to press the esc key twice for the pause function to execute. When my GameIsPaused variable is not static, however, i only have to press my esc key once and everything works as intended. can anyone share some insight on what might be happening here?

mossy snow
ocean hollow
onyx glade
#

Hey folks, not sure if this is the right place to ask this. But is there a way to import a scene with just the objects & textures into a new project, without any the settings/dependencies/packages of the original project?

I made a big woopsie and accidentally overwrote my original project when experimenting with an asset. I admittedly was being a little hasty, and it ended up installing URP, Burst, Core RP and a bunch of other things I don't want or need. It completely wrecked all my textures and VR stuff, and I have been working for hours to try and remove or reverse the changes with no luck.

I think my best option would be to simply start a new project, and basically import just the scenes/objects by themselves with nothing else, and fix my VR stuff later. (I needed to make some changes anyways)

Is such a thing possible?

#

I don't mind having to fix up some textures, I just don't want to have to re-import every object one by one and recreate every scene manually if it can at all be avoided

knotty sun
onyx glade
light pond
#

i have chess board like tiles is there a rule tile i can use to place them fast one by 1

gray mural
#

Also, pretty sure it's pretty useless

full elk
light pond
#

also why is my slider ui element behind everything

gray mural
#

If both are UI, check the hierarchy order

gray mural
light pond
#

checked and did everything still didnt work

gray mural
#

You have to create your own one

light pond
#

this looks better imo

gray mural
light pond
gray mural
#

How are you going to add textures to your game without using textures?

light pond
#

No I’m gonna use the current one u see

full elk
grizzled ferry
knotty sun
full elk
#

@grizzled ferry @knotty sun i found the issue. because i needed to pass the gameobject i want to release to the handler i used anonymous function so it didnt unsubscribe it
i fixed it by changing the event to Event<GameObject>

amber mauve
#

Does anyone know how to cap an application on 40 fps on 60hz display device - I know its possible some game are doing it and it works on both iOS and Andriod but i am unable to do so using unity ,any help or any suggestion towards that direction would really help
please dont say i will need to get enterprise license

and also
Application.SetTargetFrameRate(40); this will cap game to 30fps on a 60hz mobile and will only work in 120hz mobile

oblique spoke
#

There's also Adaptive Performance to respond to power/thermal/battery conditions on a higher level

amber mauve
#

`using UnityEngine;
using System.Collections;
using System.Threading;

public class CustomFrameLimiter : MonoBehaviour
{
[Range(10, 144)]
public int targetFrameRate = 40;

private float targetFrameTime;
private float lastFrameTime;

void Start()
{
    ApplyFrameRate();
    StartCoroutine(FrameLimiterCoroutine());
}

void ApplyFrameRate()
{
    targetFrameTime = 1f / targetFrameRate;
    QualitySettings.vSyncCount = 0; // Disable VSync to use custom frame rate
}

IEnumerator FrameLimiterCoroutine()
{
    while (true)
    {
        float currentTime = Time.realtimeSinceStartup;
        float elapsedTime = currentTime - lastFrameTime;
        float timeToWait = targetFrameTime - elapsedTime;

        if (timeToWait > 0)
        {
            // Introduce a delay by waiting until the target frame time is reached
            Thread.Sleep((int)(timeToWait * 1000)); // Convert to milliseconds
        }

        lastFrameTime = Time.realtimeSinceStartup;
        yield return null; // Continue to the next frame
    }
}

}
`
how about this code?

amber mauve
#

like i want my application to be capped at 40fps on 60hz display wouldnt ondemand render just change render speed

oblique spoke
#

Not throttling the device would help if that is what you are seeing, yes

amber mauve
amber mauve
oblique spoke
#

Unity has various APIs to better work with mobile devices

amber mauve
#

see i want players to have option to change fps as well i dont want it to be fixed but i also want a 40fps mode ( currently im provviding 20-25-30-40-60 fps mode) but 40 fps is not working

#

will adaptive performance help with this?

oblique spoke
# amber mauve will adaptive performance help with this?

It will help for the reasons you are most likely doing this frame limiting. Just setting a framerate and having users pick can be a bit naive in the mobile world.
Engine rendering speed and screen refresh rate is something you might want to think about separately.

amber mauve
#

people like to choose it

#

and moreover i can cap FPS based on device specs

#

like you can only get 40 fps on x device but if you want you can play in 20fps as well

amber mauve
#

setting it on adaptive performance does nothing for me

#

@oblique spoke

tardy hull
#

Hello, I have problem with audio mixer, I am trying to set value of it from player prefs in awake but then something (I read it a snapshot) is overriding it. If player set volume values I would like to have them from start, not after their ears are blasted off.
Am I doing something wrong or is there work around?

PS: Pls @ me

soft shard
# tardy hull Hello, I have problem with audio mixer, I am trying to set value of it from play...

I dont think you need a mixer for volume, you can normally set the volume on the AudioSource directly, or if you want all your audio sources to always have the same volume you can also set AudioListener.volume which is a static value - if you do prefer to use a mixer, AFAIK you should either use exposed properties of your filters, or a "snapshot", though I havnt needed to use snapshots with my mixers, I usually just make a "group" instead and control the "attenuation volume"

tardy hull
young bluff
#

COMException
Rethrow as AssimpException: Error loading unmanaged library from path: assimp.dll.
Does anyone have any ideas to what might be causing this error. The lib works fine on my computer but when someone else tried downloading the repo and opening and running the project he got this error

dusk apex
#

Sounds like the compiled library (dll) isn't compatible with their setup

young bluff
mighty void
#

why this happens?

#

why the color changes?

craggy tapir
#

I've got a problem:
Timberborn stable: full FPS, even with over 200 beavers and at 33x speed
Timberborn experimental: 1-2FPS with just 10 beaver at 3x speed

7950X3D. If I launch it in steam with the command
taskset -c 0,2,4,6 %command%
everything seems to run perfectly right, full FPS at all times

dusk apex
craggy tapir
#

I did contact some devs of Timberborn

#

I was wondering if this is a general Unity problem or some problem with how they wrote the Timberborn game

#

I was hoping to get a bit of answers here that I might be able to share with Timberborn devs

#

or just with people who experience the same issue, as I personally know at least 10 people so far that have this exact same problem, and i hardly know anyone

lean sail
craggy tapir
#

understood

paper ember
#

Hi! I'm struggling with writing Play Mode tests. I have a script that calls Screen.height. It works in the editors Play Mode, but not in Play Mode tests. There it gives a null. I'm loading a scene in {Setup] with SceneManager.LoadScene("TestScene", LoadSceneMode.Single). Why is Screen null?

rain patio
spring creek
jagged plume
#

what's the diff between code beginner code general code advanced?

cosmic rain
vivid wind
#

Anyone know of a good unity asset for handling large volumes of text that is not dialog i.e Mission Text, Item/group/concept descriptions in in-game wiki, journal entry, etc. So far the options I've found are focused for dialog rather than like Text Content.

cold parrot
subtle spoke
#

Hello, while working with System DLLs, Unity Editor crashed, and I got this error in the Editor.Log.

Can someone please help me? I'll give any context I can. This has been bugging me for so long. Thanks for any help!

knotty sun
subtle spoke
knotty sun
#

Are you building using .Net FrameWork or .Net Standard

subtle spoke
#

.net framework

#

mono

#

@knotty sun

knotty sun
#

ok, can you check the dll to make sure it is .Net framework 4.7.2 or below

#

and see what dependencies it has

#

I'm a bit concerned with the Windows.Devices.Bluetooth. I'm pretty sure Mono will not support this

onyx cypress
#

i keep on getting this errror even tho there are no duplicates of upadtes

#

in my cosde

lean sail
onyx cypress
#

soh ok

swift falcon
#

Why is the game object I tagged as something returns "Untagged" when I get its tag?

oblique spoke
swift falcon
#

Pretty sure I am not

#

This is the object with the collider entering

cosmic rain
#

Or a child object with another collider

swift falcon
#

No to both

#

The collsion triggers

#

But it does not fetch the tag

cosmic rain
swift falcon
#

Of course

#

    void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log("Collision"); //Does show up upon entering

        Debug.Log(gameObject.tag); //Returns "Untagged"

        if(gameObject.tag.Equals("Shell")){ //thus, this does not trigger
            Debug.Log("Hit");

            health -= 1f;

            healthBar.transform.localScale = Vector3.right * health / 100f;
        }
    }```
cosmic rain
swift falcon
#

Hum, what's the point, will do but

cosmic rain
swift falcon
#

Oh

cosmic rain
swift falcon
#

I must have messed up

#

I am tired

#

I should not do this

#

Let me hide in a corner πŸ₯²

#

For info

#

if(collision.gameObject.tag.Equals("Shell")){ is what I really wanted

#

Yuuup

#

The shame is immeasurable

#

πŸ˜‚

#

Also

#
healthBar.transform.localScale = new Vector3(0, 0.2f, 1) + Vector3.right * health / 20f;``` was the proper code for the health bar (ignoring the hard coded values)
swift falcon
#

Interesting

spring basin
#

i was playing saints row 2022 the other day. how does the different voice pitch thing work? they basically had accents(Voice 1, Voice 2 etc) and then you had a slider to set the pitch and it was pretty brilliant

fleet furnace
weary swift
#

Yo ! I want to make a game with a horde of enemies, first I tried using the NavMeshAgent system but this doesn't really work because they can't really avoid each others, should I make my own system of pathfinding and is there common process for making horde ? Thanks !

knotty sun
weary swift
#

Ok, how would you go about setting up the system ? I tried many differents ideas and nothing was good enough

#

Therefore I'm here asking

knotty sun
#

First explain exactly what problems you are experiencing

weary swift
#

Ok

#

I want my enemis to find the path to my player. I'm doing that by calling SetDestination to the player position every x seconds. The problem with that is that they don't collides into each others, therefore they stack in one another. I tried using NavMeshObstacle and .Move or .AddForce but this cost too much performances because CalculatePath is synched. I also tried to put a rigidbody and let the agent move but this also doesn't work and creates strange behaviours. I just want my enemies to move to the player without merging into each others

#

And for the rigidbody the problem is that they push each others and I don't want that

knotty sun
#

Sorry but that makes no sense, if you have 20 enemies and they are all told to converge on the same point, of course they will stack up, what are you expecting them to do?

weary swift
#

Sorry English isn't my main language. Take for example when there is a crowd of people going into the subway they will slow down if there are in the middle of the crowd, but they will still move forward

#

That's what I want

#

In simple terms I want collision that's all

#

But I don't want my enemies to push each others

knotty sun
#

Sounds like you want a Raycast which reduces agent speed

weary swift
#

Isn't a raycast going to cost too much performance ?

knotty sun
#

nah

weary swift
#

I have an idea but I'm not sure if it's possible, is it possible to make rigidbodies not push each others ? If it's possible I could put a rigidbody on my enemies, this will make them move slower when they hit another enemy ?

knotty sun
#

but you want to slow before the hit do you not?

#

A trigger collider could also do that

weary swift
#

or slow down if they can't move at full speed in the direction to the player

knotty sun
weary swift
#

Yes

knotty sun
#

so slow down BEFORE they walk into someone, as you would irl

weary swift
#

If you're using raycast yes, if you're using physics no

knotty sun
#

raycast is physics

weary swift
#

Ok, but by physic I mean rigidbody

knotty sun
#

trigger collider could also be used

weary swift
#

But this mean I will need to move them manually right ?

#

But CalculatePath is not performant at all

knotty sun
#

no, setdestiniation would still work

knotty sun
weary swift
#

But when moving manually and using setDestination there is a desync between the agent movement and the actual gameObject movements

knotty sun
#

you dont need/want accuracy only reasonable

weary swift
knotty sun
#

no

weary swift
#

Ok

#

I will look into this then

#

My game is in co-op, this will not cause any problem ?

knotty sun
#

I think you need to sit down with a clean project and play with the NavMesh system untill you understand it

weary swift
#

I think I'm fine with it now

#

This was the only thing I didn't understand

knotty sun
#

I would still recommend implement this is a clean project so you can play with the settings without affecting your main project

weary swift
#

Ok thanks for the help !

#

Should I move with Kinematic Rigidbody and MovePosition ?

knotty sun
weary swift
#

What

#

I need to move it with something else than the agent if I want it to slow down ?

#

Oh I can just set the destination to be somewhere else

knotty sun
#

no you do not, you can control the agent speed

weary swift
#

Yes ok

#

Thanks

#

I understand

modern atlas
#

I’m working on a character editor and it works by generating a png file inside a folder. When I generate it inside of Resource folder, I can access it via the editor but not the built solution but when it’s in any other folder such as StreamingAssets, it doesn’t save as Texture2D rather as a default asset. Any advice?

leaden ice
#

You were hoping to rely on the editor's asset import pipeline which naturally does not exist in the built game.

modern atlas
#

Yeah I tried the persistent data method too but because it doesn’t save in a folder anywhere in the editor, I can’t access it

modern atlas
#

The method that equips a skin onto the character requires the png file to be in a file somewhere accessible within the editor

leaden ice
#

But sounds like something that can easily be worked around

#

regardless, your approach to loading images at runtime cannot involve the asset import pipeline, because it doesn't exist at runtime.

knotty sun
modern atlas
#

Because I looked for the generated image and couldn’t find it anywhere

eager yacht
knotty sun
leaden ice
reef garnet
#

Anyone non-sound designers here have any good resources/tutorials for integrating WWise for their team's sound designer?

reef garnet
#

my bad

arctic rock
#

I'm wondering what is considered best practice?

Option 1: Have all UI Panels(ex PauseUI ) part of the GameManager and just Enable/disable as needed .
or
Option 2: Save UI Panels as prefabs and load/unload on demand.

Keeping them in and disabling them seems like it would be quicker for the system to access, but means they are always in memory, where as loading/unloading saves memory it could eat up some CPU when swapping them out. Seems like its a matter of Memory Optimization vs CPU optimization. Which is considered best practice? if there is one?

edit: clarity/typos

knotty sun
#

tbh, there is usually nothing in UI which is performance critical, so memory is more important than cpu usage

arctic rock
#

thats a good point

#

I guess I'm worried loading/unloading UI's, when pausing could cause a bit of a delay... if I hit the pause button, I want it to pause NOW not in 3 seconds... but maybe were talking fractions of a second so maybe it's not an issue.

knotty sun
#

3 seconds is extreme, 3 milliseconds might be closer to the truth

arctic rock
#

yeah that's what I figured.. thanks for your input.

knotty sun
#

rule of thumb, any thing that takes < 200 ms is considered as instant by the human eye and brain

night storm
naive swallow
mental anvil
#

I followed a guide on procedural generation but the function doesn't change my mesh's verticies at all. Someone got a clue what is wrong? ``` private void UpdateMeshVertices(float[,] heightMap)
{
int tileDepth = heightMap.GetLength(0);
int tileWidth = heightMap.GetLength(1);

    Vector3[] meshVertices = this.meshFilter.mesh.vertices;

    int vertexIndex = 0;
    for (int zIndex = 0; zIndex < tileDepth; zIndex++)
    {
        for (int xIndex = 0; xIndex < tileWidth; xIndex++)
        {
            float height = heightMap[zIndex, xIndex];
            Vector3 vertex = meshVertices[vertexIndex];
            meshVertices[vertexIndex] = new Vector3(vertex.x, this.heightCurve.Evaluate(height) * this.heightMultiplier, vertex.z);
            vertexIndex++;
        }
    }
    this.meshFilter.mesh.vertices = meshVertices;
    this.meshFilter.mesh.RecalculateBounds();
    this.meshFilter.mesh.RecalculateNormals();

    this.meshCollider.sharedMesh = this.meshFilter.mesh;
}

}```

steady moat
night storm
steady moat
#

I just reread some of the article and it seem like with sound it is possible to feel a dissonance in some circumstance below 100ms. And, 100ms is really the hard floor, in practice 100-200ms is acceptable.

dense shale
#

should i use unity's c# style guide even though i prefer google's visually?

dense shale
#

because i'm guessing all of the UnityEngine stuff is written according to the unity style guide

leaden ice
#

not google

dense shale
#

I know they wrote it, the code just looks uglier to me

#

(specifically braces on a newline, it's just a waste of screenspace imo and detaches the if/while/whatever statement from the block)

steep herald
#

There used to be an API to write basic text onto the screen, I think you could also draw lines and it didn't require any components. It was before unity 4.6 GUI introduction.

I can't find the docs but I'm sure it's still around. Any idea?

leaden ice
leaden ice
dense shale
#

gotcha ty

leaden ice
steep herald
#

Okay, great. I'll take a look around

dense shale
#

should i declare a variable in <object>.Update()?
on one hand, it'll redeclare the variable every frame, which might have performance issues (not sure)
on the other, it's a better scope for it to be in

leaden ice
#

declare your variables in the smallest possible scope

#

"redeclare the variable every frame" is not a concern for performance

#

one of the very common mistakes beginners make is not using local variables enough.

dense shale
#

yeah, it makes more sense, just wondered if it affected performance

#

good to know, ty

leaden ice
#

It doesn't

#

But using unecessary heap memory by making unecessary member variables can

plush ridge
#

Can anyone explain why this script is also setting the "Deck" parent as the first sibling of it's parent (the game canvas)? It's causing my deck to dissapear.


    public void ShuffleDeck()
    {
        List<Transform> cardList = new List<Transform>(GetComponentsInChildren<Transform>());

        int n = cardList.Count;
        System.Random rng = new System.Random();

        while ( n > 0 )
        {
            n--;
            int k = rng.Next( n + 1 );
            Transform value = cardList[k];
            cardList[k] = cardList[n];
            cardList[n] = value;

            Transform siblingObject = cardList[n];
            siblingObject.SetAsFirstSibling();
        }


        Debug.Log( "Deck shuffled successfully." );
    }

leaden ice
plush ridge
leaden ice
#
  • Exclude it from the list with Linq
  • Build your own list using childCount/GetChild instead of GetComponentsInChildren
  • don't derive the list from the Transform hierarchy in the first place

Any of those

subtle spoke
leaden ice
#

p.s. - GetComponentsInChildren is also going to find the grandchildren too

leaden ice
#

it's just not a good idea here

leaden ice
#

so probably the second one

prisma seal
#

Sorry if I’m posting in the wrong channel. I watched Codeer’s video on how to make a procedural animation character. I need a bit of help with the second step of the video, which involves fixing the bottom of the leg to the ground. Any help is appreciated.

solemn ember
#

henlo people

#

so if I want to use an interface

#

I would have to make the function public?

leaden ice
#

You don't need the public keyword inside the interface itself, it is implied.

plush ridge
plush ridge
solemn ember
#

Idk if this is Unity but

#

you can just put new()

leaden ice
#

yes you can

solemn ember
#
List<Transform> cardList = new();

        foreach (Transform card in transform)
        {
            cardList.Add(card);
        }```
#

like this

#

and no need to put this.transform

plush ridge
solemn ember
#

"this" it's already implied

#

so you can just put "transform

plush ridge
#

yup that worked too. Thank you!

leaden ice
#

you can also do List<Transform> cardList = new(transform.childCount); to ensure the list has the right capacity

#

this may be slightly more efficient

solemn ember
#

based

solemn ember
leaden ice
#

likewise an array could be used, but now we're just going crazy

solemn ember
#

usually public functions are open to be hacked, no?

leaden ice
#

public functions have nothing to do with hacking

#

C# access modifiers are not protections against hacking

solemn ember
#

no?

leaden ice
#

they are only there to help you write good code

plush ridge
leaden ice
#

they don't exist at runtime at all, only in the compiler.

solemn ember
#

I thought public functions could cause issues, easier to be accessed

solemn ember
#

interesting

#

XDDDDDD

leaden ice
plush ridge
solemn ember
#

c: good luck with that Inmortal

#

anyways, is this how I should make the interfaces?

#

a separate script and put them all there

plush ridge
leaden ice
#

Just make IBreakable.cs and put the interface in it

#

get rid of the rest

solemn ember
#

πŸ‘πŸΌ

leaden ice
#

I personally would rename the file too but the filename is completely up to you.

solemn ember
leaden ice
#

Unlike MonoBehaviour classes, there is no requirement for the filename to match the class name here

solemn ember
#

^ yup, I was tihnking GameplayInterfaces

#

was a good name

#

what would you suggest?

leaden ice
#

IDK, are you planning to put more in this file?

solemn ember
#

yes

simple egret
#

Outside of Unity, the convention is one type per file.
So here you'd have one IInteractable.cs containing just interface IInteractable, and one IBreakable.cs containing just interface IBreakable.

solemn ember
#

ah

#

doesn't Unity takes longer to compile, the more scripts you have?

simple egret
#

It surely has to read more files, but it's negligible compared to spinning up the compiler process and feeding it all in

cold parrot
simple egret
#

I've seen some name them Foo`1.cs, as it would be displayed in ToStrings

cold parrot
eager yacht
#

Personally I much prefer many types to a single file, as I hate dealing with file navigation LUL Plus I just like having types in context to other things around it, such as a bunch of ecs components.

cold parrot
solemn ember
#

ah

#

this is not really coding, not sure where I should put it but

#

how do I add this package to Unity?

#

it only searches for package.json

leaden ice
solemn ember
#

nice, thanks!

mental anvil
#

I followed a guide on procedural generation and for some reason the heightmap wont affect the verticies on my plane. Someone knows what I did wrong?

simple egret
rigid island
#

notice its also grayed out color on function (darker yellow)

#

and 3 dots telling you method is unused

knotty sun
minor stream
#

how would you check if an enemy is Infront of you

leaden ice
#

and what's your definition of "in front of"

minor stream
#

an enemy i have refrenced

#

like the player is facing the enemy

leaden ice
#

sure but like

#

if the enemy is 1000 yards away and behind a wall, are they still "in front of" the player?

rigid island
#

like Vision cone?
I combine DotProduct with Raycast

leaden ice
#

or are we talking about a small area directly in front of the player

minor stream
#

that

#

like if player is facing enemy and distance <= 4

leaden ice
#

If you want a vision cone with a limited range you can start with Physics.OverlapSphere with radius x, and then do a bool withinCone = Vector3.Angle(transform.forward, directionTowardsEnemy) < angleThreshold; to narrow it down

minor stream
#

ok ill try that

rough tartan
#

hello I made this code to know if a bool of my animator is true or false, how can I do to know if a trigger is active or no ?

public int IsHigh()
    {
        return Fps_animator.GetBool("IsHigh") ? 1 : 0;
    }
leaden ice
#

anyway what's the use case here?

#

Why do you need to read bools and triggers back from your animator? What's wrong with a normal variable?

rough tartan
leaden ice
#

wouldn't a typical network framework have some capacity for animation syncing?

rough tartan
leaden ice
#

which network framework are you using

rough tartan
rigid island
#

using websockets sound like a nightmare here

leaden ice
#

that's not a game networking framework that's a websockets implementation

rough tartan
rough tartan
rigid island
#

it was literally built for the job

rough tartan
rough tartan
rough tartan
rigid island
#

this will return true if its playing the clip by name, aka a state

#

typically you place it in Update if you want a bool to update realtime

#

eg
Jumping = m_Animator.GetCurrentAnimatorStateInfo(0).IsName("Jump")

spring creek
rough tartan
rough tartan
storm wolf
#

Is there a way to lock the cursor in the same spot without hiding it?

ik about Cursor.lockState = CursorLockMode.Locked That is not the functionality I want however:

essentially on the drag i want to rotate a model around based on the mouse inputs (which is already working) but the mouse will still move around I want it to be visible but not move around. Everything I am finding online is just locking and hiding it which also puts it in the center of the screen. How can I accomplish this?

rough tartan
storm wolf
rigid island
rough tartan
spare island
#

you'll have to port it manually to each platform you want though

#

alternatively you could have a virtual cursor

#

(hardware cursor is invisible, but you have a controllable in-application cursor)

storm wolf
#

yikes

#

i was honestly avoiding installing the new input system 😭 guess I'll have to for this

spare island
storm wolf
#

No, I have used it before, theres just no need for it in my current project

spare island
#

i thought the new input system comes with unity now

storm wolf
#

i dont think so I tried importing it

spring creek
rigid island
#

just switch it to a fake cursor when you are rotating

spring creek
#

It is just an input system. It should just be standard

rigid island
#

its locked anyway, lag will be unfelt

leaden ice
#

probably the default in Unity 6 I think

storm wolf
#

which is what im multiplying to rotate the model

spare island
#

make it invisible and confine it to the window

#

show a stand-in cursor to represent it

rigid island
storm wolf
#

alright Ill try that

storm wolf
rigid island
#

all my FPS is locked in middle I can use GetAxis just fine

storm wolf
#

ah i lied actually

#

the problem is that i only want the rotation to happen when hovering over the raw image, when its locked in the center it will no longer rotate

spare island
rigid island
storm wolf
#

yes that is accurate

spare island
#

something about this seems paradoxical

storm wolf
#

how so

spare island
#

im not really understanding your goal i guess

#

you want to rotate something while hovering but lock it to what exactly?

rigid island
#

lock the cursor to be on the image I suppose

spare island
#

but if its locked how will you stop hovering over it

storm wolf
#

yes like I don't want the cursor to be moving around while rotating the model around

rigid island
#

cause locking snaps it to the middle iirc

spare island
#

like holding down a button?

#

because otherwise i don't see how you would stop rotating

storm wolf
#

yes dragging

spare island
#

oh okay

storm wolf
#

I can send the script if it helps

rigid island
#

it is a bit of a pardaox problem with hardware cursor

#

if you dont lock the cursor while you rotate it moves away too

#

either way the cursor will move away , you could use a bool but when your done rotating your mouse is somewhere else

spare island
#

I'm thinking of a solution like:

when click on rotateable object:
  swap to virtual cursor
  hide and confine hardware cursor to window
  while holding drag button:
    use mouse delta to rotate
  show and unconfine hardware cursor
storm wolf
#

is there a way to confine the cursor to just the image bounds

spare island
#

not built-in no

rigid island
#

each OS handles cursor different

storm wolf
#

thats not the functionality I want anyways but its a pseudo solution

rigid island
#

iirc new input system lets you snap cursor to specific point

#

could be used after swapping from faux cursor

spare island
#

'WarpCursorPosition'

#
 Mouse.current.WarpCursorPosition(new Vector2(123, 234));
rigid island
#

ah yes there it is

storm wolf
#

yeah that was my initial thought lol

spare island
#

this should handle each desktop platform

storm wolf
#

again didnt want to use new input system but I will try using that

spare island
#

i would get used to using the new one, i dont think there's really a good reason to use the old one anymore besides compatibility

rigid island
#

the new input system is not that much different than old input system

#

you can still use it with polling as you're used to

#

although events are better ofc

spare island
#

i still do polling sometimes because im lazy 🫠

rigid island
#

Keyboard.current.qKey.wasPressedThisFrame for example

#

thats same as GetKeyDown

storm wolf
#

this project I started a while ago so I am just trying to finish it and push it out its already mostly done and uses the old so call it sunk cost if you want but I don't feel like switching it 😭

rigid island
#

with Get Axis though you do need to just read v2 of mouse

rigid island
#

set the Player Settings to use Both input systems

storm wolf
#

I just did lol

spare island
#

isnt osu open source?

#

you should be able to reverse engineer exactly how mania detects hits

#

plus: it seems the codebase is mostly C#

#

oh sorry, ENTIRELY C#

gleaming falcon
#

this is for the experimental rewrite of osu iirc, it still might help though ty

rough tartan
#

what's the maximum lenght for for an Index because It seams that this is too long :

int Index8 = queuedMessage.IndexOf('IsWalking');

and also, does having longer Index really slow the process ?

somber nacelle
#

using ' around letters is for a char, which is just a single character, but you have wrapped 9 letters in it

lean sail
#

i find it odd you need to parse anything like this though

young tapir
#

I don't see why " wouldn't be used in its place

spring creek
#

A char is a primitive, so use it over string when you can

young tapir
#

Well yeah

#

Oh it's more performant? That makes sense

somber nacelle
rough tartan
#

that because I making a multi player game with a websocketsharp server , and other player information arrives in this format :

(63ecf009b7a74979bdc8582aac0ab8f9)GID123X-1,037964Y1,296136Z3,7!89,9RIsAiming0IsWalking0IsRunning0IsHigh0IsShooting0IsReloading0$#

So I need to exctract all important information in the message

spring creek
young tapir
#

Fair enough lol

somber nacelle
rough tartan
somber nacelle
#

that is objectively the "hard" way

#

it looks like your data is pretty simple so you could literally just use JsonUtility which is built into unity for serialization

rough tartan
# somber nacelle that is objectively the "hard" way

I know, but it's one more thing to learn and also I don't have anyone to really guide me and explain to me how to do it right so I do things the way they seem to work, not the way they should be. Honestly, if I'd known it was possible I'd probably have done it that way, but now that I've done everything with my method, I don't think I'll change for the time being, since it's working pretty well.

rough tartan
somber nacelle
#

only way to tell is by profiling it. but it will mean you don't have to do some crazy manual string parsing that will be more prone to error if you don't cover all possible edge cases

rough tartan
somber nacelle
#

and i spend to much time doing this way
sunk cost fallacy. it is almost always better to learn to do things right even if you already have something that "works"

cold parrot
#

my rule of thumb: if its not done in 2 weeks (in some rough form), its not gonna be done in 2 years either.

rough tartan
#

I'd still go and see if changing the method would be possible without modifying my server and client too much

cold parrot
rough tartan
#

Now I have something that work, it's not finished but it work

somber nacelle
devout nimbus
#

If someone is free to allow me to screenshare to show this issue that would be great just lmk. I dont think there is a way to show enough code or inspector screenshots to really show my point

somber nacelle
#

it is incredibly unlikely that anyone would be willing to help you privately like that. just describe your issue using the guidelines in #854851968446365696 as best you can and if someone wants to help then they will do so here

tawny elkBOT
devout nimbus
#

Sounds good

rough tartan
lean sail
rough tartan
lean sail
devout nimbus
#

https://pastebin.com/QrnYY3UL

This system of mine adds an item into an inventory system. It works perfectly fine in almost every scenario except this one where I add an item to a system before I spawn in the ui slots using createlootslots()

It has the itemdata in the slot correctly as well as the correct tooltip. No null references. The image component that is refereced is the only thing failing to update. During runtime in the game I can even have the player grab the item and move it to his inventory where the image properly displays again.

The images with the axe shows its tool tip and the slot ui, this is how it proerply looks. the other images with the feather are all fine as well except the image component fails to change and just says none.

#
public void UpdateUISlot(InventorySlot slot) {
        // Debug.Log("Updating ui slot");;
        OnSlotUpdated?.Invoke(requiredItemType);
        if (slot.itemdata != null) {
            // Debug.Log("image null: " + (slot.itemdata.image == null));
            image.sprite = slot.itemdata.image;
            image.color = Color.white;
            // Debug.Log($"Trying to update slot for {slot.itemdata.name}");
            toolTipTrigger.SetText(slot.itemdata.name, slot.itemdata.description);
        } else {``` This is the part that mostly trips me up as it correctly changes the tooltip and the sprite and the itemdata is correct as well. the image is not null if i remove the log statement. This works perfectly fine in most other scenarios too
solemn ember
wide terrace
# devout nimbus https://pastebin.com/QrnYY3UL This system of mine adds an item into an inventor...

It would be useful to see more of whatever scripts are the principal of the paste you've shared, ideally with each file as a separate paste and using a website like https://gdl.space - pastebin is sort of bloated and ad-riddled.

Readers can probably sort out the file divisions and derive the types of the fields and such by staring long enough, but that extra effort often drives would-be answerers away

young tapir
#

I'm trying to link a script in unity to an external DLL with an asmdef and it just won't connect no matter how I set it up, keeps giving me this error whenever the script is enabled

The referenced script (Unknown) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object 'Armour Module') is missing!
The referenced script on this Behaviour (Game Object '<null>') is missing!
The referenced script (DW.ArmourModule) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object 'Armour Module') is missing!```
The class names and namespace all match and it should work, has anyone got any ideas?
#

I can provide screenshots of whatever's needed, just don't want to flood the chat

cosmic rain
young tapir
#

I have a stub in unity with just 5 empty functions and a coroutine, all the code is in the DLL

cosmic rain
# young tapir It is

Is the dll configured properly? And referenced if you're using assembly definitions?

young tapir
#

Unity vs the DLL. It's worked before in the past but just won't link

#

This DLL hasn't worked* Other projects

young tapir
#

And no, it's not referenced via the asmdef, I'm only referencing two DLLs in there

#

The game loads all the DLLs so it's not needed if I'm not referencing stuff in unity (hence the stub)

cosmic rain
#

I don't think stubs are a thing in C#?πŸ€”
If you have 2 classes with the same name in the same namespace, they would just conflict and cause a compile error.

#

The errors you were getting indicate that the reference/guid in the GameObject metadata was pointing to a script/class that doesn't exist anymore.

gloomy helm
#

how could i rotate feet like this procedurally using ik when they are to far behind the player

young tapir
cosmic rain
jade vault
potent anchor
#

Hiya - There's some stuff I want to execute in Start() when the scene is being loaded but I don't want it executed when the same object is being instantiated programatically after the scene has loaded. Is there a good way to check why Start is being called withour using reflection to look at the call stack or something weird

leaden ice
potent anchor
#

I had considered that, but was hoping for a self-contained way so my sceneManager didn't need to know about these types of objects.

leaden ice
#

e.g.

pubic class BootStrapper : MonoBehaviour {
  foreach (MyScript ms in FindObjectsOfType<MyScript>()) {
    ms.Initialize();
  }
}```
potent anchor
#

But if that's "approved", then I'll do it that way πŸ™‚

leaden ice
#

not sure what "approved" means

potent anchor
#

I didn't want BootStrapper to know about all of the different types like MyScript.

potent anchor
#

I preferred to just handle it all in MyScript without creating another dependecny

#

yah - that feels better

#

with the interface

#

I'll go that route. Thanks!

calm talon
#
int i = 0;
for (i = 0; i < PlayerInputs.PlayerControls.Length; i++)
{
  optionsButtons[i].transform.parent.GetComponent<Button>().onClick.AddListener(() => ChangePlayerControls(i));
}

I'm trying to add a listener to a set of buttons using some code to automate the process, however onClick.AddListener() always fails

#
public void ChangePlayerControls(int keyToChange)
{
    optionsButtons[Array.IndexOf(PlayerInputs.PlayerControls, keyToChange)].text = "Awaiting Input";
    StartCoroutine(ReadInput((PlayerControlMap)keyToChange));
}

here is the called function for reference

leaden ice
calm talon
#
for (int i = 0; i < PlayerInputs.PlayerControls.Length; i++)
{
    int x = i;
    optionsButtons[x].transform.parent.GetComponent<Button>().onClick.AddListener(() => ChangePlayerControls(x));
}

Still fails to add the listener to the button

somber nacelle
#

what do you mean it fails to add the listener

calm talon
#

the onClick list is empty

#

If it is important, the buttons are disabled when I add listeners to them

somber nacelle
#

well yes, you won't see listeners added via the AddListener method in the inspector, the inspector only shows persistent listeners (which you wouldn't be adding at runtime)

#

have you actually done anything to confirm whether this code is working? or are you just using the inspector and making assumptions?

calm talon
#

okay nvm it does

calm talon
#

good to know

young tapir
#

If I modify the emission of a material by lerping the values instead of the material on a renderer, will it change session wide?

#

Like how It's working in the scene now, instead of just changing one

cosmic rain
golden wave
#

can an event return a value?

rigid island
spring creek
versed aspen
#

Where can I find material about the latest version of ECS? ( Other than Docs)

haughty sonnet
#

why does this happen when changing the value of the base color through script? if i nudge the colour afterward it properly updates and removes this weird glow (the base color is not actually white either, as seen if i open the base map color changer window)

analog iron
#

Hi good day ya'll i just wanna ask is it possible to make a custom serializable class that be checked if its null? like example a weapon class which is under a character class(both serializable) to check if player has weapon or null?
Cause what happens is that weapon class under character class seems to be already instantiated.

wide terrace
somber nacelle
analog iron
somber nacelle
#

the inspector cannot display a null value. so yes, you'll need to write a custom editor to handle null if you want it to be null in the inspector

haughty sonnet
analog iron
wide terrace
haughty sonnet
#

i guess that's why it's a float instead of an int lol

#

originally had HEX codes but converted them to RGB

#

new Color(22, 93, 200) << one of the colours i use

knotty sun
haughty sonnet
somber nacelle
#

it's like you didn't even read the page i linked

haughty sonnet
#

thank you

#

yea that about fixed it, thank you y'all πŸ™ dont really work with colours too often

wide terrace
#

On a corollary, why doesn't Color complain about out of range arguments, anyway? πŸ€”

Is it a valid use if you are aware of repercussions (despite being undocumented)? Or maybe it is considered too trivial to waste a runtime check on?

somber nacelle
#

yeah HDR colors are supported and those go out of that 0->1 range

wide terrace
#

Ahh alright, that makes sense πŸ‘

analog iron
somber nacelle
#

yes, because the inspector cannot display null as i've already said

analog iron
somber nacelle
#

you could just not serialize that field. or if it must be serialized and you want a simple way to ensure it is valid, give it a bool property that must be true when it has been assigned a valid instance

wild vigil
#

is there an efficent way to know when an LOD change occurs?

cold parrot
wild vigil
#

very limited memory

cold parrot
wild vigil
young tapir
#

If I call a static function on a MonoBehavior, will It update every instance of that component or just one?

#

If not, is there a way to update every instance of a MonoBehavior from one main, and seperate script?

#

Googles results were.. Confusing to say the least 😦

knotty sun
#

A static method does not have access to instance variables

grizzled ibex
young tapir
#

Oh good idea actually..

#

Yeah I see no reason why that wouldn't work for my use case πŸ˜„
Thanks!

leaden ice
#

A static function has nothing to do with any instances

prisma seal
#

Hey, I'm having an issue with my 3D character rig in Unity. I've tried to fix it, but the problem persists. It gets into a weird pose whenever I go into play mode. (IΒ΄m using Animation rigging for the ik solution)

prisma seal
tacit vine
#

does your company has a extended monobehaviour and is it worth it?

leaden ice
#

extending MonoBehaviour is the way to make scripts.

tacit vine
#

yeah i dont mean it like that some company's has a monobehaviour like (company)MonoBehaviour : MonoBehaviour\

#

so it extends monobehaviour and you can set a function like reset a transform in it

trim schooner
#

It's worth it ... if it makes sense for you to do it Β―_(ツ)_/Β―

leaden ice
tacit vine
#

but i was intressted if someone had a personal experience with it

little meadow
#

I've never needed it πŸ€·β€β™‚οΈ I've seen some people do it and their use-cases didn't seem all bad at the time (some 2 years ago), but I don't remember what exactly those were

#

I'd say - don't extend unless you have an actual use for that... you can always refactor it later on, if really necessary πŸ€·β€β™‚οΈ

light pond
#

so i have another script for player rotating but the problem is that because in the editor i have made the XRotateTo and the YRotateTo 0

#

its not turning

leaden ice
light pond
leaden ice
light pond
#

i made it one

leaden ice
#

sahow me

#

how you did that

light pond
#

ok i will send a video of without dotween vs with

#

the problem is that dotween only works in the start so it doesnt care what else happens

leaden ice
#

what are we comparing to?

#

Whjat does the other code do?

#

yes, you only wrote the dotween thing in Start, so it will only happen once there

light pond
leaden ice
#

in what circumstance

#

how do you suppose your DOTween code would or should do that?

light pond
leaden ice
#

the DOTween code you shared makes no attempt to handle input

barren stag
#

Hello, would anyone happen to know the method for realistic 2D rope swing physics? What I currently have is the player attachment to the rope, but I cannot seem to get the physics right. For now, it applies an impulse in the direction we're pointing (just once, when we change direction, e.g if the last direction was left and we press right it applies a force towards the right) but the physics aren't right at all. I'd like something realistic, where we have to swing multiple times left and right to accumulate velocity. How would I do that correctly? Already looked up on youtube, but the only good swinging physics didn't explain how they did it.

leaden ice
#

if you make it a small force the player will have to swing back and forth to build up momentum

barren stag
#

that's what I had way before, but since the force is continuous the rope doens't fall back after reaching the current max allowed by the current energy

leaden ice
#

it needs to be too weak to overcome gravity on its own

barren stag
#

yeah that's true

#

I think also one error I made was to apply the force only to the right, when it should also be slightly up, right?

leaden ice
barren stag
#

I'll try that

#

thanks

swift falcon
#

I'm wondering if anyone can help me make a certain area foggy/dark? instead of the whole map

swift falcon
leaden ice
#

something like this

swift falcon
leaden ice
#

that depends on which render pipeline you're using

#

basically you should google:
Unity HDRP Volumetric Fog
or
Unity URP Volumetric Fog
or
Unity Built In Volumetric Fog

depending on which pipeline you're using

swift falcon
#

alright

fallow obsidian
#

I'm trying to make a system where you can play a video and once youve watched the video, you get resurrected.
The issue im facing is that the first 2 seconds of video have distorted audio. The original file doesnt have this distortion and i think it's most likely since it's loading the video from a url.
Is there a way in Unity's VideoPlayer to wait until the first few frames of the video are ready to be played?
I think this would fix my initial distorted audio.
Here's the code i've tried and frameReady doesnt work for urls i think.... unless maybe i need to Play and pause it first to start the loading process and then wait for frameReady to resume playing.

simple egret
#

(the two pairs of lambdas are compiled to different methods - the -= operator will see them as different)

swift falcon
#

Guys, give me docs and stuff i will need, to integrate and make a 3RD Perspective player 3d movement, i have made good progress in my game, i wanna learn how to integrate camera and player rotation wiht mouse, and how to make Rigid Body add force code integrated with player's position, view and mouse movement

tawny elkBOT
swift falcon
rigid island
swift falcon
#

I tried this

#

cine machine cant be integrated wiht physics, rigidbody

#

only character movement, or character controller

rigid island
#

what

swift falcon
#

i forgot

#

Like When i turn, or rotate my camera

#

and press W (front key)

#

it will go front on litreral X-Axis

rigid island
#

what does that have to do with Cinemachine ?

swift falcon
#

rather than front as in where player is looking

rigid island
#

or physics

swift falcon
#

for Rgid body

#

i have to do

#

Addforce (axis_

rigid island
#

it has nothing to do with rigidbody

hidden compass
swift falcon
rigid island
#

you picked the wrong direction

swift falcon
#

For movement of character

#

i use addForce

#

from rigid body

rigid island
#

or your character controller has the wrong orientation

hidden compass
#

this may be useful.. idk for sure

swift falcon
#

No wait

#

how can i make it so

#

that Rigid Body

#

add force

hidden compass
#

please type in full sentences

swift falcon
#

to the direct

#

direction of camera

#

or player

rigid island
#

make a full sentence please before you hit enter

knotty sun
#

ffs type in full sentences @swift falcon

hidden compass
#

πŸ›‘ stop bro

#

im not reading any of that 1 word stuff so please retype ur question

swift falcon
#

how can i make it so that Rigid Body adds force to the direction of camera or player rather then specific Vector3 axis

hidden compass
#

use Camera.forward

swift falcon
#

wdym

hidden compass
#

Camera.transform.forward

somber nacelle
#

AddRelativeForce

hidden compass
#

or taht ^

swift falcon
rigid island
#

dude its a direction

hidden compass
#

yes.. u still use RB.ADDFORCE

swift falcon
hidden compass
#

ur just giving it a different direction

#

(from tha cameras perspective)_

swift falcon
#

😭

rigid island
#

direction relative to the camera's forward (blue arrow)

swift falcon
#

This is too much to absorb at once

hidden compass
#

well slow down

rigid island
#

yes because you need to start from the beginning courses

#

!learn

tawny elkBOT
#

:teacher: Unity Learn β†—

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

swift falcon
#

I did

#

But like

#

I never learned

#

abotu mouse

#

movement

rigid island
#

well do it until you understand each differnce

swift falcon
#

and cinnemachine

rigid island
#

also stop typing like that

swift falcon
#

mb gang, its a habit

hidden compass
#

ur going to get warned if u continue..

rigid island
swift falcon
#

Wait

#

I have to find relative force docs

#

and cinnemachine docs

hidden compass
#

all u need to do is change AddForce to AddRelativeForce

#

simple as that

swift falcon
#

in a nutshell what does relative force do

hidden compass
#

yes a nutshell πŸ₯œ

#

its local forces

swift falcon
knotty sun
hidden compass
#

Vector3.forward would mean the local forward axis of the object

#

instead of the worlds forward

swift falcon
swift falcon
rigid island
hidden compass
#

if u use AddRelativeForce(Vector3.foward); its going to use the forward axis of the object w/ the rigidbody

rigid island
swift falcon
#

Got it

#

Now i understand

#

thank you, ill try using this

rigid island
#

doing a character rigidbody is a pain