#archived-code-advanced

1 messages · Page 49 of 1

torpid swift
#

What would probably happen is overshoot

dusty wigeon
#

There is no overshoot.

torpid swift
#

It tries to land at half in the wall, but it lands further because that point is unreachable

dusty wigeon
#

Because the calculation find the correct velocity base on the angle and distance

#

It wont land in the wall if you adjust the height

torpid swift
#

Velocity, angle and distance got nothing to do with the y offset

dusty wigeon
#

Then use Height and distance

torpid swift
#

And that y offset is exactly the problem. Because if I put the height higher, the distance will be greater and too high

#

That's the problem I got with the raycasts I was using to determine the height

#

Because it calculates the distance based on diagonal instead of horizontal

#

Which is logical, but makes it much harder to calculate a precise distance point

dusty wigeon
#

Is that what you are trying to do ?

torpid swift
#

The code I posted was using diagonal 20

#

So the distance between the circle and the x point is 20 diagonally

#

I can show you in like 8 - 10 hours when I wake up again

#

Because we are probably not on the same line yet

dusty wigeon
#

Pretty sure the distance should be only on the X/Z axis

dusty wigeon
# torpid swift The code I posted was using diagonal 20

I had a bit of time so I did a small script. Maybe it can help you figure out your issue.

public class Shoot : MonoBehaviour
{
    [SerializeField] private Transform target;
    [SerializeField] private Rigidbody rigidbody;
    [SerializeField] private float angle;
    [SerializeField] private float maxDistance;

    public void Execute()
    {
        //x = v * t

        //x = v * cos(a) * t
        //h = v * sin(a) * t + 1 / 2 * g * t ^ 2

        //t = x / (cos(a) * v)
        //h = v * sin(a) * (x / (cos(a) * v)) + 1 / 2 * g * (x / (cos(a) * v)) ^ 2
        //h = v * sin(a) * (x / (cos(a) * v)) + 1 / 2 * g * (x / (cos(a) * v)) * (x / (cos(a) * v))
        //h = v * sin(a) * (x / (cos(a) * v)) + 1 / 2 * g * x ^ 2 / (cos(a) ^ 2 * v ^ 2)
        //h = sin(a) * (x / cos(a)) + 1 / 2 * g * x ^ 2 / (cos(a) ^ 2 * v ^ 2)
        //h - sin(a) * (x / cos(a)) = 1 / 2 * g * x ^ 2 / (cos(a) ^ 2 * v ^ 2)
        //1 / 2 * g * x ^ 2 / (h - sin(a) * (x / cos(a))) = cos(a) ^ 2 * v ^ 2
        //1 / 2 * g * x ^ 2 / (h - sin(a) * (x / cos(a))) / cos(a) ^ 2 = v ^ 2

        Vector3 delta = target.position - transform.position;

        float distance = Mathf.Min(Mathf.Sqrt(delta.x * delta.x + delta.z * delta.z), maxDistance);
        float height = delta.y;
        float a = 0.5f * Physics.gravity.y * distance * distance;
        float b = height - Mathf.Sin(Mathf.Deg2Rad * angle) * (distance / Mathf.Cos(Mathf.Deg2Rad * angle));
        float c = a / b / Mathf.Pow(Mathf.Cos(Mathf.Deg2Rad * angle), 2);

        Vector2 planeDirection = new Vector3(Mathf.Cos(Mathf.Deg2Rad * angle), Mathf.Sin(Mathf.Deg2Rad * angle));
        Vector3 direction = new Vector3(delta.x, 0, delta.z).normalized * planeDirection.x + Vector3.up * planeDirection.y;
        rigidbody.velocity = direction * Mathf.Sqrt(c);
    }

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Execute();
        }
    }
}
jovial totem
#

How am I to go about debugging a segmentation fault. I’ve never had to debug a crash stack like this before. I think it says something about cameras.

#

I’m on a slightly older version of Unity 2022 so should I just update and hope it goes away

timber flame
#

There are a bunch of tasks in my voxel game. Also, there are some workers who do these tasks.
I want to show if a reachable path from a worker to that task exists or not.

#

From my view, flood fill is OK.
Partitioning the world to some connected areas.
Do you know better way to handle it?

odd dome
#

hello, anyone knows how to override package scripts? (if they dont have any virtual or abstract modifier)
when i attempted to edit the script, it said:

The package cache was invalidated and rebuilt because the following immutable asset(s) were unexpectedly altered: Packages/com.unity.2d.tilemap.extras/Runtime/Tiles/RuleTile/RuleTile.cs
heres my question from #🖼️┃2d-tools
#🖼️┃2d-tools message

stiff hornet
#

i think so, i havent done it in a while

#

actually i think you move it from PackageCache to the Package folder

willow sigil
#

Hi!
I am writing a test for an editor script in Unity Test Framework and come across a problem where it reset the test midway as the test enter play mode twice. And I realised the UnitySetUp is called whenever it enter playmode.
Is there a way to prevent it?

dusty wigeon
# timber flame From my view, flood fill is OK. Partitioning the world to some connected areas....

Did you try Unity NavMesh ? It is one of their supported scenario. Otherwise, standard A* star path-finding should work in most case. If you really, really, really want more performance. You could precompute each entrance-exit foreach "chunk" and then use each "chunk" as a node for your A*.

https://learn.unity.com/tutorial/runtime-navmesh-generation#
In this live training session we will learn how to work with Unity’s Navigation tools at runtime. We will explore the publicly available Components for Runtime NavMesh Building and look at how we can use the provided components to create characters which can navigate dynamic environments and walk on arbitrarily rotated surfaces, including enemies that walk on walls. In this session we will learn how to bake NavMeshes at runtime, including for procedural style levels.

dusty wigeon
# odd dome hello, anyone knows how to override package scripts? (if they dont have any virt...

Do not override package script. (Except if you really, really need to) It is not a good practice. If you want to override a package. You need to extract the whole package in your project. Copy it from the Packages Folder and then remove it from the package manager. Also, clear the PackageCache.

Alternatively, you could use a script that would contains a TileMap and instead of using directly the TileMap, you can call a function on your script which will alter the functionality. That would be a sort of "Bridge Pattern".

Example:

public class MyTileMap
{
  private TileMap map;

  public void SetTile(Vector3Int position, Tilemaps.TileBase tile)
  {
    map.SetTile(position, tile);
  }
}
timber flame
#

It is not for voxel based games.

#

So, you say a star with many workers and tasks is better than flood fill?!
I just want to know if it is reachable or not

dusty wigeon
#

Flood fill, if I understand correctly, is Breadth First Search.

timber flame
#

I don't think a star is a good way to handle this scenario.
Yes, I have implemented a star and used it to find best path

dusty wigeon
#

Breadth First Search being the worst algorithm you can do that will find the fastest path.

#

It is the most basic one.

timber flame
#

You did not get my problem I think

#

The question is not to get the best path from worker1 to task b

#

There are task1,...., task n in different positions
There are worker1,..., worker m in different positions.
Q:find is there any path from any worker to task1,..., task n

#

Isn't time consuming to run a star for each pair worker, task?

dusty wigeon
#

A* will still be better than Breadth First Search in any circumstance.

#

Yes, it is.

#

Even more if you want to find the shortest path between a Start point and N tasks.

#

But, you do not need it to be instantaneous. You can make a little animation: <Searching> for your character which could buy you a lot of time to run the algorithm.

earnest ridge
#

if MonoBehaviours are only executed in Play Mode, how come DrawGizmos work in Edit Mode?

fresh salmon
#

Unity detects that the method is implemented, and calls it.
You can have MonoBehaviour instances running in edit mode by applying a [ExecuteInEditMode] attribute on it

earnest ridge
#

Can I have the opposite?

#

or not the opposite

kindred tusk
earnest ridge
#

Can I have a script run only in Edit Mode

kindred tusk
#

Or you can write an editor script.

earnest ridge
#

or does it already happen if I only have a OnDrawGizmosSelected function for example

kindred tusk
#

What are you trying to do?

earnest ridge
#

a script only for drawing gizmos

kindred tusk
#

You don't need any checks

#

That's just how it works

earnest ridge
#

and I'm thinking how inheriting MonoBehaviour will bloat my Game assembly

#

ehh, I think I'll use handles instead

kindred tusk
earnest ridge
#

of course, but the small script only for edit mode will be too

upbeat path
#

editor only code is not included in a build

earnest ridge
#

What is editor only code?

upbeat path
#

duh, code that only runs in the editor, like OnDrawGizmos

earnest ridge
#

so the compiler is smart enough

#

ok thanks

upbeat path
#

nothing to do with the compiler, look at the unity code stripping docs

torpid swift
#

Especially when it's out of range. It can jump really far when going up and not far when it needs to go down

timber flame
hybrid prism
#

Hello
I'm using URP
Have material A with texture (binded)
Have material B withOUT binded property
So the question is how to set property of material A to B
in runtime
switching forward renderer feature?

dusty wigeon
odd dome
dusty wigeon
#

So, it has nothing to do with materials ?

hybrid prism
# dusty wigeon So, it has nothing to do with materials ?

I have normal texture on URP/Lit material
and when I overriding material NormalMapMaterial (it has no normal texture) I could set it manually, but what would I do with other URP/Lit materials?
The best solution is:
Get rendering material; Get property; Set property to override material Render

dusty wigeon
hybrid prism
dusty wigeon
#

Can you not get the current drawingsetting

#

Because I see you created a new one.

hybrid prism
dusty wigeon
#

Then what materials are you trying to get ?

#

If the GetRenderingObjectMaterial is really a function, you could potentially use Reflection to get to it. I would be surprise if it is really what you are searching.

hybrid prism
dusty wigeon
#

Then what is the material

#

Where it comes from ?

hybrid prism
timber flame
dusty wigeon
#

What GetRenderingObjectMaterial is supposed to return ?

hybrid prism
dusty wigeon
#

That is what I'm trying to understand.

hybrid prism
dusty wigeon
#

What object ?

#

Pretty sure Render Feature are kinda like postprocessing. I might be wrong.

hybrid prism
dusty wigeon
#

I mean, you do not work on the object directly. You work on the whole.

#

But, like I said. I might be wrong

dusty wigeon
hazy bear
#

Im having a hard time creating an arrow in editor window, but the problem itself is probably more related to math/rendering so maybe here I will find some help.
As you can see arrow is getting narrower with the angle between nodes increasing (or deacreasing in this case i guess). Actually arrow itself appears only in 2nd and 4th circle slices (but ive noticed that if I change indices order it appears in 1st and 3rd). I dont understand what im doing wrong here :/

#
            start = edge.GetPoints()[edge.GetPoints().Length/2 - 1];
            end = edge.GetPoints()[edge.GetPoints().Length/2];

            Vector2 lineDirection = end - start;
            Vector2 midPoint = (start + end) / 2;
            Vector2 perpendicular = new Vector2(-lineDirection.x, lineDirection.y);
            float arrowEdgeLength = 12f;
            float distanceFromMiddle = (arrowEdgeLength * Mathf.Sqrt(3) / 4);

            MeshWriteData mesh = ctx.Allocate(3, 3);
            Vertex[] vertices = new Vertex[3];
            vertices[0].position = midPoint + (lineDirection.normalized * distanceFromMiddle);
            vertices[1].position = (midPoint + (-lineDirection.normalized * distanceFromMiddle))+(perpendicular.normalized * arrowEdgeLength/2);
            vertices[2].position = (midPoint + (-lineDirection.normalized * distanceFromMiddle))+(-perpendicular.normalized * arrowEdgeLength/2);

            for(int i = 0; i < vertices.Length; i++)
            {
                vertices[i].position += Vector3.forward * Vertex.nearZ;
                vertices[i].tint = Color.white;
            }

            mesh.SetAllVertices(vertices);
            mesh.SetAllIndices(new ushort[] { 0, 1, 2 });
potent shoal
#

How can I get the position of a mouse click inside a scrollview content panel?

#

I want to position a UI item where the mouse is clicking within the scrollView.

cold hedge
#

hello there
im working on a enemy AI
that patrol on random way points
and should chase the player when get close
the patrol works fine
but it doesn't detect the player tried to debug and nothing shows in the console
here is the code for the AI
https://hastebin.com/share/dirasilapi.csharp
and the Weapon
https://hastebin.com/share/vejiqohupe.csharp

hazy bear
sly grove
potent shoal
#

All of the positions returned are happening in the screen space or world space.

#

None return a position according to the view of the scrollview.

sly grove
#

if you use Screen Space - Overlay, you have to convert it

potent shoal
#

Even using Screen space camera, it still returns the screen space position.

#

All of these clicks show the same position.

potent shoal
#

@sly groveAll of these clicks return the same position. I am trying to make my level editor inside of a scrollview, and I need to get the mouse position according to the view of the scrollview.
How can I do that properly?

sly grove
potent shoal
#

I see.

#

I tried screen to world space, as well as eventData.Position

sly grove
#

and then how are you using this position?

potent shoal
#

I am debugging it.

sly grove
#

yes but - you are saying it's incorrect. That presumably corresponds to some particular technique of positioning an object

potent shoal
#

So in the video, I demonstrate clicking in the same screen corner, with a different view on the scrollview.

sly grove
#

Are you using it to set a RectTransform's anchoredPosition?
Setting a transform.position?

potent shoal
#

I want to use this position to create a tile at that position in the scroll view.

sly grove
#

Right - note that the pointer event data contains other concepts of "position" as well. position is the screen space position

#

for a screen space camera canvas, I expect you can use the worldPosition, and then set your tile's transform.position from it

dusty wigeon
bright wind
#

If I submit a bunch of mesh data to NavMesh.UpdateNavMeshDataAsync(), while the function runs asynchronously, it still locks up the main thread while it does most of the calculation? It seems it's running the vast majority of NavMesh.TileMesh() before the frame even begins rendering? Is this just a known limitation or is there a way around this?

potent shoal
#

Thank you, PraetorBlue.
I am using

        Debug.Log(eventData.pointerCurrentRaycast.worldPosition);```
I've attached a video that demonstrates the debug log output always of roughly 9.8 on the X and -3.9 on the Y, regardless of where the scroll view is panned to.
sly grove
#

and correct

#

the point is now if you position your block there with transform.position

#

the other objects have moved

#

so positioning it there in world space and parenting it will work fine.

#

You are moving the rest of your UI when you drag

potent shoal
#

I did not realize that.

#

I see..

cold hedge
#

even this didnt work

void Update()
{
    float distanceToPlayer = Vector3.Distance(transform.position, player.position);

    if (distanceToPlayer <= chaseRange && !isChasing)
    {
        StartCoroutine(WaitBeforeChasing(2f));
    }

    if (!isChasing)
    {
        Patrol();
    }
    else
    {
        ChasePlayer();
    }

   
}
misty glade
#

https://docs.unity3d.com/Packages/com.unity.mobile.notifications@2.1/manual/index.html

Unity only supports preloaded/prescheduled push notifications. My game is multiplayer and I was hoping to be able to create dynamic notifications that could trigger somewhat on demand, even for clients who may not have activated the game in a few days. Is there any sort of solution to this? Any background processing or ability to do so? I could write a web api for the notification content, but I don't know of a way to get the app to call it in the background.

dusty wigeon
# cold hedge even this didnt work ```cs void Update() { float distanceToPlayer = Vector...

At first, it seem to me that the issue could have been a Collider Setup which does not seem like it because you remove it. I do not see anything that it could be quickly. It would require access to the code in a working environment to continue debugging.

You should try #archived-code-general or #💻┃code-beginner. They will be more inclined to help you through the whole process of debugging. Normally, you should be able to find the issue yourself. If you want to do it, there is multitude of ways of doing so.

  • Algorithm Trace
  • Logs
  • Breakpoints
  • Find the minimum working code
  • Isolate the non-working code
  • Reduce the number of parameters
  • etc.

Unfortunately, I'm only able to do a partial algorithm trace and I need to guess most of the values which make it near impossible to debug for me.

Also, you should definitely look into StateMachine/Behaviour Tree. A clean architecture helps in debugging.

bright wind
cold hedge
#

okay mate thanks
i posted in Code Beginner
im trying to debug and find a fix for like 7h now and still nothing
i will stick with patrolling until i find a way to make the AI chase or at least Attack the player

dusty wigeon
#

That is part of programming :P. Perseverance is one of the strongest qualities of a programmer. I'm sorry to not be able to help you more.

dusty wigeon
misty glade
#

The issue is also partially that I'd need to build a resilient webapi that can cache and deliver these notifications since the full connection to the game server isn't necessary or appropriate for getting this data

#

And I don't have that service in my stack yet

dusty wigeon
#

I have done Mobile Application directly from Android Studio, and I remember we had some functionalities like that we could use.

bright wind
# misty glade Yeah. That's what I'm thinking. The library I linked in the OP handles schedulin...

This just sounds like basic native push notifications - doing things like Android services for this are not ideal, and you'll have a few bits of headache trying to get stuff to run long after the user hasn't opened in a while etc - your use case sounds more like a push notification, and going that route would also fit well with "hey, I want to start a sale, let me create a notification server side and push it out to all clients" instead of having to push an app update etc

dusty wigeon
misty glade
#

Yeah, I don't particularly want to roll a service just for this. I could probably just say to the content team that they need to queue up sales and limited time events months in advance so we get the clients to connect to the server and download the notifications and schedule them ahead of time, which seems to be easy using the unity library.

#

I'm not gonna be building from android studio 🙂 Ever, if I can help it.

dire bramble
#

I have this kinda "pool" with 2500+ colored balls in it, how can i deal with performance? I tried my best but it still goes to around 15-25 fps

dusty wigeon
#

Are you struggling with the GPU or the CPU ?

#

How many draw calls you have ?

#

What is the time per physics update ?

#

What are the settings on the rigidbody of the Sphere ?

dire bramble
dire bramble
#

its just an idea that i would implement

#

if performance talking is good

dusty wigeon
#

You have 1.6k draw calls...

dire bramble
#

oh

#

lol

#

how can i fix

dusty wigeon
#

I'll find a good ressource

dusty wigeon
#

You will probably use GPU instancing.

dire bramble
#

man i just stopped at the first step lol

#

i use multiple materials for the balls

dusty wigeon
dire bramble
#

what do you mean for "use batching tool to regenerate uvs"

dusty wigeon
#

If you have multiple object with same materials but different texture. You might need to change the UV to get the correct texture if you merge the texture together.

#

But, with Unity. You just require to make an Altas.

dire bramble
#

its only a one color material

#

it hasn't textures like albedo or normals

#

normal map*

dusty wigeon
#

I think GPU instancing can handle single color.

dire bramble
#

lemme try

dusty wigeon
dire bramble
#

even with gpu instancing is laggy

#

i even tried to enable in the player settings static batching

#

same thing

#

even dynamic batching

dusty wigeon
#

How many batch do you have now ?

dire bramble
#

lemme see

#

oh just one thing

#

i even removed materials from balls

#

and its still laggy

#

same batches

dusty wigeon
#

Which mean that it failed to batch it together.

dire bramble
#

so?

dusty wigeon
#

Debug by using the Frame Debugger

#

It will say why it fails to batches together.

dire bramble
#

like i enable it and it pause the game

dusty wigeon
#

Yeah. It is expected.

#

Then you look at each draw call.

#

And see why it is not batches with the previous.

#

Something like

dire bramble
dire bramble
dusty wigeon
#

You have 91 batches

dire bramble
dusty wigeon
#

Which is fine.

#

There is nothing more you can do there.

#

What you want, is use LOD and CullingGroup

dire bramble
#

maybe i havent rendered the right thing?

#

bro i make 25 fps with the balls

#

and without 90+

#

there is a problem

dusty wigeon
#

How many balls you have ?

#

1000+ ?

dire bramble
#

yes

dusty wigeon
#

Unity is not a simulation engine.

dire bramble
#

they have 32 triangles per ball

#

not too much

dusty wigeon
#

So, it is kinda expected to have some draw back there.

#

Reduce the amount of triangles.

dire bramble
#

how can i make something like that

dusty wigeon
#

Use LOD

#

Use CullingGroup

dire bramble
dusty wigeon
#

Reduce the amount of balls

#

Make them bigger

#

Also, what is your RendererPipeline ? URP, HDRP or Built-in ?

dire bramble
#

built in

dusty wigeon
#

Use URP

#

But yeah, Unity is not made for such operation. It is going to cost a lot in performance.

dire bramble
#

How steel wool studios made that in unreal engine for Five Night's at Freddy's Security Breach

dusty wigeon
#

By profiling and optimizing.

dire bramble
#

installing urp could corrupt something of my project? and maybe could i revert it?

dusty wigeon
#

Do you use Version Control ?

dire bramble
#

because i had bad experience with hdrp

dire bramble
#

imma setup it

dusty wigeon
#

Yeah...

dire bramble
#

and then install urp maybe

dusty wigeon
#

It is a most

#

With URP, you will be able to use SRP.

#

That being said, it should be the same of instancing.

#

I would still upgrade to URP.

dire bramble
#

im making a backup atm

#

btw bro thank you for the help

#

so much

crystal parrot
#

is there any method to rotate a 2d vector?

like complex number multiplication?

#

on unity mathematics

sly grove
#
Quaternion myRotation = Quaternion.Euler(0, 0, 45);
Vector2 rotated = myRotation * someVector2;```
dire bramble
#

@dusty wigeon how can i enable the srp batcher

#

i searched over the internet and i haven't found a useful tutorial

#

unity forum is also offline

#

i installed the urp

#

everything is purple lol

vernal canyon
#

Evening guys, I've got a question about json serialization, would here be the right spot?

#

I'll ask and see I guess ^^'
So I'm pulling stuff from firebase and get I'm getting the right json. but when I deserilize, the object "data" remains empty. I've tried googling everywhere but I'm getting nothing. I would really appreciate it if you stumbled upon something like this. Here's the relevant code...

chrome wigeon
#

interesting

vernal canyon
#

There is of course no error given btw
I can give more context of course, but so far the code is this simple. I'm not assigning "data" to anything else (and debuging on this line shows that he object is never changed what so ever)
Let me know if any info could help 🙏 I'm losing my mind ^^'

chrome wigeon
#

damn what you working on

warped galleon
#

extra brace on the end there

vernal canyon
#

indeed sorry, it's a misstype

vernal canyon
# chrome wigeon damn what you working on

I have a fleet of tablets in a museum with questions about stuff in the museum. There will be some kind of live leaderboard and I need to know the current progress of every tablet

warped galleon
#

Have you tried JsonUtility just as a test?

vernal canyon
#

yes, I switched to newton by recomendation of in the forums

#

I also tried only having an int there, to simplify it as much as possible

#

(thanks for the help, I appreciate it 🙏 )

warped galleon
#

you debug data right after it is set?

vernal canyon
#

yep, it's immidietly not set, so it's not that I re-assign it after or something like that

warped galleon
#

straight debug of the convert?

vernal canyon
#

yes

warped galleon
#

pass in the string you think you're passing in?

vernal canyon
#

you mean hardcoding the json in the convert parameter?

#

I didn't try that no, I 'll do that now

#

😮 progress! so indeed, I'm now getting the "scenarioprogress" deserialized but not the simple progress (int)!

You think there is some sneaky characters in there when pulled I can't see in the debugger or log?

#

Progress should show 27

crystal parrot
#

I`m trying to create a topdown shield block system

the character is red . He is looking at blue (forward) and can block for up to something like +-30deg.

I have position of hit. How can i know if this position lies between +-30deg?

#

with unity Mathematics

#

this is what i have now but the angle is not signed ;/

#

i need signed angle too

warped galleon
#

I didn't think this was the case, but could it be order-sensitive?

vernal canyon
#

What do you mean? sorry

warped galleon
#

swap order of answersCount and progress in either the json string or the class

#

oh man I just realized lol. you havent been telling me the true structure of the json being returned, have you?

vernal canyon
#

? what do you mean?

warped galleon
#

the real json has a guid key with a SessionData value

#

that's why there were two braces in the first image

vernal canyon
#

Indeed there is a GUID as the top of the data, here's a screenshot of the firebase:
However I've sent you all that I'm getting as a return from my request!

#

I wouldn't hide stuff from you haha

#

Do you think not getting the root reference, but getting the ref from the GUID would help?

warped galleon
#

would you just paste the json in chat rather than send me images I can't copy?

vernal canyon
#

sure sorry:
{"fc124f8b562641ab84b5591023dd231556d13988":{"answersCount":0,"progress":27,"scenariosProgress":[0,66,0]}}

scenic forge
#

That's an object with a fc124... property of SessionData.

vernal canyon
#

Okay so instead of root ref I'm now getting the ref(guid).

I'm now getting the same result as with the hardcoded path! so cleaner progress! thanks a lot guys

#

the progress value is still 0, so maybe there still is an order issue like you mentionned DROD

#

Is there an easy way to enforce order when serializing/deserializing?

#

Here is the updated code: (as picture for readablility, but let me know if you need the text)

#

Result:

#

Log output:
Data fetched: {"answersCount":0,"progress":27,"scenariosProgress":[0,66,0]}

sly grove
vernal canyon
#

Okay I hoped as much! then what did DROD mean?

sly grove
#

No idea

#

that should work if that's the actual json string

vernal canyon
sly grove
#

I mean sure that might be one reason it's not working.

scenic forge
#

Also try directly logging the result of deserialized session data, rather than inspecting it in editor.

vernal canyon
#

indeed logging it shows the correct 27

dusty wigeon
# crystal parrot this is what i have now but the angle is not signed ;/

To know the side, use the cross product between the forward and direction between your character and its target.

Something like (Untested) :

Vector3 target = new Vector3(targetTransform.postion.x, 0, targetTransform.postion.z);
Vector3 player = new Vector3(playerTransform.postion.x, 0, playerTransform.postion.z);
Vector3 forward = new Vector3(playerTransform.forward.x, 0, playerTransform.forward.z);
Vector3 direction = target - player;
float side = Mathf.abs(Vector3.CrossProduct(forward, direction).y);
vernal canyon
#

so my issue was indeed getting the rootref that included in the GUID but trying to store it in a sessiondata

crystal parrot
vernal canyon
#

Thanks a lot guys 🙏 🙂

dusty wigeon
sly grove
vernal canyon
sly grove
crystal parrot
vernal canyon
#

I'll have a look around. Thanks again for the help! have a great day/night!

crystal parrot
dusty wigeon
crystal parrot
dusty wigeon
#

I'm still trying to wrap my head around lol.

#

But yeah, it is something like that. I cant confirm if you have the correct value at the correct place.

crystal parrot
#

It works now

#

but is not signed

crystal parrot
#

It gives the right result for me

#

thank you

dusty wigeon
#

Yeah, my bad. I meant Mathf.sign but wrote Mathf.abs. Mathf.abs will always return positive, it is kinda the objective of the function.

warped galleon
#

like I said once I saw, it's because of the guid string. SessionData is a nested object in the json. Doesn't match the root you're trying to deserialize into

midnight violet
raw lily
#

Hey, so I have this code that generates a wall of cubes from a width and height. As you can see in the first few lines, there's some code to leave a gap within the wall. The question is, what would be a good way to make the code that adds coords to the _ignoredCoords list?
Let's say I want a gap between 5,3 6,3 7,3 5,0 7,0 (x,y) ? (or a better way to handle this all together)
Thanks!

patent bear
#

Hey everyone, got a plugin question: Is it not possible to use a statically linked .lib as a plugin in Unity?

I have static libraries for some platforms in and working but it seems the .lib file does not show up as a valid binary to import in the inspector.

dusty wigeon
dusty wigeon
dusty wigeon
# raw lily Hey, so I have this code that generates a wall of cubes from a width and height....

I'm not sure what you are asking. What are you trying to do ?

Here are some insight:

  • Use a HashSet instead of a list. See table (HashSet being a Dictionary without values)
  • Use OOP (Oriented Object Programming) instead of dictionaries. (struct/class Wall)
  • Use Vector2Int or any specific struct to represent your data. (Primitive Obsession) https://refactoring.guru/smells/primitive-obsession

Also, we do not comment on style normally, but maybe you should review the way you are structuring/stylising your code. (usage of not useful comment, usage of var instead of explicit type, usage of single line if instead of two lines, no usage of string interpolation, usage of nested constructor/function call) - All of that being personal preference

Otherwise, there is no real "load" in the code your are showing except the Instantiate that could potentially be pooled depending on the context of usage. (At max a 100 of iterations with an handful of "miss/ignored") If you have a lot of misses AND you use a lot of similar loop (for{if(ignored) continue;}), you might want to try to model in function of what you have instead of what you ignore. But I would be surprise that it is the case.

patent bear
#

Static library

tender ingot
#

Has anyone done anything with OpenAI API with unity yet? Just looking at doing a project atm for an App using unity that uses the OpenAi but Just wondering how it went if u did do it and what kind of road blocks you faced doing so. This is purely a code based question in terms of how well it went implementing it

mild cairn
#

Hi, I need some advice
If I have an inventory item of different tiers. Basically in card games where you combine 3 cards to a 1 better card
Should I have different scriptable objects for different rarity or just one which hold all the details?

regal lava
#

Probably cleaner to keep it as a single SO and just check what variables to use when you read it.

dire bramble
vernal canyon
mild cairn
#

I extended a script but it's editor script is hiding my properties from showing up. What should I do?

midnight violet
mild cairn
#

ok thanks

random dust
#

Is there a build in way to listen for changes on a serializeField? I need to pass the change to a depending class. Since properties do not really work, and fields don't have a way to emit changed (AFAIK), I am kind of stuck. I did find this, but I was wondering for a build-in way: https://stackoverflow.com/questions/63778384/unity-how-to-update-an-object-when-a-serialized-field-is-changed

midnight violet
#

Or do you talk about an actual observer for one field?

#

Ah just read the link, you just want the equivalent as a builtin unity thing. I don`t know of any either

jovial totem
#

How do I go about diagnosing a segmentation fault?

midnight violet
#

What exactly is the error?

jovial totem
#

it could definitely be a bug

midnight violet
#

Also where do you get it, platform etc

jovial totem
#

Basically, I load a scene (editor play mode win10), and then it sometimes crashes and gives me a seg fault. Looking down the stack, it appears to originate in a UIElements call, and then somehow ends with URP rendering shadows. It happens after Start(), I think. I don't believe I am loading any UIElements on scene load, since afaik they are in a dontdestroyonload() so they dont get instantiated again

#

i havent been able to glean a whole lot of info from it other than that since it doesnt provide line numbers and a lot appears to be native

midnight violet
jovial totem
#

ive googled a lot but "segmentation fault unity" is very generic and "unity urp seg fault" doesnt do a whole lot

midnight violet
#

Even if he is talking bout linux, might be worth a shot

jovial totem
#

didnt work, unfortunately. Havent tested a build. I wonder if regenerating temps would help?

#

the top of the trace looks like this: ```
Received signal SIGSEGV
Obtained 67 stack frames
0x00007ff75e24c052 (Unity) PrepareDrawShadowsCommandStep1
0x00007ff75e2433f7 (Unity) ScriptableRenderContext::ExecuteScriptableRenderLoop
0x00007ff75d79cd89 (Unity) ScriptableRenderContext_CUSTOM_Submit_Internal_Injected

obsidian glade
midnight violet
#

Maybe just update to a newer version and see if it persists

jovial totem
#

Maybe. I’m on the latest stable release of 2022, I did update in hopes that would get rid of the bug

random dust
# midnight violet Ah just read the link, you just want the equivalent as a builtin unity thing. I ...

Ehhh, it's fine. If anybody ever finds a better way I would love to know. For now I made a property drawer.

Runtime.ObserveChangeAttribute

#nullable enable
public class ObserveChangeAttribute : PropertyAttribute
{
    private readonly string _method;
    public string Method => this._method;

    public ObserveChangeAttribute(string method)
    {
        this._method = method;
    }
}

Editor.ObserveChangeAttributePropertyDrawer

[CustomPropertyDrawer(typeof(ObserveChangeAttribute))]
public class ObserveChangeAttributePropertyDrawer : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginChangeCheck();
        EditorGUI.PropertyField(position, property, new GUIContent(property.displayName));
        if (!EditorGUI.EndChangeCheck() || !Application.isPlaying)
        {
            return;
        }

        var observeChangeAttribute = (base.attribute as ObserveChangeAttribute)!;
        var method = property
            .serializedObject
            .targetObject
            .GetType()
            .GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
            .Where(x =>
                x.Name.ToLower() == observeChangeAttribute.Method.ToLower() &&
                x.GetParameters().Count() == 0)
                .FirstOrDefault();

        if (method == null)
        {
            var fieldName = base.fieldInfo.Name;
            throw new Exception($"Method \"{observeChangeAttribute.Method}\" not found whilst invoking change on \"{fieldName}\".");
        }

        method.Invoke(property.serializedObject.targetObject, null);
    }
}
jovial totem
midnight violet
jovial totem
#

Occlusion culling …

midnight violet
dusty wigeon
dusty wigeon
jovial totem
#

i dont even know where to start removing

dusty wigeon
#

Load an empty scene.

random dust
#

Gotta say, this is quite a bit of work for such a small thing 🙃

#

Why is this not a good solution, by the way?

dusty wigeon
#

Because it creates magic, thus it is hard to maintain because it forces other user to learn a "new language" and can behave in unpredictable way. It is always why you should keep reflection low and be sure that it is explicit.

jovial totem
#

tfw your project is too big to send in the bug report

dusty wigeon
#

Also, I do not how well it is implemented and integrated in thing like console or mobile build nor how well it fares with debug tools.

dusty wigeon
hearty shoal
#

Hi, this may be a niche question, but we're using NuGet for some packages (IE BouncyCastle for cryptography). We also have some external packages we use for all our projects. Is there a way to add a NuGet dependency to a certain unity package?

upbeat path
hearty shoal
#

Hm, I figured, thats unfortunate

upbeat path
#

what you can do is use NuGet in an external solution, compile to dll and then copy those dll's to a Unity Assets/Plugins folder

hearty shoal
#

Currently we're just including the Bouncycastle DLL in the package, but was hoping for something a bit more elegant

upbeat path
#

you can cheat, create a new solution which includes the Unity csproj files, then you can add NuGet packages to the solution without being impacted by unitys sln/csproj system

hearty shoal
#

Hm, maybe I'll have a look at that

#

Thanks!

upbeat path
#

luckily MS VS sln and csproj files are not too difficult to understand and modify

astral shard
#

my brain doesnt even understand what that is

dusty wigeon
#

It is 50 ich lines.

#

It took me 1h to do.

#

So it is small

astral shard
novel meteor
#

I want to write my grid data to output to a file. (1,2,3,etc being an object placed[ID] in game, 0 empty) so its a "readable-writable" format, file that i can call/load in another scene.

[0,0,0,0,0]
[0,0,1,0,0]
[1,1,1,1,1]

(Gonna put my code in a thread, to save space)

glacial wedge
#

I added that code inside Awake

#

but it gets executed only if the entire object became disabled

sly grove
# glacial wedge

That description in the documentation is a bit suspicious. Colliders are notoriously not Behaviours and have their own separately defined enabled property.

#

I wonder if that's related.

glacial wedge
#

so, if instead of collider I would use a custom monobehaviour and it works than it's collider fault?

#

it doesn't work either with monobehaviours

midnight violet
dire bramble
#

i just opened this server and the first visible chat was that

#

sorry btw

#

i didnt even notice lol

midnight violet
glacial wedge
# sly grove I wonder if that's related.

it isn't related. the OnDisableAsObservable add a new component to the gameobject and listen for this component OnDisable. so there is no way it will fire for the disable of a specific component.

autumn locust
#

im writing a compute shader, where can i see the output of the "printf" statement from inside the shader?
it doenst appear in the unity console

sly grove
#

you have to use RenderDoc or something

undone coral
# glacial wedge

there's no eventful way to listen to a collider's change in enabled status. you can check every frame, or you can modify the code that disables colliders to disable a different monobehavior instead. that script will be responsible for the collider

sly grove
#

I tend to use color outputs and other things to creatively debug my compute shaders.

autumn locust
#

for nvidia cuda you can tho and the HLSL docu says it goes into the general information queue
EDIT: docu also says the command doesnt do anything on machines that dont support it 🤡

autumn locust
#

thanks, altough i cant figure out how to actually step through my shader, renderdoc looks promising 👍

#

shame that print doesnt work.

undone coral
velvet mirage
#

loading initial domain with user assemblies?

#

i dont understand

#

hello?

autumn locust
sterile snow
#

What are the possibilities (and limitations) of having it so Unity can read from external C# files and include them?

#

Trying to figure out how this could work with my desire to add easy modding support.

#

Wouldn't be surprised if that isn't possible (or safe) though and it demands my own scripting language and interpreter.

compact ingot
sterile snow
#

I've noticed MoonSharp is a library for exactly such purposes.

compact ingot
#

Depending on what type of scripting you need, a lisp might be a good option (where code and data are the same)

sterile snow
#

Hmm, I'll take a look-see

scenic forge
#

Are you trying to provide modding support for the general public, or is it something you expect only few people will be modding?

sterile snow
#

General public, which I'm aware will indeed mean a lot of work, but for a text adventure game (to which I've essentially went through the effort to make an engine for by hand) I figure it'll be useful to both me and others

scenic forge
#

If it’s the former, you should consider a language that’s well known and popular.

sterile snow
#

Lua seems like my bet then

#

I can tightly control the scripting environment as well and not expose a buncha shit from my bajillion C# scripts

scenic forge
#

Most languages that are suitable for scripting have libraries for embedding, you can consider things like Python too.

sterile snow
#

To my assumption, of course

scenic forge
#

Lua historical has been the scripting language of choice because it’s extremely close to just plain C code, and the runtime is tiny, both advantages are pretty insignificant nowadays.

dusty wigeon
#

I know, it might not be what you are looking for, but if you target specified people to extends your engine. Knows that there is tool available that requires nothing from the developer. https://github.com/BepInEx/BepInEx

sage tusk
#

I am in the development of a 2d top down environment. I am using netcode for multiplayer, which will only be for a few people. I have setup a network manager and added my prefab as a network prefab. My prefab has a network object component attached to it.

I have setup buttons, so that when I build and run the game I can choose between a server, host and client. I have the host on the main environment and the client on the new window that pops up.

My issue is that when my object spawns on the server side, it does not spawn on the client side as well.

My code looks like this.

Can someone help me?

scenic forge
#

If you are trying to appeal to novice programmers to mod your game, Lua isn’t exactly a popular language in comparison to things like Python JS etc. But if you expect people who mod your game to be seasoned programmers, this is then irrelevant, I’m sure they can learn whatever scripting language quickly.

#

In the end it boils down to what audience you are targeting.

sterile snow
#

As I think on it, python miiight just be the better choice

#

It's a nicer language on novices and I expect most people wanting to mod for my game are going to be novices

#

Lua might turn em away

autumn locust
#

very pleased with my pointcloud 👍

crystal parrot
#

In theory is it possible to use Equipment from one humanoid model into another? is there a way to transfer the rig?

dusty wigeon
#

Elaborate on "transfer the rig".

crystal parrot
#

i saw this

#

transfer the rig mean use equipment from vendor A character on vendor B character

#

Both humanoids but different armature

dusty wigeon
#

Use a skinned mesh for the equipment. Reassign the bones of the skinned mesh. You must use a script to reassign the bones as they are not visible in the inspector.

distant tree
#

so im trying to serialize a custom class on with a monobehaviour field in it in a script that will be saved as a prefab, but since i have to use serializereference to serialize the custom class (the classes inherit from a base class so they cant be serialized normally) when i place the prefab in the scene the references still reference the monobehaviours in the prefab instead of the instantiated object. is there anything i can do about this

crystal parrot
#

if bone are humanoids?

#

Neck is named neck_03_04 on armature 1 but neck_tst on armature 2

can i mix and match? do humanoids have this info

#

from armature bone to humanoid bone then go back from humanoid bone to the other armature bone

dusty wigeon
#

Personally, I have a script that hold reference to all the bones of my SkinnedMesh (Skeleton) on the player and an other script on my equipment (Rig Binder) which hold the name of the bones that should be use with the SkinnedMesh of the equipment. Whenever the equipment is instantiate, the Rig Binder binds on the Skeleton of the owner of the equipment.

crystal parrot
cerulean minnow
#

Can Someone help me with my script here? I'm trying to load all Correct answers and user name from firestore and use it to make a leaderboard in unity
**UPDATED WITH METHODS AT THE BOOTOM ( COMMENTS TELL WHAT DEBUGS GET TRIGGERED)
https://pastebin.com/qaK9PLDj
Please any help to get this working would be greatly appreciated

untold moth
cerulean minnow
#

I'm getting Task.IsFaulted in the last method

#
public void GetLeaderboard(Action<List<LeaderboardUser>> callback)
    {
        fireStore.Collection("Users").GetSnapshotAsync().ContinueWith(task =>
        {
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log("Error getting documents");
                Debug.Log($"Error getting documents: {task.IsFaulted} : {task.IsCanceled}"); ///ADDED THIS
                return;
            }

            foreach (DocumentSnapshot doc in task.Result.Documents)
            {
                SaveData data = doc.ConvertTo<SaveData>();
                users.Add(new LeaderboardUser { userName = data.User, correctAnswers = data.CorrectAnswers });
            }

            users.Sort((u1, u2) => u2.correctAnswers.CompareTo(u1.correctAnswers));
            callback(users);
        });
    }
untold moth
#

Does task have an error code property or something?

#

Or do you get any additional firestore errors/logs in the console?

cerulean minnow
#

so i assume i get task.IsFaulted

untold moth
#

What type is task?

untold moth
#

Plugins like that usually have some logs that they print on their own reporting the status of operations.

cerulean minnow
untold moth
#

Ok, then what type does the task have?

cerulean minnow
#

where do I look for that?

#

Oh Looks Like I'm trying to get the data in collection Users

untold moth
#

Anyways, I suggest setting the firebase logging level to verbose and looking at the console.

split sierra
#

I have a shoot em up game that looks like this, the player is the green ship and in this case the right ship is a boss, what would be the best way to make him dodge my shots?

dusty wigeon
#

To know if it is to the right or to the left, use the cross product between (Projectile,Direction) and (Projectile, Center of Boss)

split sierra
#

already did something like that but since the player can have high attackspeed (multiple bullets flying towards the enemy) i dont really know how to account for all of them

dusty wigeon
#

Use a weighted sum base on how close the bullets are from hitting the ship.

#

The side that has the maximum value is the side that should be choose

#

left <= 0
right <= 0

For every Bullets
weight <= How close the bullet is from hitting the ship
If center of the boss is to the right of the predicted path then add to the left value
If center of the boss is to the left of the path then add to the right value

Move according to the max of left and right

#

Finding the correct weight function would be the way to fine tune the behaviour.

split sierra
#

ok thanks ill try it out and let you know how it goes

sterile snow
#

Man, finding the best way to develop a prototype-based method to create entities in my game, like actors, is very tricky

#

Previously protected properties and methods can't be protected anymore if the prototype clone needs functions granted to it

cerulean minnow
# untold moth Is that not what you wanted to do?

tried this I put together from the docs and It only get the first debug

public async void GetAllDocsInCollectionAsync()
    {
        Debug.Log($"Getting All Docs In Users");

        Query allCitiesQuery = fireStore.Collection("Users");

        QuerySnapshot allCitiesQuerySnapshot = await allCitiesQuery.GetSnapshotAsync();

        foreach (DocumentSnapshot documentSnapshot in allCitiesQuerySnapshot.Documents)
        {
            Debug.Log($"Document data for document: {documentSnapshot.Id}");

            Dictionary<string, object> city = documentSnapshot.ToDictionary();

            foreach (KeyValuePair<string, object> pair in city)
            {
                Debug.Log($"All Data: {pair.Key} , {pair.Value}");
            }

            Debug.Log("");
        }
    }
#

docs example

Query allCitiesQuery = db.Collection("cities");
QuerySnapshot allCitiesQuerySnapshot = await allCitiesQuery.GetSnapshotAsync();
foreach (DocumentSnapshot documentSnapshot in allCitiesQuerySnapshot.Documents)
{
    Console.WriteLine("Document data for {0} document:", documentSnapshot.Id);
    Dictionary<string, object> city = documentSnapshot.ToDictionary();
    foreach (KeyValuePair<string, object> pair in city)
    {
        Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
    }
    Console.WriteLine("");
}
untold moth
split sierra
#

@dusty wigeon works surprisingly good, thanks 🙂

cerulean minnow
cerulean minnow
#

like didnt print anything to console

untold moth
#

If you placed it where I think you did and it didn't print, then there was probably an error thrown before that.

cerulean minnow
# untold moth Where did you add it? Share the updated code.
public async void GetAllDocsInCollectionAsync()
    {
        Debug.Log($"Getting All Docs In Users");

        Query allCitiesQuery = fireStore.Collection("Users");

        QuerySnapshot allCitiesQuerySnapshot = await allCitiesQuery.GetSnapshotAsync();

      ----->  Debug.Log($"QuerySnapshot: {allCitiesQuerySnapshot}");

        foreach (DocumentSnapshot documentSnapshot in allCitiesQuerySnapshot.Documents)
        {
            Debug.Log($"Document data for document: {documentSnapshot.Id}");

            Dictionary<string, object> city = documentSnapshot.ToDictionary();

            foreach (KeyValuePair<string, object> pair in city)
            {
                Debug.Log($"All Data: {pair.Key} , {pair.Value}");
            }
        }
    }
untold moth
#

So yeah, there's probably an error thrown before/during the log. That's why you shouldn't hide your errors...

cerulean minnow
#

maybe I should just move this data to Realtime Database , there tuts on making a leaderboard with firebase

untold moth
#

Realtime database? No clue what you're referring to, but I guess that means that we can consider the issue solved?

cerulean minnow
#

I'm trying to get all docs in collection Users , get username and correct answers from al and sort most to least

cerulean minnow
#

I'll search unity assets and see if I can buy soemthing

untold moth
#

I don't have much experience with firebase, but your issue should be fixable by simply debugging it properly.🤷‍♂️

trail cloak
#

Hello there, recently I found out that unity asset importer crashes when importing Texture2D (2D sprite format) with over 8000 sprite slices, I am wondering what's the upper limit for the slices a texutre 2d can have.

cerulean minnow
# untold moth I don't have much experience with firebase, but your issue should be fixable by ...
public async void GetAllDocsInCollectionAsync()
    {
        Debug.Log($"Getting All Docs In Users");

        Query allUsers = fireStore.Collection("Users");

        Debug.Log($"Query: {allUsers}");

        QuerySnapshot allUsersQuerySnapshot = await allUsers.GetSnapshotAsync();

       -----> Debug.Log($"QuerySnapshot: {allUsersQuerySnapshot}");

        foreach (DocumentSnapshot documentSnapshot in allUsersQuerySnapshot.Documents)
        {
            Debug.Log($"Document data for document: {documentSnapshot.Id}");

            Dictionary<string, object> user = documentSnapshot.ToDictionary();

            foreach (KeyValuePair<string, object> pair in user)
            {
                Debug.Log($"All Data: {pair.Key} , {pair.Value}");
            }
        }
    }
#

@untold moth the above debug give this error

#

look at lowest blue highlight mentions line 206

undone coral
#

can someone help me test an in-browser multiplayer feature in your browser?

undone coral
#

if you never logged in (seems likely) you are probably trying to write as an anonymous user

#

also async/await doesn't really work prior to unity 2023.1.0a14

undone coral
#

not the way you think it does

#

it's telling you what the error is

cerulean minnow
#

Do you know a lot about firebase?

undone coral
#

i know that you have to give a user, role or group permissions to read, write or modify documents

#

in this case it looks like you're reading

#

the error seems unambiguous

#

if you believe you've set up the permissions correctly, it's highly likely you are not actually logged in at the moment you make this call.

#

because of the way you are using tasks, and the other 3 errors it's printing in there, you probably are not correctly waiting for auth to complete

cerulean minnow
#

I'm trying to get all docs in a collection , sort these docs by number of correct answers and get user name and correct answers ... Making a leaderboard with firestore instead of Realtime database

undone coral
undone coral
#

did you use chatgpt to author any of this code or other code in your project, by the way?

cerulean minnow
undone coral
untold moth
#

Why do you keep on ignoring our questions?

#

You ignored me mentioning errors before too😅

cerulean minnow
untold moth
#

The error is clear, either your firebase setup is wrong or you don't authorize properly. You should check your setup on the firebase side first and if there's no problem there, look into where you authenticate.

cerulean minnow
undone coral
#

you may have set the permissions ocrrectly

#

but at the moment you call this function you may not have finished logging in

#

so 50% chance you did not set permissions correctly anyway (you probably did not use the right subject or principal or similar) and 40% chance you are not logging in before you make this call, even though it appears that you are

#

10% chance everything else

cerulean minnow
undone coral
#

gotta go!

cerulean minnow
#

I'll make a work around , I know how I'll do it

cerulean minnow
abstract hill
#

Hi everyone, I posted this in the editor extension chat last but I didn't get a response so I'm thinking I may have posted in the wrong chat.

My aim is to create an asset that lets you create rail systems, however the way I want to go about this is by playing a manager component on a mono-behaviour and then having that create the rails. The thing I would like help with is this:
I want to be able to give the user the ability to define points in world space and move them around, like a game object, without the need to actually create many game objects for this purpose. I would also like to have it work as something that sits on top / interacts separately to the main scene, kind of like how editing prefabs directly within a scene lets you grey out and show the scene they sit in.

The implementation that I want is for a component to have a button that will "enable edit mode" which will then take the user out of the main scene editing and into the "prefab mode" kind of thing, where they will be able to create and drag positions around. With potentially gizmo's rendering on top.

Does anyone have an idea on how something like this overlayed scene and interacting with positions and such without the need for actual game objects would be done? (Just to explain why I want to do this in the first place, I would like to make something that is contained and causes minimal changes to the actual game scene)

regal lava
#

How do you want to get the points? Using mouse clicks? I would then consider using a large collider potentially along the x/z axis and grabbing the point via ray cast then adding them to a list. You can probably then use some spline tool to drag them around perhaps. Not too sure about the prefab editing "scene", which is something I'd like to look into myself when I get back to developing my tool.

undone coral
#

and give permissions to modify keys that are prefixed with the userId / subject / principal (whatever they call it)

#

you can also use an aggregation / trigger / whatever they call it

#

a cloud function can be called every time a user's score is inserted

#

and then that cloud function updates the read only leaderboard doc

grave pasture
#

hey I have a question
I want to call some native functions from C standard library
dll named msvcrt
functions like file and memset and fread and etc
but i dont know if it would work inside unity and on build for android
pls clarify me?

midnight violet
novel plinth
#

whether it would work on said platforms, that's another story ☕

#

Also don't learn about this stuff on pinvoke.net ... many misleading stuffs there

glacial wedge
#

How to observe value change of custom class or single float using unirx?

untold moth
novel plinth
# glacial wedge How to observe value change of custom class or single float using unirx?

read the docs? I hate unirx due to it comes with a massive bloats

Either way easy to make your own..

    //usage var i = new VListener<SomeType>();
    // i.value += () => { Debug.Log("changed!"); };
    public class VListener<T>
    {
        private T _value;
        public Action value;

        public T Value
        {
            get => _value;

            set
            {
                if (!EqualityComparer<T>.Default.Equals(_value, value))
                {
                    _value = value;
                    OnValueChanged();
                }
            }
        }
        protected virtual void OnValueChanged() => value?.Invoke();
    }
glacial wedge
#

I already did with custom callback, but then I found unirx, and from readings it is very impactful for other programmers. So I would give a try instead of reinventing the wheel.
this is my own:

[Serializable][HideLabel]
    public class CallbackValue<T>
    {
        // così tanto zucchero da farti diventare diabetico
        public static implicit operator T(CallbackValue<T> instance) => instance.Value;
        
        public Action<T> onChanged;

        public CallbackValue()
        {
        }

        public CallbackValue(T cachedValue)
        {
            this.cachedValue = cachedValue;
        }

        public T Value
        {
            get => cachedValue;
            set
            {
                if (cachedValue != null && cachedValue.Equals(value))
                    return;
                cachedValue = value;
                onChanged?.Invoke(cachedValue);
            }
        }

        public void ForceSet(T value)
        {
            cachedValue = value;
            onChanged?.Invoke(cachedValue);
        }

        public void SetNoCallback(T value)
        {
            cachedValue = value;
        }

        [SerializeField][LabelText("@$property.Parent.NiceName")] private T cachedValue = default;
    }
novel plinth
#

yours can go south pretty easily, but it's fine bcos you're not going to use it anyway 🔥

#

you need a proper check there

#

Also the serialize thingy wont work due to System.Action, should use Unity's ones if you're planning to do so

glacial wedge
#

mmm.. it is actually working

novel plinth
#

aight, carry on!

rancid oxide
#

Can I ask here how to build a unity project on cloud through AWS CodeBuild?

kindred remnant
split sierra
potent shoal
#

Hi there. I'm working on a chess game, where I have a level editor. Here is a video of a problem I've encountered with move generation.
My code generation is pasted here: https://hastebin.skyra.pw/emetagamut.csharp

#

To explain about the issue, I am trying to make the selected piece (a bishop) only move in diagonal lines.

#

We can see though, that when selected some squares are also validated that should not be.

#

I have verified that this validation error comes from the code listed above, so my mistake is most definitely there.

kindred remnant
regal lava
#

Probably some formulated thing, but at max the bishop only has two move per row it seems

obsidian glade
potent shoal
#

@obsidian glade It is not supposed to wrap.

potent shoal
obsidian glade
potent shoal
#

It makes it a little harder, because all available information on chess is based on an 8x8 grid.

#

@obsidian gladeI see. I don't understand how, though.

blissful coyote
#

is there any reason why would unity give me all black no matter what i change the color in the material ?

sly grove
blissful coyote
sly grove
#

is it black?

blissful coyote
#

no sprite just color

sly grove
#

wdym

#

What kind of thing are we looking at

#

is this a TileMap?
A SpriteRenderer?
MeshRenderer?

blissful coyote
#

game object "quad" with a material on it to change colors from

#

and it is rotated correctly

sly grove
#

MeshRenderer?

blissful coyote
#

yea mesh rend

sly grove
blissful coyote
sly grove
#

but I'd guess you simply don't have lights

blissful coyote
sly grove
#

or no lights hitting the object

sly grove
blissful coyote
#

perp on it

regal lava
# potent shoal Yes, but it's all dynamic because it's a level editor based board.

Well, like I said there's probably some alg for it, being row-major or column related, which is probably somewhere out there on google. But, you could always do the lazy way and pattern match/check and in this case I found:

Bishop can make moves in 8 or 6 steps through the matrix indices on a 7x6 board, so if your bishop is on index 25 -> [3][4], then it would decrement to:

6 steps -> [2][5], [1][6], [1][1]```

As we can see, using 6 steps our `i` does not decrement at one of the steps, and our `j` wraps around here.
blissful coyote
#

so this is the issue ig ?

sly grove
blissful coyote
sly grove
#

so it's definitely just a lighting issue 😉

bleak edge
#

Anyone here familiar with Zenject?

I am trying to write an automated test for a class that instantiates different prefabs that are passed by a parameter, but I'm getting Assert hit! Error occurred while instantiating object of type 'Placeable'. Instantiator should not be used to create new mono behaviours. Must use InstantiatePrefabForComponent, InstantiatePrefab, or InstantiateComponent.

It's weird because my CustomFactory is already using InstantiatePrefabForComponent?

potent shoal
#

@regal lavaThank you

glacial wedge
#

unirx reactiveproperty. how to fire the observable subscription without change its value?

undone coral
#

4 player

#

if someone wants to try a new multiplayer framework click that link and join in tested

#

thanks!

left basin
#

Hi there

#

I would like to ask for a suggestion

#

I am working on a stabilizer system for my ship that moves along a track, I already implemented a PID to keep the ship hovering over a distance between the ship and the trak and also implemented a PID to keep the ship aligned to the normal vector uf the face below it by casting a ray

#

What I can't figure out however is how to keep the ship in track since there are no fences or bolliders on the sides of the track

#

So I was thinking about a system that pushes the ship to the center of the track based on some raycasts

#

But I don't know how efficien that would be

undone coral
# left basin So I was thinking about a system that pushes the ship to the center of the track...

How the arcade-like car controller was made; big sphere rolling around, car model just copies position. Raycast down to find ground normal for car. Sphere gets force based on car model direction. Tilt/wheel turning/etc. all lerps. #gamedev #unitytips

Likes

4057

Retweets

710

▶ Play video
#

you can attach something to the track and have it roll around on its surface

#

then attach a spring to that thing and your ship

#

this would also obsolete your PID... but i think you are discovering the limitations of trying to do something that isn't really physical (a hovercar track) using physics

left basin
#

Yeah, damn limitations

#

Thank you so much for this advice

#

I don't know who the ball will behave moving at 800km/h and at 3000km/h

desert panther
#

If I set up an accelerator on a server in the internet, are anyone able to access it and read my assets? I want one for my build servers but it's kinda irking me that it's accessible without an username and password

undone coral
left basin
#

I am aiming for mp with AI CPU

left basin
#

Hello there

#

I was told that using AddRelativeTorque in FixedUpdate is not the best practice, but this code works:

private void Stabilize()
{
    Vector3 headingError = Vector3.Cross(Vector3.up, transform.InverseTransformDirection(hit.normal));
    Vector3 headingCorrection = stabilityPID.Update(headingError, Time.fixedDeltaTime);
    Vector3 torque = (headingCorrection * 3000f) * stabilityMultiplier;
    rb.AddRelativeTorque(torque, ForceMode.Force);
}
#

Then I decided to just use AddTorque and came out with this code:

private void Stabilize()
{
    Vector3 headingError = Vector3.Cross(transform.up, hit.normal);
    Vector3 headingCorrection = stabilityPID.Update(headingError, Time.fixedDeltaTime);
    Vector3 torque = (headingCorrection * 3000f) * stabilityMultiplier;
    rb.AddTorque(torque, ForceMode.Force);
}
#

The problem with the second code is that the ship at some point start to slowly rotate to the left

#

and I don't know why

#

This is the PID class

using UnityEngine;

[System.Serializable]
public class Vector3PID
{
    public float pFactor, iFactor, dFactor;

    private Vector3 integral;
    private Vector3 lastError;

    public Vector3PID(float pFactor, float iFactor, float dFactor)
    {
        this.pFactor = pFactor;
        this.iFactor = iFactor;
        this.dFactor = dFactor;
    }

    public Vector3 Update(Vector3 currentError, float timeFrame)
    {
        integral += currentError * timeFrame;
        var deriv = (currentError - lastError) / timeFrame;
        lastError = currentError;
        return currentError * pFactor
            + integral * iFactor
            + deriv * dFactor;
    }
}

glad badger
#

never mind, found my answer, Its not anymore 🙂

lament salmon
#

Why would that be bad practice

left basin
#

I was told that

autumn locust
#

its physx and it belongs in FixedUpdate

#

if you call your above method in normal update, it gets executed based on framerate, which leads to unwanted behaviour. maybe thats where your issue comes form

left basin
#

Probably, I alwayys call those functions from FixedUpdate

#

But I can't understand why ot works fine one way and not the other way because in theory it's the same

green bison
#

Is there a channel here to hire people?

sly grove
thorn flintBOT
bleak edge
kindred tusk
#

They have a gitter you can ask in

#

There was a whole drama where the author of zenject lost the rights to maintain zenject after leaving his employer, Modest Tree, you can read about it in a blog post somewhere

#

Anyway, I'd def wanna be on latest extenject before looking for fixes for what may be a bug

#

Then you can ask their gitter for support.

#

All these projects look dead actually.

#

Does anyone know how to debug these? Getting spammed in editor, but none of our code is using jobs/native arrays so it's presumably coming from a plugin.

#

I guess it tells me how to debug here. Does that mean to launch the unity editor with a flag?

#

Ah, I see! nvm. I can add CLI args in unity hub

leaden lotus
#

How do you install this

#

Trying to do it as stated in the manual doesn't work

#

Says there is no package with that name

glacial wedge
#

Hi @novel plinth,
after 2 days of unirx I found more bugs than help, and this are bugs reported in the git issue from years... with even a proposed solution that haven't been implemented. (just an example: https://github.com/neuecc/UniRx/issues/314).
I'm sad because I like the rx approach.
You are totally right in hating unirx.

GitHub

Reactive Extensions for Unity. Contribute to neuecc/UniRx development by creating an account on GitHub.

#

I didn't explore the microcoroutine part... It seems super cool, but if it has the same problems of the rest it isn't even worth a try

novel plinth
#

UniRx isn't being maintained anymore by the creator

#

the creator made a new account tied to his new company called CySharp

#

the same dude who created UniTask and MagicOnion

novel plinth
#

which essentially what UniTask does unde the hood

glacial wedge
#

what you mean with customYield?

glacial wedge
#

oh, it's a way to implement yield return similar to waitwhile and waituntil

surreal sphinx
#

is this just a recursion technique?

random dust
#

Pretty sure it's all part of base c# and you could add a custom enumerator yourself

#

And I don't think it's recursive. I assume Unity has a build in state system that checks each frame if the predicate defined in those yield instructions have passed, and it will then call MoveNext() on it.

surreal sphinx
#

it just seemed like it yield returns a new instantiation of itself

random dust
#

No, just that yield instruction. I'm not sure why you would create a new instance constantly. I think you can just make a single instance and reuse that, unless there is more behaviour to it

#

So you can probably actually just reuse the same instance

surreal sphinx
#

the example i looked at . . i didnt notice the different case

#
public IEnumerator waitForMouseDown()
    {
        yield return new WaitForMouseDown();
        Debug.Log("Right mouse button pressed");
    }```
#

its just calling this:

public class WaitForMouseDown : CustomYieldInstruction
{
    public override bool keepWaiting
    {
        get
        {
            return !Input.GetMouseButtonDown(1);
        }
    }

    public WaitForMouseDown()
    {
        Debug.Log("Waiting for Mouse right button down");
    }
}
kindred tusk
surreal sphinx
random dust
#

They're two completely different things though

#

Top one is the actual "Coroutine", whilst the bottom one is a yield instruction that can be used within

#

The Coroutine should also be capitalized but I'm guessing that wasn't done to avoid a conflict in shitty naming

carmine hinge
#

if i want to make an easily moddable game / one that encourages modding, should i just use mono or make a custom modding framework and have my game il2cpp

cerulean minnow
#

How can I get a count of all docs in Realtime database?

kindred remnant
undone coral
#

once you are writing custom yield instructions, you can use the better authored ideas in unitask / unirx and the utilities there

#

it is also hard to represent UX imperatively at this low level

#

you are also using old input system which will make this much harder

undone coral
#

i suppose you can join him... it sounds like you want to trigger things when components enable and disable

#

we discussed this

#

it's a code smell

glacial wedge
#

no, he wanted to dispose when the script gets disabled, like the description of AddTo say. but it dispose when the gameobject gets disabled

undone coral
#

it doesn't do either of those things

#

he wanted to dispose when the script gets disabled
that is a code smell

#

if he wants to do something when a component is OnDisable he can put it in that callback

#

AddTo does what it says it does

#

"blissfully unaware" indeed

#

no offense to that ticketer

#

if you want a helper for OnEnabledStatusChangeAsObservable, author it

#

it cannot be authored in an evented way for a target component. we discussed this. it has to check every frame

#

it should be obvious why - you can only do it in an evented way by writing something in OnEnable and OnDisable, which you can't peak into from another component

#

BUT it's a code smell

#

@glacial wedge do you see what i am saying?

glacial wedge
#

i'm reading...

undone coral
#

or i suppose you can throw your arms up and you know, use Built in Render Pipeline and Amplify Shader Editor

#

just think it through. how would you implement this callback without using every frame?

#

DisposeWhenComponentDisabled(Behaviour targetComponent) or DisposeWhenComponentDestroyed(Component targetComponent)

#

how can a script "add something" to another script's OnDisable or OnDestroy, if the script is a black box?

#

it can't

glacial wedge
#

no, it can't ofcourse

undone coral
#

it can only check every frame. but that should be telling you it's a code smell

#

a game object is a container, not a component

#

the association between components is a game object

#

that's what the unity architecture is

#

if you want to destroy things together, you know, you put them on the same game object and destroy the game object

#

it doesn't make sense to dynamically add and remove components most of the time (that is a little code smell), and it really doesn't make sense to "add behavior" at runtime that needs to be coupled to the lifetime of a specific other component on the game object. those things are just tightly coupled together

#

anyway

#

it's your prerogative

#

this is the worst example of an issue with unirx

#

it's not a tool for people to write smelly blub code

#

I'd prefer not to deal with adding/removing trigger components. They take up space in the inspector and their full behavior is inherent in the code we have to write to call them
i mean listen to this guy

#

the thing that guy is doing makes so little sense

#

if you have a real bug you should ticket it

undone coral
#

also, this is a DOTS package

glacial wedge
#

it is still a dead repo

undone coral
#

this isn't web development

#

that heuristic doesn't apply

#

it's your prerogative

#

you are so close to ascending. you said it yourself, you like this

#

You're Not In Web Development Anymore

#

i have been using unirx for years, and i have written exactly two extensions (Window and tweaks to Throttle) + fleshed out the reactive collections. i have not yet encountered a bug

#

you can even see the issues i did ticket

#

okay, i also authored the unitywebrequest extensions which he merged

#

that's it

glacial wedge
#

yeah, it's a bad mentality but when the documentation is misleading and there is no support from years become an insecure way to proceed. It could give me to unundestandable bugs

#

It say behaviour and seems attached to this component when in reality it happen on gameobject

undone coral
#

it also has random parentheses in it lol

#

the guy is ESL

#

i don't know

glacial wedge
#

you are right on black box..

undone coral
#

you can't use this to blub code

#

elsewhere in the docs for observableenabletrigger it's clear that it means the gameobject

#

and Component doesn't have enabled

#

only Behaviour does

#

it sounds like you had this one issue

#

i wouldn't let it get you down

#

i am saying this docs issue is real

#

i agree with you

#

but if docs are getting you down

#

why are you using unity lol

#

have you seen the unity docs

glacial wedge
#

I had another bug about the OnEnable, the callback was called only if the gameobject were disabled and reenabled.... I didn't lost too much time on it because ofcourse the callback was set after the first onenable caused by the random execution order of awake

undone coral
#

OnEnable and OnDisable was a mistake

hardy sentinel
#

my first exp was with Lumberyard... switching to Unity was a blessing lol

scenic forge
#

It's not terrible, but I also wouldn't call it great either.

hardy sentinel
#

what docs would u consider great? except microsoft's

#

thought so :p

fair hound
#

Is there a way to strip a class of its functionality to use it as a buffer for its variables? I have a system where I want to enable the configuration of multiple instances of different classes, but I don't want to have to pass down tons of duplicate variable names.

#

Like for example I have a wheel class, this class has a Build() method that creates gameobjects and adds components in the scene using its own variables, and a Mount() method which configures those newly created things. The problem is that some values are shared while others are not, so I feel like I would be weighing the system down by creating a full dummy object to hold my values.

fresh salmon
#
public class Sample
{
    // stuff here
}
fair hound
#

huh

regal lava
#

Container class

fresh salmon
#

A class whose only purpose is to store data. Does not inherit from anything, does not implement interfaces. Can't get more barebones than that

fair hound
#

is there a convention for naming these?

#

I guess if I nest them in the class theyre for I can name them all the same thing

#

alright, thanks

fresh salmon
#

If you plan on using that class outside of the one it's nested in, it should be in its own file

fair hound
#

why

#

then im just accessing it via classname.containername.variable

fresh salmon
#

Conventions? So you don't have to type the full name all the time

fair hound
#

well it needs to be different for each object

fresh salmon
#

Will it be used outside of said object?

fair hound
#

well ill be using it from the config, then ill pass it down back to the object during assembly

fresh salmon
#

From the config? Assembly?

fair hound
#

In my current situation its for a car

#

so I need stuff like wheel radius, depth, etc, and all the car dimensions so It knows where to put them and how to configure the components attached

#

currently all those public variables are separately declared from the objects they represent

#

which is causing me a lot of running around

#

but yeah ill try this container class thing

fresh salmon
#

You can mark the container class with a [Serializable] attribute so it shows in the main script's Inspector. You'll be able to collapse it, which will free some space

#

Pretty much what happens with the Suspension field here

fair hound
#

is there a way for me to force implementation of a nested class via inheritance or interface?

fresh salmon
#

No

scenic forge
# hardy sentinel what docs would u consider great? except microsoft's

What I consider great would be that docs can serve as primary material and cover vast majority of what you need, including not just basic usage but higher level things like architectural, best practices, and even trouble shooting common questions, to the point where you mostly don't need to go to third party sites bar very advanced things.
Off top of my head, Vue and Svelte's are both done very well, and as you mentioned, Microsoft's C# docs are excellent (albeit somewhat disorganized). Unity fails at this, it's very much a documentation with one flimsy example if there even is one; often you have to resort to Googling to obtain most of the information. This is not a dig at Unity specifically, most things don't have docs to that level, and not everything is great. If everything was great, that's just the average.

hardy sentinel
#

If everything was great, that's just the average.
Yeah that's where I was going 😄 My general exp with documentations makes me feel Unity docs are great. Haven't checked Vue or Svelte's tho tbf, but hadn't had too many complaints from Unity's docs

scenic forge
#

Unity's docs are far from the worst, well besides content wise, most of my complains about Unity's docs are simply the website itself being very poor.

#

Searching on Unity's docs site is so bad and slow that using Google to search is faster; except Unity's docs also don't index well on Google, especially that you have to change Unity version with every link you click.

fresh salmon
#

And most of the time when you change versions, it puts you back to the homepage

flint sage
#

I think they improved that recently in the newer versions

hardy sentinel
#

thankfully that's fixed yeah 😆

scenic forge
#

Some pages are also practically unusable, eg math class in Unity.Mathematics with all the methods and overloads, that page (at least last time I checked it) would take a ridiculous long time to load and prone to crashing, as well as near impossible to navigate.

hardy sentinel
#

oh yeah the 'new' docs NotLikeThis

#

literally contains nothing useful lol -- except that it's wip (ok and well that it's similar to SIMD and graphic/shaders math api)

scenic forge
#

Tbf, most of those methods in math are very self explanatory.

fresh salmon
#

To signify that these types are bultin their type names are in all lower case.
Will they ever stop butchering every existing naming convention lol

#

Also that lowercase namespace name

hardy sentinel
#

when u take sl conventions too far

fresh salmon
#

In C# int and float are considered builtin types.
Yeah but these are aliases to Int32 and Single, which are properly named, so why, just whyyy

scenic forge
#

I assume all the name convention violations, and I guess most of the questionable things in Unity (like overriding ==) are historic artifacts back when Unity was supporting not just C# but also UnityScript and Boo

hardy sentinel
#

still it's pretty cool that they made this compile 😄 I was happy enough to never care about the docs in this case anyway lol

scenic forge
#

I wish Unity could start over and rid these mistakes, but that's a pipe dream.

hardy sentinel
#

how do you guys feel about URP/HDRP?

#

I sometimes wonder what wonders could've been done in the engine if these 2 projects weren't approved

#

not saying they're not useful.. just not to me, and kept thinking about it

scenic forge
#

Don't think I'm qualified to give an opinion regarding those, I've only used the very basics of URP and it works fine for what I need.

#

Well, there's always the "here's our 3 rendering pipelines, 3 UI solutions, etc" meme.

fresh salmon
elfin tundra
#

is it ok to yield return in a coroutine from inside a foreach loop? it seems that is causing problems for me and i'd like to make sure that isn't the root of the problem.

#

to clarify, the array i am looping over with the foreach loop contains no null values before the loop, but after the first yield return inside the loop, it suddenly contains null values, but i am not altering anything inside the loop.

fresh salmon
#

Switch to a for loop, and see if you can reproduce the issue. Yielding in a foreach loop should not cause any issues

elfin tundra
#

yeah i didn't think it would be the issue, i'll try that and report back

fresh salmon
#

foreach is just an elaborated while loop after all, it compiles to one

elfin tundra
#

still have the issue, but i have an idea what might be happening so i'm checking that first

#

hmm that wasn't it

#

well if i remove the yield return it doesn't give me the error and the array remains intact

#

@fresh salmon

fresh salmon
#

Error? What's the error about?

elfin tundra
#

it doesn't always occur but when it does it's a null reference exception

#

and it seems that the null reference is the iterator variable from my for loop

#

as in collider in foreach (Collider collider in colliders)

fresh salmon
#

Can you try with

var e = colliders.GetEnumerator();
while (e.MoveNext())
{
    Collider collider = e.Current;
    // contents of loop go there
}

Essentially the compiled version of foreach. Then place a breakpoint and step through line by line, inspect the contents of the variables

elfin tundra
#

i doubt that will work bc the stack trace for the error says something about MoveNext

#

i'll try setting breakpoints with my current code

fresh salmon
#

Depends on which MoveNext it's talking about, because there's two. One that iterates the foreach loop, and another that the compiler generates for your iterator method (which is translated to a full class), called by whatever runs the iterator

#

If the class name is really weird, then it's the iterator's MoveNext throwing

elfin tundra
#

ah i see

#

ok i'll try what you suggested

#

ok lots of weird things are happening so i think this is most likely a result of a series of other less related bugs in my code so i'm gonna go find those first

#

sorry to bother you

elfin tundra
#

@fresh salmon fixed it, turns out the issue was i was assuming that destroy would destroy the object immediately but in reality it isn't actually destroyed until the end of the frame

#

so i added yield return new WaitForEndOfFrame(); after calling destroy and it works now

shrewd bear
#

Does anyone know what this error is trying to tell me:

NullReferenceException
  at (wrapper managed-to-native) UnityEngine.CanvasRenderer.get_cull(UnityEngine.CanvasRenderer)
  at UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.Canvas canvas, UnityEngine.Camera eventCamera, UnityEngine.Vector2 pointerPosition, System.Collections.Generic.IList`1[T] foundGraphics, System.Collections.Generic.List`1[T] results) [0x00021] in <e0bc12d6d4684ff9a2af6711575bbd24>:0 
  at UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] resultAppendList) [0x00272] in <e0bc12d6d4684ff9a2af6711575bbd24>:0 
  at UnityEngine.EventSystems.EventSystem.RaycastAll (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] raycastResults) [0x00030] in <e0bc12d6d4684ff9a2af6711575bbd24>:0 
  at UnityEngine.EventSystems.PointerInputModule.GetMousePointerEventData (System.Int32 id) [0x00090] in <e0bc12d6d4684ff9a2af6711575bbd24>:0 
  at UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent (System.Int32 id) [0x00000] in <e0bc12d6d4684ff9a2af6711575bbd24>:0 
  at UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent () [0x00000] in <e0bc12d6d4684ff9a2af6711575bbd24>:0 
  at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00032] in <e0bc12d6d4684ff9a2af6711575bbd24>:0 
  at UnityEngine.EventSystems.EventSystem.Update () [0x000b7] in <e0bc12d6d4684ff9a2af6711575bbd24>:0 
thick peak
#

Something in a raycast is giving a null result but then trying to do something with it as if it's not, by the looks of it.

shrewd bear
thick peak
#

Seems so since it's on a Canvas.

shrewd bear
#

God I wish I could figure out what triggers it. Only seems to happen in windowed mode build.

thick peak
#

Hm.

#

What are you doing when it happens?

shrewd bear
#

I think it has happening after I do an attack pressing a key or mouse button

#

I thought it was going to be the floating text for damage, but this seems to not be that.

thick peak
#

Do you have any other UI events firing on an attack?

shrewd bear
#

Nothing else uses the input for the attacks. Other then the inventory, which uses the ipointer events for drag and drop

#

But the inventory isn't open when this happens

thick peak
#

Did the error only just start happening or has it been present for a while?

shrewd bear
#

Only just noticed it.

#

It's very hard to make it happen, so I don't know if it has been around for a while

#

But when it goes off, it kills the FPS

thick peak
#

Ah, okay. Reason I asked was that if it were a recent thing it might be traceable to something you just added, but if you can't be sure about that it could be anything.

shrewd bear
#

Yeah. It doesn't seem to happen in editor testing, so it may have flown under the radar

untold moth
thick peak
#

Oh, good shout.

shrewd bear
#

I have a canvas on monsters/players for displaying hp bars etc

untold moth
#

And it's probably destroyed at some weird timing. Like during a pointer event handling.

shrewd bear
#

When they go out of range they get destroyed

untold moth
#

Or something like that. Since the event system tries to raycast to it, but it seems to be null at that point

#

Assuming that's really what's happening

shrewd bear
#

From the object with the cavnas for line of sight

untold moth
shrewd bear
#

And dist

shrewd bear
#

Which is wrapped up on the network logic

untold moth
#

Is it destroyed via an rpc or something?

shrewd bear
sterile snow
#

So I'm working on modding support for my game through Lua and MoonSharp, but some assets modders will need to make are inevitably going to be Unity assets (such as animator controllers). Is it possible to fetch Unity assets like this during runtime with a file path?

shrewd bear
#

Hang on the method is to big to not be txt file

untold moth
#

Use a paste site

shrewd bear
#
//If to destroy.
            if (destroy)
            {
                MonoBehaviour.Destroy(nob.gameObject);
            }
#

This is a network call from the server.

#

But I think you may be on to something with the Canvas and the raycast

#

I do have an idea where to look

#

I just wish I could trigger it reliably to know if it is fixed.

untold moth
shrewd bear
#

It is probably happening here.

private IEnumerator UpdateVisiblity()
        {
            while (true)
            {
                yield return _wait;
                if (Vector3.Distance(_cameraTransform.position, transform.position) > ViewDistance
                    || Physics.Linecast(_lineOfSight, _cameraTransform.position))
                {
                    SetCanvasVisibility(false);
                    continue;
                }               
                SetCanvasVisibility(true);
            }
        }
untold moth
#

Nah, that's a physics cast. I don't think it's related

shrewd bear
untold moth
shrewd bear
#

Well I really should move the canvas off the gameobjects anyway and just have one canvas get updated to display player name and hp bar.

#

This may just make me do it sooner.

dusty wigeon
sterile snow
#

I was thinking the same. So AssetBundle it shall be.

thorny whale
#

I'm not sure if its possible to build AssetBundles outside of the editor though. Unless you know the format of the file?

karmic surge
#

I am only asking if it is possible,
but Assuming I launching an application from within unity, (and that application tries to read the camera)
is there a way to direct a unity camera to that application, instead of it trying to read from the laptop camera?

untold moth
karmic surge
thick peak
#

dlich, crushing people's dreams since 2019.

untold moth
#

I mean,it's not entirely impossible. Just not they way they want to achieve it.

ancient rivet
#

I have a post processing volume override that I want to modify with code.
However, the code below is returning a Component with a null material:
GetComponent<Volume>.sharedProfile.TryGet(out s)

I can see the effects of the component in the game, so there's a component out there somewhere with a material. How do I access it?

lament salmon
#

Where exactly are you trying to get the material from?

ancient rivet
#

I am using the existence of the material as a kind of proof that I have the correct component. The type of s is Shockwave, a custom post process order that I have @lament salmon

#

public sealed class Shockwave : CustomPostProcessVolumeComponent, IPostProcessComponent

#

m_Material is being populated automatically by HDRP

#

I can see it when debugging

karmic surge
ancient rivet
#

But I can't seem to access it in a monobehavior

lament salmon
untold moth
ancient rivet
warped galleon
lament salmon
untold moth
#

Hack some app and substitute the camera input👀

ancient rivet
karmic surge
lament salmon
#

Sorry not much to work with here so its all I can think of.

ancient rivet
#

I can also put a breakpoint inside of Shockwave.cs Render and see the correct material.

#

It's almost as if TryGet is returning some kind of empty copy

#

In the debugger, it does have the word (Clone) in parens Shockwave(Clone)

warped galleon
untold moth
lament salmon
#

@ancient rivet Alright so I just tried to replicate your issue in my own project.
End result: It also prints null for me

#

Even though the PP effect itself works fine

ancient rivet
#

@lament salmon are you saying you were able to reproduce the issue?

ancient rivet
#

So, what can we do?

lament salmon
#

What are you trying to do though? Why are you accessing the material directly?

ancient rivet
#

Well, so I can load the shockwave positions and times for any explosions occuring dynamically on screen

#

It looks really sweet, when I input it from the Unity Editor

#

but it needs to come from code

lament salmon
#

I believe it has something to do with that HDRP has to instantiate the material for every camera, so there's no "one instance" to access, I could be wrong though

untold moth
ancient rivet
#

I mean, somehow people pass dynamic uniforms into shaders, right?

lament salmon
#

But in any case, you are not really supposed to access the material directly, but use the ColorParameter, FloatParameter etc. variables inside your post processing effect

ancient rivet
#

Yes, yes, I am only using the material as an indicator of the issue

#

Because, the real issue is, it's a different instance. Setting its properties has no effect

#

try it on your machine

lament salmon
ancient rivet
#

no, I am talking about the VolumeComponent, Shockwave

untold moth
#

Can you share the whole script?

ancient rivet