#archived-code-general

1 messages · Page 225 of 1

sonic trench
#

uhh please tell me how..

#

I'm sorry if I'm annoying

fervent furnace
#

here

sonic trench
#

oh alr thanks

#

still doesn't work

fervent furnace
#

yes, then loop through the string and check the char one by one

sonic trench
#

uhh.... you know what I'm gonna ask...

#

here is the scirpt:

using System.Collections;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;

public class Test : MonoBehaviour
{
    public TMPro.TMP_InputField inputField;
    public string desiredString = "1";
    public GameObject correctObject;
    public GameObject incorrectObject;

    private void Start()
    {
        if (correctObject != null)
        {
            correctObject.SetActive(false);
        }

        if (incorrectObject != null)
        {
            incorrectObject.SetActive(false);
        }
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
        {
            CheckAndShowObjects();
        }
    }

    void CheckAndShowObjects()
    {

        Debug.Log(inputField);
        if (inputField != null && !string.IsNullOrEmpty(inputField.text))
        {
            if (inputField.text.Equals(desiredString))
            {
                StartCoroutine(ActivateAndDeactivateWithDelay(correctObject));
                Debug.Log("Correct!");
            }
            else 
            {
                StartCoroutine(ActivateAndDeactivateWithDelay(incorrectObject));
                Debug.Log("Incorrect!");
            }

        }
    }

    IEnumerator ActivateAndDeactivateWithDelay(GameObject targetObject)
    {
        if (targetObject != null)
        {
            targetObject.SetActive(true);
            yield return new WaitForSeconds(2.5f);
            targetObject.SetActive(false);
        }
    }
}
fervent furnace
#

yes, loop the text and check the string

sonic trench
#

hoow

#

:(

fervent furnace
sonic trench
#

I just made my own version

#

kind of

#

and it worksPepeHappy

#

thanks for telling me to put it in a loop and told me to make a TMP input field

pine blade
#

hi i've got a simple coroutine that moves the player over a duration, but since its physics based, I'm having some trouble getting it working the same at different frame rates (which I only noticed since I recently lowered the interval between time steps for more consistent physics [from 0.02 to 0.005]). Everything else in the game i've simply multiplied by time.unscaleddeltatime so I'm clearly misunderstanding how waitforfixedupdate or time steps in general work. Any help would be appreciated

mellow sigil
#

Impulse mode is the wrong mode to use. That's only for single force events, continuous forces should use Force or Acceleration

pine blade
mellow sigil
#

it might

#

actually probably does because Impulse specifically ignores fixedDeltaTime

vivid heart
#

Guys, I am a beginner in Unity, and I would like to know if it's okay to use this architecture in my game about a pharmacist simulator.I have been working for a day and I don't know if I have indeed started correctly?

pine blade
hasty wave
#

how should I keep an object across scenes? or should I just make my camera a prefab?

fervent furnace
#
Unity Learn

In this tutorial, you’ll learn how to use data persistence to preserve information across different scenes by taking a color that the user selects in the Menu scene and applying it to the transporter units in the Main scene. By the end of this tutorial, you will be able to: Ensure data is preserved throughout an application session by using the ...

lean sail
# vivid heart Guys, I am a beginner in Unity, and I would like to know if it's okay to use thi...

this question is not possible to answer based on a screenshot of your file organization alone. the location of your files have literally no effect (excluding stuff like Resources). As long as they are easily accessible and not a pain to search through, then your file organization is fine.
It matters more what you are doing code wise to say if your architecture is fine or if you've started "correctly". Although based on the final names alone, I will say this gives me feelings of a web dev based background. You may end up overengineering trying to apply some other development techniques into game development.

vivid heart
lean sail
vivid heart
# lean sail there isnt really that much to say, as i dont know what most of your code is doi...

In the future, I would like to further develop my game by adding different scenes and unique logic. I believe that using DI will improve performance because I handle the references myself, as well as other aspects. I want the logic to be able to increase in volume in the future but involve less time for creation.
And since performance is always welcome in Unity, I think it would be okay to use it.However, I'm not just talking for the sake of it. Your opinion is a key point, because alone you can't know for sure if you're doing something right or not.

lean sail
# vivid heart In the future, I would like to further develop my game by adding different scene...

As far as i know, DI will do absolutely nothing performance wise and has no affect on what the user sees while playing the game. If you want to use that, thats entirely fine and dont let me stop you. First just to inform you, the profiler is the tool you'll want to use if you ever have performance concerns.
For example, DI wont do anything if your problem is that it takes awhile for the user to load scenes (due to creating a lot of objects). These objects still need to be created, and most of them probably arent suffering from doing a ton of GetComponent calls.

since performance is always welcome in Unity
This is somewhat true, id say you should just start developing without really worrying about this. Obviously dont intentionally write slow code, but theres no need to go out of your way to write super performant code in every step. You can do a lot before you notice any performance issues at all. These performance issues are more likely gonna be from 1 area anyways (like wanting to run 100s of enemies with complex logic).

#

For DI (and just a lot of areas in CS), people LOVE to toss around words like "decouple" "scalable" "modular" etc etc. Sometimes these really dont mean anything. Especially if theres no proof provided like benchmarks or examples of how their system saves you from doing work. Sometimes you end up writing more code to get something working just so that it can be "modular" but in reality it has no other uses. At the end of the day, you could make every system in your game "decoupled/scalable/modular" but if its not used then whats the point

lean sail
hasty wave
#

uhm what do you guys do keep player data between scenes?

fervent furnace
#

i have posted a link for you

jaunty light
#

Can I ask questions here?

main shuttle
hasty wave
jaunty light
#

Sure okay
So I was watching this tutorial yesterday on a simple chase AI https://www.youtube.com/watch?v=ieyHlYp5SLQ
But the navigation AI has functionality has since been moved to a plug-in (which I installed)

In the video he baked the floor on which the enemy has to walk. That bake option appears to be removed (supposedly the source of my error)
The error I am facing is:

"FunctionName" can only be called on an active agent that has been placed on a NavMesh

I think this is caused because my ground is not flagged as a NavMesh, how do I do so?

There is a legacy option which I have yet to check out, but I propose there should be a more elegant solution in the updated AI navigation.

main shuttle
jaunty light
#

NavMeshSurface I believe?

#

Let me try that out, thx 🙂

main shuttle
#

Yeah that one, was looking for it for you

#

I think following that manual will result in something working in the new system. Kind of annoying that it changes constantly UnityChanLOL

jaunty light
#

It's good that they keep updating their stuff, will make stuff better in the long run

(unity UI though 👀 )

#

Works like a charm! You're a legend @main shuttle
Thank you so much

main shuttle
main shuttle
jaunty light
#

Noted, I will have to look into NavMeshObstacle cause in the tutorial he did it manually. The solution now seems much more elegant

waxen kayak
#

Guys I need help with a memory leak. Unity crashes less than a seconda fter I start the game, there is a single line causing it

and this is it's context:

        public void Add(gridObj soldier, bool doit = false)
        {
            if (!init)
            {
                return;
            }
            if (soldier == null)
            {
                Debug.Log("tryingto add null");
            }
            //Determine which grid cell the soldier is in
            Vector2 cellPos = gridIndexAtPosition(soldier.soldierTrans.position);
            int cellX = (int)cellPos.x;
            int cellZ = (int)cellPos.y;

            //Add the soldier to the front of the list for the cell it's in
            if(cellX > size || cellZ > size)
            {
                Debug.LogWarning("Object is out of the bounds of the grid partioning system, at position (" + soldier.soldierTrans.position.x + ", " + soldier.soldierTrans.position.y + ")", soldier.soldierTrans);
                return;
            }
            //Add the soldier to the front of the list for the cell it's in
            soldier.previousSoldier = null;
            soldier.nextSoldier = cells[cellX, cellZ]; //WHY DOESN'T THIS WORK??
            //Associate this cell with this soldier
            cells[cellX, cellZ] = soldier;
            if (soldier.nextSoldier != null)
            {
                //Set this soldier to be the previous soldier of the next soldier of this soldier (linked lists ftw)
                soldier.nextSoldier.previousSoldier = soldier;
            }
        }

I need some help because I have no idea why setting a simple class does that. I can show more details, just ask

fervent furnace
#

what is [,] operator in your implementation or it is just an regular 2D array

waxen kayak
#

regulard 2d array of these objects:

    [System.Serializable]
    public class gridObj// : NetworkBehaviour
    {
        public FishNet.Object.NetworkObject soldierMeshRenderer;
        //To move the soldier
        public Transform soldierTrans;
        public gridObj previousSoldier;
        public gridObj nextSoldier;

        //The enemy doesnt need any outside information
        public virtual void Move()
        { }

        //The friendly has to move which soldier is the closest
        public virtual void Move(gridObj stuff,Vector3 oldpos, Vector3 newpos)
        { }
    }
#

another piece of information, I use this to add thins to a grid, it works when I initialize

#

now I'm calling it from another void, which is resposible for checking if the object has changed grid

#

and there it doesn't work

#

AKA crashes

fervent furnace
#

have you read the log btw

waxen kayak
#

what log are you talking about

fervent furnace
#

!log

main shuttle
#

!logs

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

fervent furnace
#

oh, the crash reported will generate logs when editor crash

waxen kayak
#

I tried but it didn't say anything

#

also the profiler doesn't show an increase at all before crashing

#

which is weird

main shuttle
#

What does cells contain? Are those the gridObj's?

waxen kayak
fervent furnace
#

something like this

#

(it crashs because write violation)

waxen kayak
#

my player log is empty??

#

editor isn't

#

I'll crash it and see what it says

fervent furnace
#

no logs under AppData\Local\Temp\Unity\Editor\Crashes?

waxen kayak
#

newest one is several months old

#

is it because I forcibly shut it down?

fervent furnace
#

when the editor crash a crash reporter will pop up

main shuttle
#

Okay, smells to me that its some kind of deep copy/shallow copy shenanigans going on, and that it doesn't clean up.
And that's above my pay grade. UnityChanLOL
As far as I know: soldier.nextSoldier = cells[cellX, cellZ]; creates a new shallow copy object for soldier.nextSoldier instead of creating a reference to the object that is in cells. Same with cells[cellX, cellZ] = soldier;, as far as I know, if you = reference types it creates a copy instead of assigning the existing object.

waxen kayak
#

How could I solve that?

#

My pc completely froze btw, so I guess it did not crash

fervent furnace
#

it is class so just assignint the pointer, should not crash

#

freeze is not crash

waxen kayak
#

Yeah I guess

#

Well it's still suboptimal

fervent furnace
#

oh i understand what you are trying to do
it is a double linked list

main shuttle
#

I don't know to be honest. I know reference type = is a common point of failure. Perhaps with a ref you can tell it to reference the existing one. Anyhow, I should really leave this to someone more knowledgeable, but I think the problem lies there.

fervent furnace
#

do you have code that iterate the list

waxen kayak
#

You mean gets all of the linked ones, yes

fervent furnace
#

a safer way is create a struct like this:

public struct Head{
  int length;
  Class instance;
}
```each time when you insert something at head then length++, remove something=>length--
the linked list has a cycle in it so dead loop
waxen kayak
#

wait I'll show where it's calling from when it crashes

#

maybe that's it

fervent furnace
#

btw is the editor crash (suddenly get shut down and pop up a crash reporter) or just freeze (no response to any input)

waxen kayak
#
      public void Move(gridObj obj, Vector3 oldPos,Vector3 newPos)
        {
            //See which cell it was in 
            Vector2 oldcellpos = gridIndexAtPosition(oldPos);
            int oldCellX = (int)oldcellpos.x;
            int oldCellZ = (int)oldcellpos.y;
            //See which cell it is in now
            Vector2 cellpos = gridIndexAtPosition(newPos);
            int cellX = (int)cellpos.x;
            int cellZ = (int)cellpos.y;
            //If it didn't change cell, we are done
            if (oldCellX == cellX && oldCellZ == cellZ)
            {
                return;
            }
            //Unlink it from the list of its old cell
            if (obj.previousSoldier != null)
            {
                obj.previousSoldier.nextSoldier = obj.nextSoldier;
            }

            if (obj.nextSoldier != null)
            {
                obj.nextSoldier.previousSoldier = obj.previousSoldier;
            }

            //If it's the head of a list, remove it
            if (cells[oldCellX, oldCellZ] == obj)
            {
                cells[oldCellX, oldCellZ] = obj.nextSoldier;
            }
            Add(obj,true);
          
        }
main shuttle
#

But it's also a memory leak right?

waxen kayak
#

my memory usage goes to 7GB+

#

in less than a second

#

so I guess yes

main shuttle
#

Perhaps adding the debugger and Pausing it in your IDE is the best option then? To see where it goes into a loop?

waxen kayak
#

with debug.break()

#

Sorry I never really used that feature

main shuttle
#

Because my game with 1 character and a plane is also 5.5GB

waxen kayak
#

it's a small 2d game

main shuttle
#

It can take a while for it to accept the break all, but it should do it after a while

waxen kayak
#

The input to Move seems fine

#

it freezes

#

I can't really

#

do stuff

violet cipher
#

Could anyone help me with some code problems. i having problems with rotations. pls Dm me if you can help

violet cipher
#

i dont want to fill the chat up with all my images...

simple egret
#

You can create a thread if needed

rigid island
#

also dont share any code via images, problem solved

#

use paste site !code

tawny elkBOT
violet cipher
#

il create a thread

rigid island
violet cipher
#

i dont have a screen recorder installed right now

#

Rotation Problems

waxen kayak
#

god damn this is driving me insane

#

well I have that

main shuttle
waxen kayak
#
(Filename: Assets/AnimalBase.cs Line: 94)

OutOfMemoryException: Out of memory
  at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_array_new_specific(intptr,int)
  at System.Collections.Generic.List`1[T].set_Capacity (System.Int32 value) [0x00021] in <4a4789deb75f446a81a24a1a00bdd3f9>:0 
  at System.Collections.Generic.List`1[T].EnsureCapacity (System.Int32 min) [0x00036] in <4a4789deb75f446a81a24a1a00bdd3f9>:0 
  at System.Collections.Generic.List`1[T].AddWithResize (T item) [0x00007] in <4a4789deb75f446a81a24a1a00bdd3f9>:0 
  at spacepartitioning.Grid.returnObjectInCell (UnityEngine.Vector2Int cellPosition, spacepartitioning.gridObj[]& objects) [0x00033] in C:\Users\smkza\Desktop\Starve\Assets\GridPartitioning.cs:242 
  at AddToPartitioning.move (UnityEngine.Vector3 oldpos, UnityEngine.Vector3 newpos) [0x0001c] in C:\Users\smkza\Desktop\Starve\Assets\AddToPartitioning.cs:38 
  at AnimalBase.refresh () [0x0001d] in C:\Users\smkza\Desktop\Starve\Assets\AnimalBase.cs:94 
  at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_array_new_specific(intptr,int)
  at System.Collections.Generic.List`1[T].set_Capacity (System.Int32 value) [0x00021] in <4a4789deb75f446a81a24a1a00bdd3f9>:0 
  at System.Collections.Generic.List`1[T].EnsureCapacity (System.Int32 min) [0x00036] in <4a4789deb75f446a81a24a1a00bdd3f9>:0 
  at System.Collections.Generic.List`1[T].AddWithResize (T item) [0x00007] in <4a4789deb75f446a81a24a1a00bdd3f9>:0 
  at spacepartitioning.Grid.returnObjectInCell (UnityEngine.Vector2Int cellPosition, spacepartitioning.gridObj[]& objects) [0x00033] in C:\Users\smkza\Desktop\Starve\Assets\GridPartitioning.cs:242 
  at AddToPartitioning.move (UnityEngine.Vector3 oldpos, UnityEngine.Vector3 newpos) [0x0001c] in C:\Users\smkza\Desktop\Starve\Assets\AddToPartitioning.cs:38 
  at AnimalBase.refresh () [0x0001d] in C:\Users\smkza\Desktop\Starve\Assets\AnimalBase.cs:94 
waxen kayak
fervent furnace
#

this is due to dead loop

main shuttle
#

No what I mean is, that that screen shows you that you infinitly nest objects.

waxen kayak
#

returnObjectInCell is the problem then I guess

simple egret
#

It's not really infinite nesting in the debug window, they just display an object that have a reference to its predecessor and successor

#

And they went through a few successors, then back and forth

waxen kayak
#
        public void returnObjectInCell(Vector2Int cellPosition, out gridObj[] objects)
        {
            List<gridObj> objList = new List<gridObj>();
            gridObj currentSoldier = cells[cellPosition.x, cellPosition.y]; 
           

            if (currentSoldier != null)
            {
                objList.Add(currentSoldier);
               // currentSoldier = currentSoldier.nextSoldier;
                while (currentSoldier.nextSoldier != null)
                {
                    currentSoldier = currentSoldier.nextSoldier;

                    objList.Add(currentSoldier);
                }
            }
            
           
            objects = objList.ToArray() ;
        }
```could this be it, or is something else, like nesting
#

I don't immidieatly notice anything wrong with this

fervent furnace
#

is there other codes modify the linked list?

#

btw you will add null to the list

waxen kayak
#

no, Move() and Add() are the only oens

fervent furnace
#

you should do this instead:

current=head;
while(current){
  list.add(current);
  current=current->next;
}
waxen kayak
#

I'll try

fervent furnace
#

if you cant figure why there is loop:
https://leetcode.com/problems/linked-list-cycle/

LeetCode

Can you solve this real interview question? Linked List Cycle - Given head, the head of a linked list, determine if the linked list has a cycle in it.

There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node t...

#

just copy the algorithm to detect

#

i think maybe the grid is not correctly initialized, or adding a same object to the list, let me think about this

waxen kayak
#

I'm trying to see how many tiems it loops in this:

public void move(Vector3 oldpos, Vector3 newpos)
    {
        gridObj[] list;
        Vector2 pos = partitioning.grid.gridIndexAtPosition(transform.position);
        partitioning.grid.returnObjectInCell(new Vector2Int((int)pos.x,(int)pos.y), out list,true);
        
        foreach (var item in list)
        {
            if(item.soldierTrans = transform)
            {
                partitioning.grid.Move(item, oldpos, newpos);
                break;
            }
        }
        
    }
fervent furnace
#

adding same object should be resulted on dangling pointer but i am not sure if this will causes cycle

if(item.soldierTrans = transform)
waxen kayak
#

oh shit

#

that was meant to be if(item.soldierTrans == transform)

simple egret
#

Unity doesn't help here, by having the implicit conversion to bool

#

It would have made a compiler error if that conversion wasn' t there

fervent furnace
#

yes adding same object will result on cycle too
eg:
if Head->A->B->C->D, adding B again
Head->B->A->B while pointer to C loses

waxen kayak
#

was that it?

#

it seems to not

#

freeze now

#

though

#

what I wanted does not work

#

but at least It doesn't freeze

fervent furnace
#

idk how you move the soldier but i will create a Dictionary<Transform, gridObj> so i can get the gridObj, idk if this work in network

waxen kayak
#

That would be very slow, no?

fervent furnace
#

much faster than iterating the double linked list and search on it

waxen kayak
#

huh

simple egret
#

Dictionaries are made to be extremely performant when searching a value from a key

waxen kayak
#

I'll do that later on, right now I wanna see why the animal does not update it's cell position

elfin tree
#

For serializing ScriptableObject Instance references in JSON, should I just have them all in a list I map through the Inspector, have a folder and load them all by ressource on game start (with some sort of RessourceManager), or something else? (also are theses only a matter of preference?)

They will be found, which ever way they’re stored either by Id or localizationEntryName.

I might end up using this design pattern on more than one thing. Thanks!

loud wharf
#

Finally finished making my weapon system (for now). UnityChanThink

#

Best part, it's not tested even once. UnityChanwow

hardy palm
#

anyone here used Microsoft mesh before please..

rigid island
#

here a TLDR

I have a question about** [thing] ** but I'm too lazy to actually formalize it in words unless there's someone on the channel who might be able to answer it

hardy palm
# rigid island a. dont crosspost across channels b. you're not getting an answer is because you...

I asked here again cause I thought maybe it wasn't a "beginner code" problem, but sure, my bad.
and I also I'm asking about if anyone is familiar with it because I am yet to find anyone who used it before. and I'd like to talk personally to that person cause it could become a paid offer for what I'm looking for.. (as it is very urgent, like, "today urgent")

however if not then, my question is, I've been trying to create something for Microsoft mesh, only problem is that I created normal C# scripts, so when I tried uploading it to the mesh environment, it didnt allow me to because apparently it cant compile "Assembly C#" components, I was wondering what should I do then, I found out that I need to make a visual script, but then still it kept only showing me for everything that I do that its "not allowed", hence the question "is there anyone who worked with this before", because out of everyone I asked, no one knew what is that or why it happens.

question then becomes, is it even possible to use normal C# scripts SOMEHOW in mesh environments, in a way that I don't know.

rigid island
unique echo
#

guys i am making an application that converts speech to text in unity engine, how can i do it ?

jaunty light
#

Okay I got another question:

My OnCollisionEnter is not being called. The capsure collider has "IsTrigger" and the enemy has a rigidBody (would have rather given it a character controller)

(I tried OnControllerColliderHit before and that was not calling when the enemy touched the player - (enemy had a character controller))

latent latch
#

OnTriggerEnter should work with a character controller I believe if you want to use that

jaunty light
#

I'll try that

latent latch
#

Otherwise cast directly using OverlapCircle/OverlapSphere

jaunty light
#

Then I'd have to use 2 different spheres

#

cause both are already using that

#

but no big deal I suppose

#

Trigger is working

#

idk why the other 2 aren't 🤷‍♂️

latent latch
#

Well, not saying you should opt in using it, but OverlapSphere basically just allows you to do what those methods do but give you more control

primal wind
#

I know some things can be done on other threads but can I for example create a collider on another thread then apply it to a gameobject on the main one later?

#

Meshes yes but colliders?

latent latch
#

Meshes can be computed for the most part, but using Unity's collider functionality is through their own estimation methods, so it's not like you're doing the calculations. So, it's probably better to clarify what you're trying to accomplish.

#

Most what you can do outside of Unity methods is usually single-threaded. Any multi-threading capabilities are usually handled under the hood by unity itself outside of any native async methods or such.

hard viper
#

when I call Collider2D. Distance, I keep getting the error: "Assertion failed on expression: 'contact != NULL'
UnityEngine.Collider2D:Distance (UnityEngine.Collider2D)"
The stacktrace brings me to a line where I call.Distance, but idk what it's trying to tell me to fix

modest jay
#

Hi, I am using the Karting sample to create my first server using UDP client/server. I have this script https://paste.ofcode.org/vr5KTtSMt8UwziqQRD2iPN and I want to change the follow and look at gameobjects depending if the player is player or player 2 which is set in the line 38-49. I have tried inside the if clause looking for the camera by tag, changing priority but everything returns a Null reference in line 52 in Unity but works well in the build version. Could someone help me on how could I achieve this?

jaunty light
#

Another weird thing

I added a 2nd post processing effect to my project, but it doesn't appear.
However, the script is being called correctly and the intensity is adjusted as intended.

fringe ridge
#

i was wondering if it matters if i'm trying to destroy a gameobject that was already destroyed

hard viper
#

Not necessarily looking for a fix for my problem, as much as I'm looking for how I'm supposed to get more info about that "AssertionFailed" error

hexed pecan
fringe ridge
#

dont the colliders have to be valid or something

#

i cant remember correctly

knotty sun
fringe ridge
#

but i remember having issues with it way back

#

but if you're getting the error on calculation i guess you wont get the object

#

back

hard viper
knotty sun
fringe ridge
#

still shouldnt give the error

#

it should return the object with IsValid false or something like that

#
Ensure that both mainCollider and overlapCol are enabled and have valid collision shapes.
Check if any of the colliders are triggers. Triggers are not considered in the physics engine’s collision detection.
Make sure that the layers of the two colliders are set to interact with each other in the Physics2D settings.```
#

try this

hard viper
#

it's the magnitude of the vector required to push 2 colliders out into contact, or pull 2 colliders to be exactly in contact

knotty sun
#

if you have 2 colliders so you have 2 transforms, calculate the distance using the transforms positions

hard viper
hexed pecan
#

Steve this is more like 2D version of Physics.ComputePenetration

hard viper
#

that's correct

fringe ridge
#

not just from the center of the objects

knotty sun
#

Ah, I dont do 2D

hard viper
#

both are CustomCollider2D

fringe ridge
#

you really have to make sure there are shapes assigned

hard viper
#

and working with CustomCollider2D, I don't think this class has been very well tested lmao

fringe ridge
#

because as far as i searched most answers are that they dont have shapes assigned

#

they are not null

#

the colliders itself, but they dont really exist

hard viper
#

you know what, let's do some more assertions to check

hexed pecan
#

Did you check the trigger thing that michael scott pointed out?

hexed pecan
#

And layers have to be able to interact in the Physics2D settings

fringe ridge
#

its probably not layers, but just make sure they actually have PhysicsShape2D

#

both

hard viper
#

I'm going, but recompiling for every response slows me down a bit

#

yes, both have shapes

#

this only happens between 2 CustomCollider2D.

fringe ridge
#

did you try doing that with something like boxCollider 2d?

#

just for testing

hard viper
#

the same method works for all sorts of colliders, and is only breaking now for CustomCollider2D vs CustomCollider2D

#

box vs box, box vs custom, edge vs custom, box vs composite... all work

#

I only trip this assertion for custom vs custom

#

for reference, my customcollider2D is a couple of polygon shapes, then one edge shape with a radius that goes all around it

#

The error disappears if I get rid of the edge shape

#

but that can have other side effects.

#

and also, I really need that edge lol

#

another bit of info. one .Distance call trips TWO identical assertions. probably because there are multiple contacts?

simple egret
#

Or none, since the message says that contact != null failed

#

But that check is made on the C++ side, the assertion isn't there in the C# code, and Distance calls a Distance_Internal() that's bound to a native function

hard viper
#

that's my core issue right now

#

I can't see wtf is going wrong

#

and the assertion message is totally useless

#

if I call Rigidbody2D.Distance (which I think connects back to the same injected function), I trip the assertion, AND it calculates a valid ColliderDistance2D object anyway

fiery warren
#

How can I add the xRotation value to the game without breaking the camera rotation.. If I use targetCameraRotation, the camera spins so fast on all axis that you can't really use that. For now I have set targetPlayerRotation for the rotation of camera. So the camera can now rotate horizontally as supposed to but I want to move it vertically as well.```cs
void Update()
{
UpdateCameraPosition();
float mouseX = Input.GetAxis("Mouse X") * (mouseSensitivity * 10) * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * (mouseSensitivity * 10) * Time.deltaTime;

xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);

targetCameraRotation *= Quaternion.Euler(xRotation, mouseX, 0f);

targetPlayerRotation *= Quaternion.Euler(0f, mouseX, 0f);

player.rotation = Quaternion.Lerp(player.rotation, targetPlayerRotation, playerRotationSmoothness * Time.deltaTime);

transform.rotation = Quaternion.Lerp(transform.rotation, targetPlayerRotation, playerRotationSmoothness * Time.deltaTime);

}

hard viper
#

is there a way to make a function generic to work for any of a set of specific classes?

#

specifically, I want MakeCollider<T>(T col) where T is BoxCollider2D or CompositeCollider2D or PolygonCollider2D

fervent furnace
#

they are collider 2D

hard viper
#

yes, but I want to exclude things like CircleCollider2D as potential arguments

#

all the methods used in the method belong to Collider2D. But I want to make sure it only gets called for specific derived types of Collider2D, and not others

hexed pecan
#

You want like an 'inverse type constraint'?

hard viper
#

My code currently looks like

        Collider2D originCollider, ref PhysicsShapeGroup2D shapes) {
    Debug.Assert(((originCollider is CompositeCollider2D)
            && (originCollider as CompositeCollider2D).geometryType == CompositeCollider2D.GeometryType.Polygons)
        || (originCollider is PolygonCollider2D)
        || (originCollider is BoxCollider2D)
        || (originCollider is CustomCollider2D),
        "Can only make this rounded shape for polygon-based colliders!");```
#

which is like a horror movie

#

I don't NEED to fix this. but... this looks pretty bad

#

alternatively private static Hashset of types to check.

fringe ridge
#

can't you do just
MakeRoundedCompositeWithoutWrapper(CustomCollider2D custCollider,T originCollider, ref PhysicsShapeGroup2D shapes) where T: BoxCollider2D, CircleCollider2D

#

im not sure exactly, cant remember

#

if this will work or not

hard viper
#

does that work?

fringe ridge
#

give me a sec

hard viper
#

I can't

fringe ridge
#

nope

hexed pecan
#

The type constraints are AND, not OR

hard viper
#

all these things are sealed

fringe ridge
#

do an interface

#

OR wont work

hard viper
#

sealed builtin class

fringe ridge
#

ah fuck right 😄

#

sorry

hard viper
#

it's ok

#

Unity devs have a fetish for sealing their component classes

hexed pecan
#

Something like extension methods but for interfaces would be cool

hard viper
#

extension fields would help tremendously

#

or just.. being able to modify these things lol

fringe ridge
#

i feel like it is not possible

#

without making it more ugly

chrome schooner
#

can anyone for the love of everything explain to me why this isn't working-
why are none of the functions being called.


public class LockOn : Singleton<LockOn>
{
    private void OnEnable()
    {
        PlayerInputHandler.Instance.playerInput.Player.LockOnHold.performed += _ => EnableLockOn();
        PlayerInputHandler.Instance.playerInput.Player.LockOnHold.canceled += _ => DisableLockOn();

        PlayerInputHandler.Instance.playerInput.Player.LockOnToggle.performed += _ => ToggleLockOn();
    }
    private void OnDisable()
    {
        PlayerInputHandler.Instance.playerInput.Player.LockOnHold.performed -= _ => EnableLockOn();
        PlayerInputHandler.Instance.playerInput.Player.LockOnHold.canceled -= _ => DisableLockOn();

        PlayerInputHandler.Instance.playerInput.Player.LockOnToggle.performed -= _ => ToggleLockOn();
    }

    [SerializeField] private bool isLockedOn = false;

    private void ToggleLockOn()
    {
        if (isLockedOn)
            DisableLockOn();
        else
            EnableLockOn();
    }

    private void EnableLockOn()
    {
        isLockedOn = true;
    }

    private void DisableLockOn()
    {
        isLockedOn = false;
    }
}```
simple egret
#

Are the input actions enabled?

chrome schooner
#

yeah, the other scripts work perfectly

simple egret
#

Is OnEnable getting executed here?

chrome schooner
#

oh my god, it just now showed the error

#

it's not finding the input system in the OnEnable function.

silent tapir
#

idk if this system is sloppy or what

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ConveyorBelt : MonoBehaviour
{
    public float speed;
    public Vector3 direction;
    public List<GameObject> onBelt;

    // Start is called before the first frame update
    void Start()
    {
        gameObject.GetComponent<MeshRenderer>().material.SetFloat("_Speed", speed/8); 
        //gameObject.GetComponent<MeshRenderer>().material.SetVector("_Direction", direction); 
    }

    // Update is called once per frame
    void Update()
    {
        if(transform.eulerAngles.y == 0) {
            direction = new Vector3(0, 0, 1);
        } else if(transform.eulerAngles.y == 90) {
            direction = new Vector3(1, 0, 0);
        } else if(transform.eulerAngles.y == 270) {
            direction = new Vector3(-1, 0, 0);
        } else if(transform.eulerAngles.y == 180) {
            direction = new Vector3(0, 0, -1);
        }

        for(int i = 0; i <= onBelt.Count -1; i++)
        {
            onBelt[i].GetComponent<Rigidbody>().velocity = speed * direction;
        }
    }

    // When something collides with the belt
    private void OnCollisionEnter(Collision collision)
    {
        onBelt.Add(collision.gameObject);
    }

    // When something leaves the belt
    private void OnCollisionExit(Collision collision)
    {
        onBelt.Remove(collision.gameObject);
    }
}``` but it kinda works but the moment it touches another conveyor belt and switches to that when it switches direction as well. This makes it ride on the edge of conveyor belt. Also, the items kinda lag on the belts.
hard viper
#

fyi there is a SurfaceEffector2D. idk if there is for 3D

somber tapir
frigid bone
#

Hello everyone , i cant seem to find a solution to attaching a script to a scriptable object. Im finding alot of things online , but none of them are really relevant.

Ive got a scriptable object with a reference to another script but i cannot select it in the inspector when creating a new scriptable object like shown here:

#

Runebehaviour being just an empty class

frigid bone
#

Yes

rigid island
#

oh its not monobehavior

#

regular class you create with an new() instance , you can't drag a script in a field

frigid bone
#

Ahh i see. That simple

#

No way around this? , i was told to try and minimalize monobehaviour scripts

#

And in this case , the class will never be called by monobehaviour

rigid island
#

why do you need the field there in the first place?

frigid bone
#

Im creating a rune system with diffrent mechanics , so when you make a new rune type , i can choose the behaviour of the rune

#

Missile runes - choose missile behaviour
Heal rune - choose heal behaviour

etc etc

rigid island
#

cant those just be scriptable objects as well?

#

they are swappable and can run methods

frigid bone
#

I want them all to be inherited from 1 class - "Rune"

rigid island
#

as long as they share a base class like "Behavior"

#

or w/e

frigid bone
#

Ohh dang , you are right

#

I could just do another step with a base parent

rigid island
#

public class BaseBehaviour : ScriptableObject { }

#

then derive anything from BaseBehaviour you can swap the slots with w/e

frigid bone
#

I even have the class ready for this exact thing

#

Sometimes you overthink.

Thanks for the help and thanks for reminding me

simple egret
#

If the base Activate method will not have any implementation, then consider making it abstract instead of virtual

#

This will also force derived classes to implement the method

frigid bone
#

^ Good tip
In this case theres a couple of things in the activate method , like mana useage

chrome schooner
#

what format does unity store rotations in? i tried doing * Mathf.Rad2Deg, but it still didn't give me the proper camera angles-

chrome schooner
#

yeah i know

#

so i guess i gotta learn that horror-

rigid island
#

no you work with Euler angles

#

Quaternion to * Mathf.Rad2Deg wouldn't make any sense

rigid island
chrome schooner
#

i am just trying to get the rotation Y from an object

#

in degrees

rigid island
#

then just use euler angles

#

myobject.transform.localEulerAngles.y

chrome schooner
#

oh i finally get it

#

yeah it does work

#

thanks a lot

eager fulcrum
#

Hey, does Resources.LoadAll also load resources from subfolders?

scarlet kindle
#

Hello, is there such a thing as an Instance ID for a scene's particular instance?
If so, how would I reference it?

hard viper
#

check build index settings

scarlet kindle
#

yea unfortunately that's not what I want... i'm hoping for a unique id for that particular instance of that specific scene, not just the general scene index.

afaik there is nothing like that...

#

like if i load scene 1 once, it has a unique id of 12345... if i exit that scene and load it again, then the next instance might have 12346

#

is what i was hoping for

hard viper
#

i don’t understand how you can have multiple instances of one scene

#

that’s not an instance

#

scenes are like macro prefabs

scarlet kindle
#

they would be at separate points in time, not at the same time

steady moat
somber tapir
#

You can just make your own id

scarlet kindle
#

yea i think making my own ID in my GameManager is the way

#

i'll just increment it each time i load a new scene

#

thanks guys!

hard viper
#

then i’d make a class in charge of changing/loading scenes that can track

#

because you can’t instance a scene, so there is no instance ID to give it

scarlet kindle
#

yea true, good ideas all around

#

cheers!!!! 😄

silent tapir
somber tapir
# silent tapir how is that going to do anything

transform.up is return the green axis of the transform. So if you rotate the object the axis rotates with it. You might have to use transform.forward or transform.right depending on how you do things.

spare island
#

What is the recommended solution for an online multiplayer party FPS supporting up to around 8 people?
Which would be easier for a beginner at multiplayer, and does it matter which solution I choose for using a service like Vivox?

vagrant blade
#

Any would work, such as Unity's own netcode. If Vivox does what you need, then use it?

spare island
spare island
vagrant blade
vagrant blade
spare island
vagrant blade
#

Yep, for development

spare island
#

Im almost certainly not going to have more than 8 concurrent players

spare island
vagrant blade
#

Ever? 🤔

spare island
#

(Im assuming you're talking about the 8 concurrent players thing)

vagrant blade
#

Right, well in the event people do, you will have to pay once you hit limits. So just be aware of that.

spare island
silent tapir
tranquil canopy
#

Hello, could someone take fast look at my lighting question said in that channel? I say it here because almost no one watches it... 🤷‍♂️
#archived-lighting message

scarlet kindle
#

Hey sorry I wanted to clarify on where to find the logs from the .exe running?

Is this considered a Player log?

knotty sun
spring creek
tranquil canopy
scarlet kindle
silent tapir
# spring creek Is your goal to get the world vector from the direction you're facing?

I mean I just tried this and it works flawlessly

using UnityEngine;
using System.Collections;

public class ConveyorBelt : MonoBehaviour {

    public float speed = 2.0f;

    private Rigidbody rb;

    void Start() {
        rb = GetComponent<Rigidbody>();
    }

    void FixedUpdate()
    {
        rb.position -= transform.forward * speed * Time.deltaTime;
        rb.MovePosition (rb.position + transform.forward * speed * Time.deltaTime);
    }

}```
#

There is just one problem, which is that the moment it touches another conveyor belt going a different direction, it changes directions, making it go on the very edge of the belt. I don't know if using a coroutine would be the best or what.

scarlet kindle
# knotty sun yes

for some reason, I dont have the file they list there... I have one called Player.log found in

C:\Users\Alex\AppData\LocalLow\DefaultCompany\Game Name\

it appears to be the right file?

scarlet kindle
#

ok thanks a ton sir!

rapid ibex
#

So I'm trying to change Scenes when a button is pressed, similar to in Titanfall 2 when you unlock the "Time-Skip" watch. I've made this, but it just duplicates the scenes so many times over and over again and I'm unsure what I'd do to stop that. This is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SwitchReality : MonoBehaviour
{

    bool levelLoaded = false;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F) && !levelLoaded)
        {
            SceneManager.LoadSceneAsync("SwitchedReality", LoadSceneMode.Additive);
            levelLoaded = true;
        }
        if (Input.GetKeyUp(KeyCode.F) && levelLoaded)
        {
            SceneManager.LoadSceneAsync("StarterReality", LoadSceneMode.Additive);
            levelLoaded = false;
        }
    }
}
pale mist
#

could someone either help me to or provide me with what I may need to correct my timestep as I both checked docs and read this https://gafferongames.com/post/fix_your_timestep/ (after finding it in like the 5th forum) but I still need help ;-;

knotty sun
rapid ibex
#

From what I read, it was to make it load in the background, to create more of a seamless switch between the two.

swift falcon
#

how to check the execution time of the code?

knotty sun
plush chasm
#

anyone here that uses FinalIK? How can I change the weight of IK components with keys in animation?

ashen yoke
#

then check profiler

swift falcon
#

alright ty

ashen yoke
#

or use Stopwatch

swift falcon
#

Process.GetCurrentProcess()

and how to use this

#

i cant do debg.log

ashen yoke
#

what do you need it for

swift falcon
ashen yoke
#

you have memory profiler

swift falcon
#

i need memory usage of the algorithm itself

#

i am doing a study

#

thats why

#

i need the algorithm itself

#

Also what do i put in parameters

ashen yoke
#

whatever you want

swift falcon
#

also thanks for ehlp

swift falcon
#

but nothing is working

somber nacelle
#

you need to add the UnityEngine using directive

swift falcon
swift falcon
swift falcon
#

please

somber nacelle
#

what are you expecting from us here? do you want us to write the code for you? because that won't happen.

swift falcon
#

i cnat do debug.log

#

idk how to fix

ashen yoke
#

UnityEngine.Debug.Log

swift falcon
#

thanks so much man

ashen yoke
#

you have debug in both UnityEngine and Diagnostics

somber nacelle
spare island
#

So do normal images just not work in unity 2023

#

did they make some change to them where you cant set them to sprites anymore

vagrant blade
#

Not a coding question. What's a "normal image"?

spare island
#

Image component

vagrant blade
#

Works the same as it always has, there's been no changes.

spare island
#

Can't drag a 2D (Sprite & UI), Legacy UI, or Default texture type into that box

#

Raw image works just fine but I don't see why I would need to use raw image..

ashen yoke
#

check again that your texture is actual single sprite

vagrant blade
#

You don't. Show the import settings for the thing you're trying to use.

spare island
#

why in the world does it default to multiple?!

spare island
#

yeah that is strange for some reason images i drag in default to 'multiple' sprite mode instead of 'single' which is my default in all other projects

ashen yoke
#

check presets

spare island
fickle hatch
hard viper
#

i’m trying to figure out how to best do ground checks, now that I am refactoring everything.
My physics solver places everything at their target destination before I hit simulate. In this case, it would be fine to get grounding state from Contacts / CollisionCallbacks, right?

polar marten
#

what is the game

fickle hatch
#

an automation game similar to factorio. im trying to put conveyor belts on the ground

polar marten
#

okay

#

what is your Edit > Project Settings > Graphics > Transparency Sort Axis?

#

there is a lot of code here

#

i am going to sort of ignore it

#

i am just checking that you don't have a weird setting there first

polar marten
#

okay

#

what does when i try to spawn a GameObject above an existing GameObject it collides with the one below it thus not spawning a GameObject. mean?

#

try to rewrite that

#

so that it makes sense

#

say what you observe in the debugger

#

or say what happens

#

it's clear that you click an empty cell above (in positive y) a game object, and you do not see an instantiation which is unexpected

#

don't say stuff like collides with the one below it

#

unless you mean "the ray hits the game object below the clicked cell, unexpectedly, according to the debugger"

fickle hatch
#

when i try to place a conveyor belt above another conveyor belt my raycast comes back as it hit something, even though there is nothing above the existing conveyor belt

polar marten
#

why did you choose -Vector2.up in Physics2D.Raycast(_mouseWorldPosition, -Vector2.up, 13f); ?

fickle hatch
polar marten
#

why are you using the mouse world point?

fickle hatch
#

i got the raycast line from unity documentation

polar marten
#

i guess, every line has a problem in CheckIfClickedOnGameObject

#

what is it hitting?

fickle hatch
#

ima try swaping -vector2.up with vector.forward see what happens

polar marten
#

don't try random stuff

fickle hatch
#

ok

polar marten
#

why did you choose that?

#

it's okay if the answer is "i don't know"

#

i mean, you can try random stuff and blub through this

#

do you want to do this the right way?

fickle hatch
#

i just copied and pasted what i saw in the unity documentation for raycast, ill link it in a sec

polar marten
#

nvm i see you mean that

#

okay

#

don't worry about it

fickle hatch
fickle hatch
modern creek
#

How can I catch an IPointerDownHandler event on a UI object that's under other raycasters?

#

(ie - I want a background to be able to catch this for "cancel" clicks)

polar marten
modern creek
#

blah

polar marten
#

you can step through graphic raycaster and event system, and clearly see that this was something that was intended to be supported

modern creek
#

Maybe you have an idea for me. I have this UI with a zillion things in it. I want a button that the user can press to use a boost - but I need their follow up action (ie, where should the boost go). If they click on the playing field, great, since I have pointer down/up events on that object already. If they click anywhere else, though, I need to cancel the particle effects on the boost button.

#

I don't want to put events on eeeeevvvvverything else and call "cancel boost"

#

Although at this point I don't see a simple solution.. maybe I'll stick a big black box on the screen (everywhere except the playing field) to capture a cancel click

ashen yoke
#

that will work but only if you have a single clickable area

polar marten
#

and use a static method to deal with that

#

for the sake of simplicity

modern creek
#

yeah, i do too, but in this case I have to do have all the other things on the UI call cancel too

polar marten
#

event system has IsBackgroundClick or something

modern creek
#

like buttons, etc

polar marten
#

which is when there was nothing that catches raycasts on graphic raycasters

#

i think for all the raycasters*

leaden ice
modern creek
#

I was thinking of getting fancy and putting a check in Update() of the playing field to see if there was a mouseup event but that's just .. sloppy

ashen yoke
#

just expose a callback, add it somewhere in the middle of the click processing

#

youll get notif and you can edit event

polar marten
modern creek
polar marten
#

i don't htink it's possible to avoid extending event system

leaden ice
modern creek
#

yeah.. well.. i need it to. 🙂

polar marten
#

specifically to expose GetCurrentPointer or whatever it's called.. it's a protected method and you basically want to promote it

leaden ice
#

put it on a screen space - camera canvas with a plane distance of 1000

ashen yoke
leaden ice
#

You definitely don't need to extend event system for this

modern creek
#

but then the other objects don't get the clicks.. it's minor but if a user clicks on "use boost" then clicks another button on the UI, that click (which would hit the invisible UI thingy) wouldn't do anything

leaden ice
modern creek
#

hm... i'm explaining this poorly.. lemme snap a pic, sec

leaden ice
#

put it in front of objects you want to block, and behind objects you don't want it to block

modern creek
#

The 1st "boost" button (the leftmost one with the purple diamonds) is active - it's waiting for the user to click somewhere on the grid. That's fine, I have a grid that handles input just fine.. while the game is waiting for the followup click, particle effects are playing on the boost button

polar marten
modern creek
#

if I click anywhere else than the grid, the boost should "turn off"

polar marten
#

like 4 of them, in order to make a border

#

in order to create a "cancel zone"

#

i hear you

modern creek
#

(but there's many other valid raycast click handlers on the UI - like the other boost buttons, etc)

polar marten
#

so i toggle that on when you're doing a targeted effect

modern creek
#

showing that big honking black thing (with some instructions, I guess) that catches any "cancel" clicks

polar marten
#

okay

polar marten
modern creek
#

kinda hides my particle effects but i can deal with that

polar marten
#

check it now, i just have the bug lol

#

i didn't do anything about it because on mobile you are dragging

#

and people who do the click based workflow don't make this mistake

#

that said you have more buttons on screen

modern creek
#

Interestingly the gameobject gets IPointerUp events if you started the click on the object

polar marten
#

if i had to implement this now, i would probably extend Button and have it check if it should be suppressed due to a global state

#

so it goes with UI

#

i would actually extend the thing i actually use*, which is OnPointerUpAsObservable, which is much easier

#

aka the ObservablePointerClickTrigger script in unirx

leaden ice
#

otherwise leave it disabled

polar marten
#

cancellation works correctly but because it just checks if you have a valid target. a ui blocking shade would also work and would be less invasive code-wise

#

now that i understand what you are talking about, well, you can definitely click end turn when you are summoning / casting

modern creek
#

don't make fun of my placeholder particle fx, i'm a horrible vfx artist

leaden ice
#

#archived-networking - it depends on your network framework. Most have a concept of "ownership" or "authority" over network objects. Use that.

pale mist
#

Is there anyone available to help me in dms atm, doing my best to work on frame independent movement while cleaning up and reformatting my PoC build but I think im fucking something up

lean sail
spare island
#

Already having desync issues
Using Unity lobbies, when I join the lobby and ask for the player list the player list is correct
but when the host checks the player list they dont see any new players

pale mist
#

alright ^~^ just have a bit of trouble communicating so I didnt wanna drown anyone else out

#

but when I apply velocity while the state is active through the state handler OR the timer itself it uh

#

well

#

its not happy for sure (I also tried it in the if statement within the timer itself which I thought would have worked but I guess not)

#

splitting the velocity helped a little but this isnt frame independant which is an issue obviously

#

im not sure where I should apply the velocity if not on the initial input or during the state or if I just did it wrong

spare island
#

Anybody familiar with unity netcode know why my player list doesn't update after someone joins?

#

HeadToTheFuckingWall when the tutorial fails to mention important aspects of the thing you're trying to make

pale mist
#

I figured it out, I needed to store the wall direction when applying force over time because I was only reading it for the single input frame during the wall jump the way I had it before

lean sail
spare island
analog crane
#

hey all, i'm trying to make a sort of ocean shader that gets a plane and updates it's vertex positions every frame. triangles and uvs are needed, but they can stay the same. both collision and render are needed from this shader, hence why i'm not just doing it on the gpu -

void Start()
{

    preMesh = new Mesh() { vertices = GetComponent<MeshCollider>().sharedMesh.vertices, triangles = GetComponent<MeshCollider>().sharedMesh.triangles, uv = GetComponent<MeshCollider>().sharedMesh.uv }; ;
    oldVertexArray = GetComponent<MeshFilter>().sharedMesh.vertices;

    GetComponent<MeshCollider>().sharedMesh = preMesh;
    GetComponent<MeshFilter>().mesh = preMesh;

}

public void Update() {
  AdjustMesh();
}

public void AdjustMesh()
{
    Vector3[] newVertexArray = new Vector3[oldVertexArray.Length];

    for (int i = 0; i < GetComponent<MeshCollider>().sharedMesh.vertices.Length; i++)
    {

        newVertexArray[i] = new Vector3(oldVertexArray[i].x, oldVertexArray[i].y, oldVertexArray[i].z + physicalWaveHeightVar * Mathf.PerlinNoise((oldVertexArray[i].x * physicalWaveWidthVar) + timeVar * physicalWaveSpeedVar, (oldVertexArray[i].y * physicalWaveWidthVar) + timeVar * physicalWaveSpeedVar));



    }
    preMesh.SetVertices(newVertexArray);
    GetComponent<MeshCollider>().sharedMesh = preMesh;
}```

but every few seconds it stutters the game, i think there's a massive amount of garbage to collect, but i can't call it manually or EVERY frame stutters for a massive chunk of time. there has to be a more efficient way to make new meshes, right? if anyone has any advice lmk!
leaden ice
#

That creates a new copy of the vertex array every single iteration of the loop

#

You're also explicitly making a new array every frame. Why?

#

Just reuse the same array

analog crane
#

because i'm dumb and it's 5am 😅

#

right gimme a sec

analog crane
#

okay, made it at least 4x as efficient

#

changed it to one array with a constant int that's based off the length initially, and changed how the sine is calculated to remove the additional array ref

#

i was also doing this on four ocean planes, now i just project the same mesh onto all four instead of lazily calculating it four times just so it can be prefabbed easily still

pearl osprey
#

I don’t have the code right now but maybe someone can still help: Im working on a top down shooter and i want that when I shoot I want the player to flip either left or right indicated by where the mouse is, so in my shoot code i have an if statement if the player already is in the right direction and if not i call the Flip function. After this I spawn and activate the bullet. The problem is that this when i run the game the bullet gets shot before the character flips.

cosmic rain
broken light
#

Any one know why this won't add labels to my asset:

var mesh = new Mesh();
AssetDatabase.SetLabels(mesh, new string[] { objType.ToString()});
AssetDatabase.AddObjectToAsset(mesh, blueprint);
AssetDatabase.SaveAssets();```
#

was hoping it would have the label Mesh but it ends up with no labels

lean sail
#

Is there a general guideline for how much allocating is bad for a pc game? Im not trying to prematurely optimize but curious at how carefree i should be. I noticed when I was making some damage numbers (player gets hit, number floats up on screen) that my DoTween sequences were allocating like 2kb per use which seems a bit excessive. This could be happening every frame, should I be concerned with this?

cosmic rain
# lean sail Is there a general guideline for how much allocating is bad for a pc game? Im no...

Possibly. In the end gc collection is just another thing you need to allocate performance budget for. If you can afford it, hundreds of kbs per frame may be fine, but you would have less budget for other things. It also depends on the GC type. I think incremental is the default now. It means that it would try to deallocate a little bit every frame without affecting the game too much. On the other hand if incremental is not enabled, it's gonna collect all at once every few frames possibly creating a spike.

lean sail
#

ill probably just stay with update loop in this case since its easy, really surprised dotween allocs this much

pearl osprey
quartz folio
#

Also, can subassets have different labels to their parent? I'm not that familiar with labels

broken light
#

have to save the database then set labels

#

cant do it before saving so you basically have to do a double save assets

quartz folio
#

I don't know if you have to call save for labels--at least, they don't in the docs

#

would have to try with git 😄

dawn nebula
#

Is there an equivalent for Rigidbody2D.GetContacts in 3D?

#

Or better question, how do I find all the current contact points for a Rigidbody?

dawn nebula
broken light
#

is there only a limit of 2 labels per asset?

#

@quartz folioah you're right you can't apply them to sub assets

#

what a pain

chrome schooner
#

how can i delete this? i have a state machine set up, and i want this line to be cleaned up.
playerInput.actions["Escape"].performed += _ => pauseMenu.ChangeState(pauseMenu.paused);
i tried changing the + to a -, but that didn't work.

knotty sun
chrome schooner
knotty sun
chrome schooner
#

only reason i managed to was because i already had that answer open

#

i just wanted to see if there was another fix

#

since it made me rewrite some stuff 💀

knotty sun
chrome schooner
#

i didn't know you couldn't unsubscribe with lambdas

dusty fog
#

Hey! Not sure in which channel I can post but I have some troubles understand how to implement a file read + image uploader within Unity. I'm trying to achieve 2 things, read a csv file which I already did using a drag and drop feature from github, but it crashes too much without any info so I'm trying to replace that. Secondly and it's the part I have no idea how to achieve, a way to upload an image in the game and save it to some database; I managed to find some repos where you can use an image as a texture in game, but couldn't find any info on how to upload this image somewhere that I can then link to the player and reuse whenever he opens the app again

knotty sun
dusty fog
knotty sun
#

you mean if the user is cross platform?

dusty fog
#

Yes, most of users will probably have the game on both mobile and pc, so I'm trying to save consistenly between both

primal wind
#

You want to send the image to a database?

dusty fog
#

Yes

#

Already using websocket+mongo for all the data, but images I'm not sure how to do it

primal wind
#

Read its bytes and depending on your database, convert it to the appropriate type

knotty sun
#

does mongo support blob data type?

primal wind
#

I'm not too familiar with mongodb tho

dusty fog
knotty sun
#

that will do

dusty fog
#

So when the user uploads the image via pc or mobile I'd need to convert it to bytes and save to the db? And then when login back in either I'd need to convert back those in a texture?

knotty sun
#

yes, exactly

dusty fog
#

Okay nice, thx a lot, I'll try to understand how it works!

knotty sun
#

you could still store it locally, then check if not exist local get from db, to cut down on overhead

primal wind
#

If you do that you should prob store a hash to know if the one in the DB is different

knotty sun
#

crc

dusty fog
#

Makes sense, I'll start with uploading/storing/loading and I'll add this on top after

#

Are you aware of any repos or asset that is able to manage standalone, mobile & webgl?

dusty fog
#

No for the unity side, to upload the image/file in the first place

knotty sun
#

UnityWebRequest

dusty fog
#

Does it handle like opening the file explorer?

knotty sun
#

no, there is a free asset on the store that does cross platform File panel at runtime

dusty fog
#

Yeah this one doesn't handle webgl, I'll start with this one and find another solution for webgl, thx again

primal wind
#

You'll probably have to do something with JavaScript

knotty sun
dusty fog
knotty sun
#

sure

jaunty plume
#

guys i have a problem
while having the math for distance in vector2 between object and plane, i cant get the math to get object position in front of the plane

#

and keep in mind that i have to avoid the parent and child feature

fervent furnace
#

rotate the offset and set the box's position after rotation

jaunty plume
fervent furnace
#

https://discussions.unity.com/t/rotate-a-vector3-direction/14722/2
there should be other easier ways for doing that

hoary pewter
#
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using UnityEngine;

public class MovementController : MonoBehaviour
{
    [SerializeField] private float rotDegreeClamp;
    [SerializeField] private float jitterBuffer;
    [SerializeField] private float rotSmoothing;

    private Quaternion gyroAttitude = Quaternion.identity;
    private Quaternion prevFrameRot;

    private void Start()
    {
        Input.gyro.enabled = true;
    }

    void Update()
    {
        gyroAttitude = Input.gyro.attitude;

        Quaternion rotChange = Quaternion.Inverse(prevFrameRot) * gyroAttitude;
        //Quaternion clampedRot = Quaternion.Euler(gyroAttitude.eulerAngles.x, gyroAttitude.eulerAngles.y, Mathf.Clamp(adjustedZRot, -rotDegreeClamp, rotDegreeClamp));

        if (Mathf.Abs(rotChange.eulerAngles.z) > jitterBuffer)
        {
            Quaternion zGyroRot = Quaternion.Euler(0, 0, gyroAttitude.eulerAngles.z - 90);
            transform.rotation = Quaternion.Slerp(prevFrameRot, zGyroRot, rotSmoothing * Time.deltaTime);
            Debug.Log("jitter: " + rotChange.eulerAngles.z);
        }
    }

    private void LateUpdate()
    {
        prevFrameRot = transform.rotation;
    }
}

I am trying to compare the rotations of my object on the prev and current frame in order to do some basic noise filtering for my gyroscope controller however the value I'm getting are ranging from 0 - 360 depending on the rotation and has no correlation to the difference between frames at all. I was under the impression that I could compare the rotations using "Quaternion rotChange = Quaternion.Inverse(prevFrameRot) * gyroAttitude;" where Quaternion.Inverse(A) * B would give me the local space rotations and vise versa world space so I assume the order is at least correct

#

it also starts off at like 20 degrees even when my phone isn't plugged in and theres nothing that should influence the rotation but I dont know lol

cobalt gyro
#

Is there a way to access the animator nodes through code

leaden ice
cobalt gyro
#

replace the animation

#

via code

leaden ice
cobalt gyro
#

ty

leaden ice
ember pine
#

hi guys

#

is adding keyvalue to diction in aysnc method doesnt work ?

rigid island
fervent furnace
#

no, it should work

hasty wave
#

I kept getting this error, although I coulnd't find the instance that is null

fervent furnace
#

where you new the dictionary?

fervent furnace
#

oh i misread

#

just restart the editor

ember pine
#

in create singleton method

#

just dont know why this happen, is this weird ?

fervent furnace
#

just i misread didnt notice it is editor error, so restart the editor should solve it
mb

knotty sun
ember pine
#

but out of method scope there is no keyvalue in dictionary

#

the dictionary count = 0

fervent furnace
#

have you checked the allcurrencydefinition first?

ember pine
#

yye, ichecked it

hard viper
#

why are you calling a static instance field? you should be retrieving by GetInstance()

#

you are bypassing any safeguards on a singleton

fervent furnace
#

have you also checked the dictionary count after the foreach?

ember pine
#

ssem like the keyvalue is added after foreach

#

i call the GetGold Method after FlecthCurrencies done

fervent furnace
#

i would find all PlayerXXXX.Clear() first

ember pine
#

there is no PlayerXXX.Clear except the one in FlectchCurrencies

fervent furnace
#

how about remove()? i think only those two methods can reduce the count of dictionary

hard viper
#

that dictionary should probably only be altered via functions of the class that holds it

#

which should make it easy to locate changes

ember pine
#

yeah

#

i found it

#

the singleton object is destroyed when load newscene

#

thank all uu guyss

hard viper
#

you should take a stock singleton class

hard viper
# ember pine the singleton object is destroyed when load newscene

Hey everyone,

In this tutorial we cover the controversial SINGLETON! Many people will hate me for teaching this but I think it is a useful tool to have, or at least know about when programming. Hope you learned something and thanks for watching!

Example video of singleton that exists in scene (Canvas Manager):
https://www.youtube.com/watch?v=v...

▶ Play video
crimson trellis
#

I'm making a android game
If I have a screen space-overlay UI with a image that covers the entire screen (which is used to look around)
Then I'm unable to interact with world space UI

I want to interact with world space UI first then screen space

random oak
#

Thank you for the reply!
sorry for late response I've been away. I ended Up solving the issue with Func ty!

hard viper
#

are collision callbacks an acceptable place to be doing ground checks?

#

now that I am refactoring, i am thinking that it might be

somber tapir
gaunt blade
#

guys I know there's a way to only show some attributes in the editor based on some value (e.g. melee or projectile ability) but idk what it's called. do you guys know?

fiery oyster
#

SkillTreeAbility (The one thats dragged)

[RequireComponent(typeof(Image))]
public class SkillTreeAbility : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
    public Transform ParentAfterDrag = default;

    public void OnBeginDrag(PointerEventData eventData)
    {
        ParentAfterDrag = transform.parent;
        transform.SetParent(transform.root);
        transform.SetAsLastSibling();
    }

    public void OnDrag(PointerEventData eventData)
    {
        transform.position = Mouse.current.position.ReadValue();
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        transform.SetParent(ParentAfterDrag);
        transform.localPosition = Vector3.zero;
    }
}

SkillTreeSlot (The one that does the on drop logic)

using UnityEngine;
using UnityEngine.EventSystems;

public class SkillTreeSlot : MonoBehaviour, IDropHandler
{
    public SkillTreeAbility HoldingSkill;

    public void OnDrop(PointerEventData eventData)
    {
        if (HoldingSkill == null)
        {
            HoldingSkill = eventData.pointerDrag.GetComponent<SkillTreeAbility>();
            HoldingSkill.ParentAfterDrag = transform;
            HoldingSkill.transform.SetParent(transform);
            HoldingSkill.transform.localPosition = Vector3.zero;
        }
    }
}

I have problem with dropping the TreeSkillAbility into Slot

#

I tried debugging, and only the OnEndDrag is being called

#

All of the children are on the same canva

#

it does looks like the hierarchy ability (draggable) needs to be on top, but i dont think thats how its supposed to work

#

if i change the code from LastSibling to first, it does work, but only once like ???

somber tapir
gaunt blade
#

lmao thanks man

void turtle
#

Is netstandartd2.1 the correct target framework when using Unity 2022.3.3f1? im using a shared library but Im unable to access the classes from it. If I am copying the dll file I get this error message.

polar marten
#

you can ignore assembly version verification and that might be enough

#

this table is the assembly versions.

Target Framework    Assembly Version
.NET Framework 4.5    4.0.0.0
.NET Framework 4.5.1    4.0.0.0
.NET Framework 4.5.2    4.0.0.0
.NET Framework 4.6    4.0.0.0
.NET Framework 4.6.1    4.0.0.0
.NET Framework 4.6.2    4.0.0.0
.NET Framework 4.7    4.0.0.0
.NET Framework 4.7.1    4.0.0.0
.NET Framework 4.7.2    4.0.0.0
.NET Framework 4.8    4.0.0.0
.NET Core 1.0    1.0.0.0
.NET Core 1.1    1.1.0.0
.NET Core 2.0    2.0.0.0
.NET Core 2.1    4.6.0.0
.NET Core 2.2    4.6.0.0
.NET Core 3.0    3.0.0.0
.NET Core 3.1    3.1.0.0
.NET 5.0    5.0.0.0
.NET 6.0    6.0.0.0
.NET Standard 1.0    1.0.0.0
.NET Standard 1.1    1.0.0.0
.NET Standard 1.2    1.0.0.0
.NET Standard 1.3    1.0.0.0
.NET Standard 1.4    1.0.0.0
.NET Standard 1.5    1.0.0.0
.NET Standard 1.6    1.0.0.0
.NET Standard 2.0    2.0.0.0
.NET Standard 2.1    2.1.0.0
#

you can configure your project to actually target netstandard21

void turtle
polar marten
#

what do you mean access the library?

#

you can turn off assembly version checking. it's called something like that

void turtle
static matrix
#
if(Input.GetMouseButtonDown(0)){
            var ClickedPoint = Input.mousePosition;
            
            Color32 CheckColor = texture.GetPixel((int)ClickedPoint.x, (int)ClickedPoint.y);
          
            //Debug.Log(CheckColor);
            sprite.color = CheckColor;
            foreach (Province p in provinces)
            {
                //Debug.Log(p.MyClickableZone.MyColor);
                //Debug.Log(p.name + " "+ DifferenceInColors(p.MyClickableZone.MyColor, CheckColor));

                if (DifferenceInColors(p.MyClickableZone.MyColor, CheckColor) == 0)
                {
                    
                    p.OnLClick();   
                }
            }
        }

heres the code that gets the clicked color and refers it back to the provinces, with their each assigned colors

#

the issue is, because Input.mousePosition is screenspace, if I change what the camera sees, it wont change what Clickedpoint is

#

(this code works great btw)

heady iris
#

is this texture being displayed by an Image component?

#

or is it something in the world, on a renderer?

static matrix
#

It is, but it doesnt need to be for this, ie, the code will work even if it isnt
I'm using a sprite which is inconsistent, but thats only because a worldspace canvas wasnt showing up on the second camera for some reason

#

I tried using a rendertexture, but for some reason the colors got offset weirdly, and that didnt work

heady iris
#

perhaps you had the wrong color format

heady iris
#

But if this is an orthographic camera looking directly at the sprite, then you can skip that

#

this would only be necessary if you had to deal with perspective

heady iris
#

actually, I wonder if you can just raycast to it and get the UV coordinate directly

hard viper
#

I'm thinking about making a singleton class to help me orchestrate things at different points of a frame. My idea is to make public event Actions like OnEarlyFixedUpdate, and invoke in a script with high priority. Would this be bad if the action winds up having a lot of read/write?

heady iris
#

I know you can do that for a mesh collider

#

I don't know if that would work with the mesh that a sprite renderer creates

static matrix
#

could I just use a boxcollider?

heady iris
#

this would be the magic

#

Failing that, I would convert from screen-space to world-space to the sprite renderer's local-space

#

You'll then just need to scale the result correctly

#

I don't do a lot of 2D so I'm not sure what that scale would be off the top of my head

#

you'd divide by the sprite renderer's local-space size

#

(or just go to world-space, subtract the world-space position of the sprite renderer, and then divide by the world-space size of the sprite renderer)

static matrix
#

math

heady iris
static matrix
#

ill work on it, getting a better idea of what to do tho

heady iris
#

Converting to local space would be the best, because it would correctly handle a rotated or scaled sprite renderer

hard viper
#

Unity doesn't have a LateFixedUpdate, or EarlyFixedUpdate, or AfterCollisionCallbacks.

#

If you use Coroutine with IEnumerator with yield return WaitForFixedUpdate, it will execute after collision callbacks.... of the NEXT frame

heady iris
#

I was looking into this at one point

#

Entities makes this super easy. You can arrange systems/system groups however you want

#

I remember finding some little bits and pieces that looked relevant, but not really getting anywhere..

static matrix
#

would a boxcollider work or would it have to be a meshcollider

leaden ice
heady iris
#

A mesh collider would be necessary for texture coordinates, yes

static matrix
#

ok

heady iris
#

I'm not sure if you could use this with a sprite renderer

#

i should just go look lol

#

doesn't seem like it

heady iris
#

in case you're joining this late

static matrix
#

I could always just make it a cube

#

I dont think that would have any issues? or that could have a lot of issues

leaden ice
#

Use a quad mesh and MeshCollider

#

then you can just use TextureCoord

#

(instead of SpriteRenderer)

static matrix
#

ok

#

this worked, although it does introduce the issue of clicking outside of the bounds will cause an error
but that shouldn't be too hard to fix

heady iris
#

should've thought of that lol

latent latch
static matrix
#

im unsure why the scaling is a little off, but I can cap zooming out at such a point where it woudlnt get bad

#

or something

fiery oyster
latent latch
#

Oh, you're talking about the raycast not going through the image

fiery oyster
#

and on enddrag switch it on

latent latch
#

But I notice your slot elements are being hidden too when you drag over a higher ordering, so you may run into this issue too.

fiery oyster
#

oh yeah, thats 2nd time when i did change the transform to first sibling

#

to showcase the different behaviour (still unexpected)

#

last sibling should often be rendered on top (but will know your fix at top of my head if i will encounter that)

latent latch
#

Another fix is to use multiple canvas too as then you can sort it directly with layering ordering

static matrix
#

unless that didnt work
it might not have

#

how can I change the aspect ratio of a camera?

#

wait nvm im just dumb

magic wolf
#

Anyone able to DM. I have a question about something Im working on

fervent furnace
#

dont dm, just ask your question here

magic wolf
#

SC allowed?

#

Ok so I need help with the middle line. I need to know how to get it to work because on the Unity Docs it says there is an out but when I try it, it says no out override

static matrix
#

send error

magic wolf
#

I cant get a SC of it. When I click screenshot overlay disappears haha

#

Ill tell you what it says

leaden ice
#

please check the docs and only use methods/overloads that exist

magic wolf
#

Argument 1 may not be passed with the 'out' keyword

static matrix
#

??????????
at the bottom of visual studio, there should be a box with an x, that should have all your errors

static matrix
#

so you need something else passed in before passing out

leaden ice
magic wolf
#

currentDrawing is a line render

magic wolf
leaden ice
static matrix
#

hover over the function, it should say what it takes

fervent furnace
#

out modifier doesnt require you to initialize the variable

magic wolf
fervent furnace
leaden ice
#

the docs are wrong

#

the Vector3[] version isn't with out

#

because Vector3[] is already a reference type

#

the solution is:

  • initialize the array
  • remove the out keyword
#

the fact they used out in the docs is a long running error

fervent furnace
#

oh it assumes you pass a allocated buffer into it

leaden ice
#

it makes sense for NativeArray but not for the managed array

magic wolf
#

usually I can find proper way online but couldn't find anything about this.

fervent furnace
#

just read the overload method signatures in your ide

leaden ice
#
Vector3 results = new Vector3[myLineRenderer.positionCount];
myLineRenderer.GetPoints(results);```
#

^ better to reuse an array though

#

but this will work in a pinch

magic wolf
#

Thank you

chrome schooner
#

i've defined this in the editor, but the following code returns inputAction as null:

private class StateKeybinds
{
    public InputActionReference inputAction;
    public UnityEvent OnActionEvent;

    public StateKeybinds()
        => inputAction.action.performed += InvokeUnityEvent;

    public void InvokeUnityEvent(InputAction.CallbackContext context)
        => OnActionEvent?.Invoke();
}```
#

[SerializeField] private List<StateKeybinds> stateBinding = new List<StateKeybinds>();

#

ignore the weird framework i have going on-

leaden ice
chrome schooner
#

i added a breakpoint

leaden ice
#

where

chrome schooner
#

=> inputAction.action.performed += InvokeUnityEvent;

#

inputAction returned as null upon creation

leaden ice
#

I would guess that you're calling this on a wrong instance of StateKeybinds then

#

e.g. not the one from the screenshot where you have it assigned

#

Show the full stack trace where it's null

nocturne pollen
#

Hey, I need some help. I am trying to use Editor scripts to create gameObjects using

UnityEngine.Object cellobj=AssetDatabase.LoadAssetAtPath<UnityEngine.Object>("Assets/Prefabs/Blank Path.prefab");
var attr = cellobj.cell_attr;
cellobj.cell_attr=new_attr;
Cell newCell=PrefabUtility.InstantiatePrefab(cellobj) as GameObject; 

The cellobj has some attributes inside in an attached separate Cell script file. I need to modify some of these in the Lines of code in between making UnityEngine.Object and instantiating the object as a Cell.

But it gives me an error

Object' does not contain a definition for 'cell_attr' and no accessible extension method 'cell_attr' accepting a first argument of type 'Object' could be found (are you missing a using directive or an assembly reference?)

Can I modify this objects copy of the Cell script variables or access the cell script variables? Or can you suggest some alternatives?

leaden ice
#

You should also probably use LoadAssetAtPath<GameObject> to make your life easier as well

#

You have UnityEngine.Object cellobj
so it should be pretty obvious that cellobj.cell_attr doesn't exist

#

you would need to get the actual component where the cell_attr field lives

#

hint: GetComponent is a thing on GameObject

vocal lantern
#

hello

nocturne pollen
nocturne pollen
leaden ice
#

the instantiated GameObject is ALSO a GameObject

#

changing the type you use in LoadAssetAtPath will make this clearer and easier to recognize in your code, and avoid you having to do a cast

nocturne pollen
#

so i should make a gameObject and then when instantiating it creates another copy of it

leaden ice
#

Instantiating creates copies of things

#

that's what it does yes

nocturne pollen
#

ah thanks

leaden ice
#

You aren't "making" a GameObject, just defining your reference as a GameObject reference

nocturne pollen
#

ah

swift falcon
#

Even though SceneView.lastActiveSceneView does not return null, when I open a project for the first time, SceneView.lastActiveSceneView?.camera returns null. Therefore, SceneView.GetAllSceneCameras()'s length returns zero for once. I just hook a method to SceneView.lastActiveSceneViewChanged (Action<SceneView Previous, SceneView New>) for those checks i said above.
How do i get the latest active SceneView Camera at the first opening of the Project properly?

I investigated the problem. Seems its about the lifecycles. I will try some kind of "Initiator"

spare island
#

Unity netcode:
How do I use the PlayerLeft lobby event? It returns a list of ints for the players who left, but how am I meant to use ints to represent players?

#

PlayerJoined gives me a normal player object

chrome schooner
#

how can i set the eventSystem.firstSelectedGameObject during runtime?

#

like, i can change it, but the Event System doesn't update accordingly-

#

so all the UI just doesn't react

rigid island
chrome schooner
#

this i mean

spare island
#

so like Button.Select()

chrome schooner
#

ohh

#

i thought y'all meant the Editor select 😭

rigid island
#

I mean i did put ()

#

and ur in code channel

#

xD

spare island
#

thank you unity very cool

rigid island
#

agh light mode

#

just lost 10 years o f eye sight

spare island
#

its 2pm here

rigid island
#

same

#

darkmode all day bby

spare island
#

theres not even dark mode for unity docs

rigid island
#

wait yall dont draw yer shades all day ?

spare island
#

i used to but then i couldn't sleep ever

#

nah dark mode extensions are shit

#

i think opera has a built in dark mode thing anyway

rigid island
#

wish unity docs had theme like .net

spare island
rigid island
polar marten
#

that's all they are

swift falcon
spare island
rigid island
#

some of these categories dont make sense

rigid island
#

id say thats active

spare island
#

so they probably dont know the answer

rigid island
#

people do have stuff to do

lean sail
#

The guy that responded to you in there also really knows what hes talking about.

#

He literally helps everyone in that server

rigid island
#

yeah i would hope so hes the mod

spare island
#

well if he doesn't know the answer to that then im fucked

#

shouldn't be this hard to just to tell when a player leaves and to put a message in the chat that "this player left: "

rigid island
spare island
rigid island
spare island
#

this is the only thing that i've found and it just links me back to the docs i was already reading

#

please god dont make me have to post on stackoverflow

rigid island
#

oh shite

#

is this NGO day

spare island
rigid island
#

multiplayer isn't for any entry level

simple egret
spare island
#

what makes you think im at entry level?

simple egret
#

You might need to find a player by that index, which means you need to store them in some list

rigid island
#

because you're here asking about mutliplayer xD

spare island
#

this is just my first time using unity netcode, and im finding the resources to be insufficient

rigid island
#

its all good I'm pretty new with netcode too

spare island
rigid island
#

exactly my point

simple egret
#

Agreed the docs page on this could use more info on what that integer is

spare island
#

it fits in both categories but feels more like a coding question to me

rigid island
#

yeah sorry I never used lobby I just know in NGO you get uLong for player ID

#

so int threw me off

simple egret
#

The integrated docs (Intellisense) doesn't have more info than the docs I guess

spare island
spare island
simple egret
#

Nah like the event itself, if you hover over it it might have a more extensive description

rigid island
#

huh guess lobby uses ints for players

#

weird

simple egret
#

And for finding it, given that the indices do NOT change as players leave and join, you'd need to store a list of them in a Dictionary (?) and index that

spare island
#

im assuming im just doing this wrong then since not even the mod on that server knows how to use it

rigid island
#

have you actually tested the event if it runs

#

worry about using it later

spare island
#

i havent tested it, no

swift falcon
rigid island
#

Idk how you test Lobby multiple ppl, but in ngo you can do a Debug.Log of the clientconnect and get their info

#

using ParallelSync for multiple client testing

simple egret
#

Okay I'm drilling down the documentation and I found this thing (in ILobbyEvents.Caalbacks.PlayerLeft)

#

So it's indeed stored as indices, who designed that?

#

And most importantly were they high when they did it

#

lmao clicking the "See ApplyPatchesToLobby" leads to a 404

rigid island
#

nicee

simple egret
#

At least the naming conventions are respected unlike the majority of the codebase (have you seen Unity.Mathematics lol)

rigid island
#

yeah working with splines package is a pain xD

spare island
simple egret
#

Not even player IDs that would be too simple, but their position in the lobby however it's stored

rigid island
spare island
#

time to test

rigid island
#

you funny

spare island
rigid island
#

its all about efficency and speed on networking

spare island
#

how is an index any different than a playerID

rigid island
#

wdym playerId

#

you said PlayerObjects

#

like a class ?

simple egret
#

OH hang on

#

Player class

spare island
#
    private bool ValidatePlayerName()
    {
        var myName = GlobalClientData.PlayerName;
        return !currentLobby.Players.Any(player => myName == player.Data["PlayerName"].Value && player.Id != AuthenticationService.Instance.PlayerId);
    }

this works fine

simple egret
#

Nevermind

rigid island
#

but again Im speaking from NGO idk how different Lobby is

#

but yeah objects arent ideal over value types on wire

spare island
#

now its spamming warnings 👍

rigid island
#

well now interest is peaked.. I'm gonna install lobby and play around

hard viper
#

manual makes it sound like OnDestroy etc might not get called after FixedUpdate and before Update

rigid island
#

wouldnt that be the end of the frame?

hard viper
#

to be clear, fixedupdate and update run on totally separate frames, right?

rigid island
#

yeah ofc

hard viper
#

making sure

rigid island
hard viper
#

hold up, do they run on different threads?

rigid island
#

😅 wish i knew

hard viper
#

because that’s a pretty big deal

rigid island
#

does unity even doing anything thats not on the main thread?

spare island
hard viper
#

i was working under th assumption that there is one main thread that evaluates either an Update or FixedUpdate frame, and swaps between them based on current time

rigid island
#

thats what i thought tbh

spare island
#

I think theyre updating stuff to be multithreaded but idk what

#

something something burst

hard viper
#

i’m just dealing with object destruction, and want to orchestrate everything properly

#

Now that I have manual simulation, I have a lot more power to fuck with LateFixedUpdate

rigid island
#

LateFixedUpdate is a thing ?

hard viper
#

only because I have my own physics system

rigid island
#

ohhhlol

hard viper
#

I can call delegates at different stages of the process.

spare island
#

they could've at least named the int 'index' or something

rigid island
#

I'm just tryina save up for havok 😔

spare island
#

i thought havok was free

rigid island
#

you need Pro license

spare island
#

oh, so free for me lol

rigid island
#

:\

hard viper
#

like i can call delegates right before solving, right after collision callbacks, etc

spare island
#

student moment

rigid island
#

that will be over soon xD

spare island
simple egret
rigid island