#archived-code-advanced

1 messages ยท Page 67 of 1

fickle sapphire
#

The first two dodges are going forward, the third is to the side

#

the first two dodges hit their target perfectly, however the third goes way off course

fickle sapphire
#

play the video

dusty wigeon
#

In the video, or always ?

fickle sapphire
#

sorry

#

in the video I meant

dusty wigeon
#

What is different ?

fickle sapphire
#

Nothing as far as I can tell in my code

#
            float deltaForward = this.rootMoveCurveForward.Evaluate(t) * this.rootMoveImpulse;
            float deltaSides = this.rootMoveCurveSides.Evaluate(t) * this.rootMoveImpulse;
            float deltaVertical = this.rootMoveCurveVertical.Evaluate(t) * this.rootMoveImpulse;

            Vector3 movement = new Vector3(
                deltaSides - this.rootMoveDeltaSides,
                deltaVertical - this.rootMoveDeltaVertical,
                deltaForward - this.rootMoveDeltaForward
            );

            movement += Time.deltaTime * rootMoveGravity * verticalMovement;

            if (characterLocomotion.character.TryGetComponent(out PlayerCharacterNetworkTransform networkTransform))
            {
                // TODO make this not use the local player's rotation, but rotate to the target direction
                //movement = characterLocomotion.character.transform.rotation * movement;
                Vector3 direction = networkTransform.currentPosition - networkTransform.transform.position;
                direction.y = 0;
                direction.Normalize();

                Quaternion viewDirection = Quaternion.LookRotation(direction);

                movement = viewDirection * movement;
            }
            else
            {
                movement = characterLocomotion.character.transform.rotation * movement;
            }

            characterLocomotion.characterController.Move(movement);

            rootMoveDeltaForward = deltaForward;
            rootMoveDeltaSides = deltaSides;
            rootMoveDeltaVertical = deltaVertical;```
dusty wigeon
#

Then, why 2 on 3 works ?

fickle sapphire
#

this is the whole function

fickle sapphire
dusty wigeon
#

Then, use my script.

#

And then adapt it.

#

But first, make it work.

#

Same if there is nothing else then a character an a target.

fickle sapphire
#

I'm adapting rn

dusty wigeon
#

This is a method of debugging. You start with what works and goes towards what you want.

fickle sapphire
# dusty wigeon This is a method of debugging. You start with what works and goes towards what y...

same result still

protected void UpdateRootMovement(Vector3 verticalMovement)
        {
            float t = (Time.time - this.rootMoveStartTime) / this.rootMoveDuration;
            float deltaForward = this.rootMoveCurveForward.Evaluate(t) * this.rootMoveImpulse;
            float deltaSides = this.rootMoveCurveSides.Evaluate(t) * this.rootMoveImpulse;
            float deltaVertical = this.rootMoveCurveVertical.Evaluate(t) * this.rootMoveImpulse;

            Vector3 movement = new Vector3(
                deltaSides - this.rootMoveDeltaSides,
                deltaVertical - this.rootMoveDeltaVertical,
                deltaForward - this.rootMoveDeltaForward
            );

            movement += Time.deltaTime * rootMoveGravity * verticalMovement;
            
            characterLocomotion.character.TryGetComponent(out PlayerCharacterNetworkTransform networkTransform);

            Vector3 direction = networkTransform.currentPosition - networkTransform.transform.position;
            direction.y = 0;
            direction.Normalize();

            Quaternion viewDirection = Quaternion.LookRotation(direction);

            movement = viewDirection * movement;
            characterLocomotion.characterController.Move(movement);

            rootMoveDeltaForward = deltaForward;
            rootMoveDeltaSides = deltaSides;
            rootMoveDeltaVertical = deltaVertical;
        }
dusty wigeon
#

Not from things that does not work.

#

Start a new scene.

#

Place a cube and a target.

#

Then try it.

#

It it works

#

Go next step

#

If it does not.

#

Maybe there is something I did not understand correctly.

#

I do not want see anything about PlayerCharacterNetworkTransform or characterLocomotion or rootMoveCurveForward.

tropic stag
#

I'm trying to get the position that unity cursor is at in this screenshot. The game object "k_u", like all the other keys, are from a keyboard model split in blender so they're all rendered at the same localposition (0,0,0), but display at the appropriate places because I think the meshes are offset off their original origin. I'm trying to place another object at this exact spot, but example.position + key.GetComponent<Renderer>().bounds.center + key.transform.position isn't it. Anything else I can try? (Also tried local position since the example transform is parented at the same parent)

sly grove
tropic stag
sly grove
#

A quick saunter over to the docs could cure that ๐Ÿ˜‰

tall ferry
#

Im trying to rotate my character and controls based on gravity, treating it kinda like the entire world rotates but am really stuck on the math. The player hips and camera is supposed to rotate so it aligns with the world after the gravity shift. The player is supposed to look where the camera does.
https://paste.ofcode.org/7ghK96TR8hXnjdjUtHsU6
For the code: GetRotation() is used to copy rotations from an animator to my joints and this works already. lines 28-32 arent important, its just for other body parts. I only need this extra gravity and camera rotation to apply to joints[0] which are the hips.
I know why this doesnt work, because i am using the Y rotation from the camera newRotation *= Quaternion.Euler(0, -input.LookRotation.y, 0); . When gravity shifts, the camera shifts, and Y no longer makes sense. When im sideways I assumed I could just use the X or Z rotation instead... but i have no idea how id actually calculate this based on gravity.

I did manually figure out that with gravity (-9.81, 0, 0) i could use
newRotation *= Quaternion.Euler(input.LookRotation.z + 90, 0, 0);
and (9.81, 0, 0) i could use
newRotation *= Quaternion.Euler(-input.LookRotation.z + 90, 0, 0);
but this doesnt allow me to apply gravity in any (x, y, z) like (-5, -5, 0) since I cant just precompute every combination. I also solved these rotations through brute force, so I dont fully understand them.

So my question is, how can I calculate what to rotate my players hips by so it looks based on the correct axis?

dusty wigeon
# tall ferry Im trying to rotate my character and controls based on gravity, treating it kind...

You want to change your coordinate system. Here some video that explain the topic. I tried my best, but could not come up with a good explication...

https://www.youtube.com/watch?v=P2LTAUO1TdA
https://www.khanacademy.org/math/linear-algebra/alternate-bases/change-of-basis/v/linear-algebra-change-of-basis-matrix

How do you translate back and forth between coordinate systems that use different basis vectors?
Help fund future projects: https://www.patreon.com/3blue1brown
An equally valuable form of support is to simply share some of the videos.
Home page: https://www.3blue1brown.com/

Future series like this are funded by the community, through Patreon, w...

โ–ถ Play video
#

In pratice, it just mean to use Transform.InversePoint or Matrix4x4.TRS(...).inverse.Multiply3x4(point);

tall ferry
#

ive studied change of basis in uni before, ill see if I can use this thanks

#

I guess it is changing the coordinate system, but i might just leave this feature to work upside down only because i didnt think this would be so math heavy :p

dusty wigeon
#

Then you should be able to navigate this pretty easily, I'm like 90% sure this is what you want.

dusty wigeon
tall ferry
#

it does make sense to use this, i only need to use it to change which way the player is rotating and like which way I am limiting the players speed

sand acorn
#

Hello there, I am trying to learn how to use the MeshData API but can't find any good examples of it, so right now I am struggling with this, I am triying to set the position of the vertices on the variable TestVer but the array lenght is always 1 and not 4 as the vertex count so I can only accesstestVer[0]and not other values, am I missunderstanding how this works or am I missing something?

#

Here is my code

       Mesh mesh = new Mesh();
        mesh.name = "chunk";

        vertexAttributes[0] = new VertexAttributeDescriptor(VertexAttribute.Position, dimension: 3);

        vertexAttributes[1] = new VertexAttributeDescriptor(
            VertexAttribute.Normal, dimension: 3, stream: 1
        );
        vertexAttributes[2] = new VertexAttributeDescriptor(
            VertexAttribute.Tangent, dimension: 4, stream: 2
        );
        vertexAttributes[3] = new VertexAttributeDescriptor(
            VertexAttribute.TexCoord0, dimension: 2, stream: 3
        );

        //Set vertex buffer 

        meshData.SetVertexBufferParams(vertexCount, vertexAttributes);

        //Define a submesh
        meshData.subMeshCount = 1;
        meshData.SetSubMesh(0, new SubMeshDescriptor(0 , triangleIndexCount, MeshTopology.Triangles));
        vertexAttributes.Dispose();

        //Set vertex positions (should depend on vertex count) but lenght is always 1 (vertexCount variable is 4)

        NativeArray<VertexData> testVer = new NativeArray<VertexData>(meshData.GetVertexData<VertexData>(), Allocator.TempJob);

        var pos = testVer[0];
        var pos1 = testVer[1];
        var pos2 = testVer[2];
        var pos3 = testVer[3];

        pos.Position = 0;
        pos1.Position = math.right();
        pos2.Position = math.up();
        pos3.Position = new float3(1f, 1f, 0f)
limber snow
#

is there any sample from. unity about to use addressables + scriptable?

dusty wigeon
little sluice
#

Mystery-Puzzle:
I got code running as a coroutine. It loads a scene called "Loading" directly, and then the actual target scene asynchronously.
The time to asynchronously load the scene increases from 0 seconds to roughly 15 seconds and more, by waiting BEFORE even starting the load.

plucky laurel
#

can it be related to the lifetime of the object the coroutine is running on?

little sluice
# little sluice Mystery-Puzzle: I got code running as a coroutine. It loads a scene called "Load...

I think i found my answer: The 15 seconds i actually "forever until whatever" and its the while (!loadOperation.isDone) loop that never exceeds a progress of 0.9f because allowSceneActivation is not set. All that is according to documentation.
The yield return wait line seems to change how the async loading works and makes it synchronous., which is still a mystery but not one that keeps me from doing my job.

limber snow
#

its a bit complex to start learning from there but well i will try it

dusty wigeon
#

There is Youtube Video on this project

limber snow
#

because i was starting using scriptables in my project as a littel data container

dusty wigeon
#

In this second devlog, we look at how we employed ScriptableObjects to create a flexible and powerful game architecture for "Chop Chop", the first Unity Open Project.

๐Ÿ”— Get the demo used in this video on the Github branch:
https://github.com/UnityTechnologies/open-project-1/tree/devlogs/2-scriptable-objects
(compatible with Unity 2020.2b and la...

โ–ถ Play video
#

An example.

limber snow
dusty wigeon
#

(Also, I am not a fan of what they are showing)

limber snow
#

or maybe classes like that should be protected and not to be used on scriptable?

limber snow
dusty wigeon
limber snow
#

well, im using on my projects to control the AI as does unity tanks with scriptables, and i never change is values

novel wing
limber snow
#

but i used also for unlock and modify values in some small scriptable and i think we can avoid to change or not each data container

limber snow
#

dependency injection like zendesk vs sciptable, i cant find anything in google

little sluice
dusty wigeon
# novel wing That sounds like a you thing. Plenty of good use cases for mutable ScriptableObj...

This is a "me" things as you stated. There is multiple advantage, there is also some disadvantages however nothing is clearly better or worse.

Making them immutable reduce the amount of issue due to different behavior in build and editor, prevents memory leak due to unloaded asset and reduce the complexity because they are simply data from my experience.

On the other hand, ScriptabeObject facilitate the implementation of things like Channel or Singleton by the fact that you can directly reference them. However, note that we can still have the same behavior without the usage of mutable ScriptableObject without extensive code by having a script that "consume" the ScriptableObject.

From my point view, ScriptableObject is the same as using Json to define the characteristics of your game. You do not have behavior associated to them.

#

Every dependency is also included in the Addressable.

sly grove
#

once the object is loaded all direct references will also be loaded into memory

limber snow
#

yes i know, im testing and works, so idk if its better to doing different

sly grove
#

if you want dependencies not to be loaded in immediately, use AssetReferences

dusty wigeon
#

However, you should still try to keep things track correctly and organize. I do not know if duplicated asset is still an issue.

limber snow
limber snow
#

so maybe is better to keep all items removed after move to menu, instead of add to my scene and addressable with all of his objects, to load an addressable scene in order to remove all items included when i remove the scene ?

fair hound
#

Im trying to figure out whats the best way to store a ScriptableObject/Prefab Script pair. My goal is to have an in-game menu that lists selectable models but im not sure if it would be better to store the Prefab Script reference inside of the ScriptableObject so that the SO is what is pointed to by the menu, or have the ScriptableObject stored inside of the Prefab Script so that the Prefab Script is what is pointed to by the menu. Is either better than the other?

plucky trellis
#

Functionally, it probably doesn't matter, but referencing a scriptable object is cleaner. Referencing them in something like a menu is the intended way to use them afaik

dusty wigeon
fair hound
#

In my case im trying to make a car, I could just set the whole thing up in the prefab I suppose, but that makes adjustments a lot more complex since when a change is made its a lot more roundabout to find out what the original values were. So I am trying to use the scriptableobject as a storage for constants that feed into the overall object setup process.

dusty wigeon
#

Where the prefab comes from then ?

limber snow
#

for example using the scriptable to configure an scene instancing prefabs?

#

so if two scriptables objects has two times the same prefab are this loaded in the build two times?

#

or the system avoid duplicated resources?

sly grove
limber snow
#

also for the memory if i unload an scene addressable that got scriptable references to other addresasables that are instancing prefabs? lol i need a coffee

dusty wigeon
fair hound
# dusty wigeon Where the prefab comes from then ?

Well I have values for the player to be able to adjust, like the spring stiffness, but I need to have that stored outside of the prefab obviously, so I need to deliver the prefab with its constants to the main object generator. The prefab only contians the mesh, armature, and animation data.

limber snow
dusty wigeon
dusty wigeon
fair hound
dusty wigeon
#

Is it a 1-1 relation between SO and Prefab ?

fair hound
#

what do you mean by 1-1

dusty wigeon
#

For each SO, you have a unique Prefab.

fair hound
#

thats what im having trouble deciding, because I suppose there would be an instance where two cars might share dimensional data, but then I wonder if they should behave more like "skins" for the same prefab.

limber snow
dusty wigeon
fair hound
#

Sort of, it would have an SO for the chassis, an SO for balancing (torque, grip, etc) and then tuning values which all get put together to build the actual completed vehicle. The prefab however, only has 1 SO associated with it.

fair hound
#

Think of the prefab as the literal raw imported FBX, its like a cosmetic that has an SO to tell the car generator how to build its simulation elements.

dusty wigeon
fair hound
#

?

dusty wigeon
#

I have a hard time understanding your structure. Maybe I can explain how I see things and you can take whatever fits you.

plucky laurel
#

at runtime, i link the so to prefab, but i create the object from an so, in most cases SO is unaware about prefabs, those are handled by systems that contruct objects based on context

dusty wigeon
#

I do almost the same as @plucky laurel. My SO are usually Definition (WeaponDefinition, CharacterDefinition) which each of them are responsible to create an instance.

In your case, I would have WheelDefinition, EngineDefinition and ChassisDefinition and they would instantiate themselves at the given position/context on the car. The one actually triggering the instantiation would be the car. Something like a RefreshPart.

fair hound
#

how would I do animation then though

#

do I just do the object setup entirely through script?

plucky laurel
#

they are part of the whole, just a component

#

you can also pre setup the root prefab and create a variant with meshes and all

#

its just whats more convenient to the end user

fair hound
#

ah, so I guess ill go with storing prefab in ScriptableObject then

mellow sail
#

could someone help me on how do disable list drag and drop add element on inspector using the odin but still could edit the element within it?

#
    [InlineEditor]
    [Title("Primary Missions")]
    // Set a button in each list's elements so it could be removed by clicking the button (Call the removeButtonPrimary method)d
    [ListDrawerSettings(IsReadOnly = true, DraggableItems = false, OnEndListElementGUI = "RemoveButtonPrimary")]
    public List<Mission> primaryMissions;
```c
#

or any other way

balmy ingot
#

Hi ppl, i need to make an Ability System that is Scallable with my A.I, so that, based on the skill the A.I know if he hasto get closest to the enemy to use, can someone give me a tip?

dusty wigeon
# balmy ingot Hi ppl, i need to make an Ability System that is Scallable with my A.I, so that,...

It really depends on what you want. The simplest, base on your description, would be to have a range attribute on each abilities and have the agent use the ability depending on the range he is from its target.

Alternatively, you could use Goal Oriented Action Planning: https://learn.unity.com/project/goal-driven-behaviour

Unity Learn

In this project you will learn about the Goal-Orientated Action Planning (GOAP) architecture used to create intelligent agents that can set goals and plan at achieving them. Unlike Finite State Machines, actions and states are uncoupled, making for a very flexible system. You will build a GOAP system from the ground up and implement it in a si...

tender ingot
#

Hey all,

I am trying to figure out how to do something in an up coming game I am making for Uni.

I want to make a fence builder for a garden you be making in the game so would be like any free form builder that you place one point and have the prefab spawn from there and can stretch it a certain distance and then place the asset down and then repeat until you exit the building the fence section.

To the best of my thoughts I can only think of using a coroutine of placing a marker then place the prefab down and then be able to stretch the prefab on the X and Z axis for a certain distance using Mathf.clamp and then finish placing the fence asset in then place a new marker and repeat until you right side click to stop.

sly grove
#

you have two primary states:

  • WaitingToPlace (where you choose where the fence starts)
  • Placing (where the initial point is chosen and you are drawing a preview showing the how the fence would look if you finished here)
#

WaitingToPlace transitions to Placing and vice versa, upon clicks/user inputs

#

You can do this any way you would normally implement a state machine. I wouldn't immediately reach for coroutines, no

tender ingot
#

Okay so if i were to implement a state machine in terms of the logic of actually placing the fence prefab in game. Would I be correct with my thoughts on it or is there a different way in placing the prefab to do what I want to implement. For reference for what I want to do think of The Sims and how the building fences and walls etc work on that game.

plucky laurel
#

depending on complexity an FSM can be too simplistic, you need rulesets, which can have priority, weight, randomization

neat vortex
#

can i copy a gpu renderTexture to cpu/save to file without blocking the main thread?

i currently generate a dynamic texture in a compute shader onto a render texture.
i then want to save it to png. i currently only found Texture2D.readPixels. But this takes like 50ms.
Problem is that this cannot be done on another thread started with Task.Run. I also found a post saying that it is not possible to do this in the job system.
just using Graphics.CopyTexture does not create the cpu pixels correctly (they are just grey).

is there a way to do this without blocking the main thread?

long ivy
drifting vessel
#

I have a string[] with 77k indices.

#

How can I return a string[max 10] that are a partial match to an input?

#
string[] values = string[77,000]
string[] GetPartialMatches(string input)
{
  search values for partial match to input
  return up to 10 partial matches
}
dusty wigeon
drifting vessel
#

Just wondering if anyone else has done something similar and what the solution looked like

dusty wigeon
#

You would be lucky to find someone that has done something as specific as this in this discord.

drifting vessel
#

Fair enough

dusty wigeon
#

If you are doing a lot of GetPartialMatches, you will need to define a good data structure to hold your data base on what a partial match mean.

drifting vessel
#

Because if the player types in "17", I'd like to return "17 Draconis", but also things like "Charlie's 17 Angels", so the match isn't always just what it begins with

dusty wigeon
#

You could, by example keep a dictionaries of index where each subset of 3-4 characters is found.

#

By example:
I love cat.

Dictionary:
"I" => [0]
" " => [1, 6]
...
"love" => [2]

#

This way you can pre-filter a huge amount of your text.

#

Could be memory intensive depending on the size of the text and the amount of subset character.

dull kestrel
#

If this data is persistent, it would perhaps be effective to use a database where you can query "LIKE". Databases are optimised for this.

dusty wigeon
#

Could always use SQLite and see what it gives in term of performance.

drifting vessel
dusty wigeon
#

SQLite does that

drifting vessel
#

Oh excellent.

dusty wigeon
#

It even runs in memory

drifting vessel
#

SQLite has been excellent in places where I didn't want to set up a whole database, like with Discord bots.

#

The performance aspect had never occured to me.

vestal lotus
#
            RaycastHit2D[] circleCast = Physics2D.CircleCastAll(origin, radius, Vector2.right, targetObjects);// Checks area for specified targets
            
            float closestDetected = 100f;
            GameObject closestTarget = null;

            for (int i = 0; i < circleCast.Length; i++){
                
                RaycastHit2D[] lineCast = Physics2D.LinecastAll(origin, circleCast[i].collider.transform.position, mask);// Draws ray between parent object and potential target
                float distance = Vector2.Distance(origin, circleCast[i].collider.transform.position);// Gets distance between parent object and potential target
                if (lineCast.Length == 0 /*Wall check*/&& distance < closestDetected /*Closer than previous check*/ && circleCast[i].collider != self/*Avoid own colllider*/){
                    closestTarget = circleCast[i].collider.gameObject;
                    closestDetected = distance;
                }
                Debug.Log(closestTarget.transform.position.ToString() + distance.ToString());
            }

            if (closestTarget != null){
                return closestTarget;
            } 
            else{
                return null;
            }
        }``` For some reason this function keeps returning the object its attached to even though i explicitly tell it not to
dull kestrel
#

Also, you can do closestDetected = float.MaxValue; to avoid issues with your current maximum.

tall ferry
vestal lotus
tall ferry
thin mesa
tall ferry
#

passing in the collider instead of gameobject is probably more useful, it doesnt seem like this method has a need for the entire gameobject anyways

exotic garden
#

hey,
if (Application.internetReachability == NetworkReachability.NotReachable) does not working on standalone windows il2cpp build, correctly ...
any suggestions?
thanks.

thin mesa
plush hare
#

if it responds, you're online

exotic garden
plush hare
#

I don't know too much about home networks, but I assume the gateway is always generally the same local IP?

thin mesa
exotic garden
thin mesa
#

i mean, i know it doesn't work for what you want. we've already established that. my question was why were you attempting to compare against the NotReachable enum instead of ReachableViaLocalAreaNetwork if you wanted to check if it was connected to a LocalAreaNetwork

plush hare
#

@exotic gardenIf you're working with LAN, then you probably already know the address of the other device you're trying to communicate with. Right? Just send pings back and forth.

#

Unless I'm completely misunderstanding what you're trying to do here

limber snow
#

because im checking chop chop project and i have to change the whole of my mind to remove all my singleton and start using event by SO

#

i got my AI working like Scriptable system from Unity Tank

kindred tusk
#

I seem to have somehow set up a scriptable object so that Unity enters a stack overflow when... loading it? Not sure exactly what operation is triggering this:

StackOverflowException: The requested operation caused a stack overflow.
UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) (at <b0fc6facff52490f8c5788181f70c5cc>:0)
UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) (at <b0fc6facff52490f8c5788181f70c5cc>:0)
UnityEngine.Object.op_Inequality (UnityEngine.Object x, UnityEngine.Object y) (at <b0fc6facff52490f8c5788181f70c5cc>:0)
EffortStar.WeaponConfig.get_IsPotent () (at Assets/_Game/Scripts/Config/WeaponConfig.cs:129)
EffortStar.WeaponConfig.get_Appearances () (at Assets/_Game/Scripts/Config/WeaponConfig.cs:135)
EffortStar.WeaponConfig.get_Appearances () (at Assets/_Game/Scripts/Config/WeaponConfig.cs:136)
EffortStar.WeaponConfig.get_Appearances () (at Assets/_Game/Scripts/Config/WeaponConfig.cs:136)
EffortStar.WeaponConfig.get_Appearances () (at Assets/_Game/Scripts/Config/WeaponConfig.cs:136)
kindred tusk
#

nvm, worked it out. Was a circular reference being triggered by GetHashCode I think

limber snow
#

for example: Addressables.Release(sceneHandle1);
Addressables.UnloadSceneAsync(sceneHandle1, true);

vestal forum
#

Hello guys! i am trying to implement a custom function to a script found in a unity package but everytime I save it, it reverts whatever I wrote

#

Does anyone know why this is and how to disable it?

#

Also i should mention the script seems to be outside of unity? as whenever I try to make a variable for a public class, it does not recognize it'

sly grove
vestal forum
sly grove
sly grove
#

naturally you can't make changes to assets that aren't part of the project and expect them to be... part of the project

#

this would break immediately once you share that project with another developer or another PC of course

vestal forum
#

I see, ok that makes sense

#

Is there any way around it considering I just want to add a single custom function?

sly grove
#

I highly recommend avoiding trying to make changes to packages iin general unless there's really no other way to do it

#

it's almost certainly easier to simply add the function outside the package

sly grove
#

or simply not trying to modify the package directly

#

perhaps you could explain what you're trying to do exactly and a workaround could be suggested?

vestal forum
#

Ok, thanks. I'm working with Yarn Spinner (v2.2) and trying to get the Line ID of whatever line is currently playing. The issue is that it's so abstracted to the point where I cant access this line id which you would think would be trivial

#

the only example I found online is in a youtube video where they edit the TextLineProvider directly

dusty wigeon
vestal forum
#

It's not a member though that's the issue

#

Its kind of like this:

dusty wigeon
vestal forum
#

I'm confused by it, but from what I understand the text script with all the narrative lines gets compiled by [something], then dialogue runner creates its own textlineprovider on runtime, which feeds off the compiled text script but I cant edit the textlineprovider and the dialogue runner uses an abstract line provider

#

and there are functions which when I try to view their definitions it only gives me an error

#

The developers seem to really want users to do commands in the narrative text script

dusty wigeon
vestal forum
#

Thanks for the help regardless ๐Ÿ‘ I'll send an email and wait for a response

vestal forum
kindred tusk
#

The confusion is why it's being called by an internal function.

#

Unity internal

#

The stack trace before that call. But I guess unity uses properties for object equality.

drifting vessel
#

Getting an issue with SQLite. I know why it's happening, just not really sure how to proceed

#

SqliteException: SQLite error near "Bounty": syntax error

#
string value = Cleanup(factions[0]);
string sql = $"INSERT INTO factions (faction_name) VALUES ({value})";

private static string Cleanup(string v)
    {
        return v.Replace('"', '\"');
    }
#

Trying to insert "Fearless" Bounty Hunters Corp.

#

Doesn't like the quotes, I imagine. But they are necessary.

dusty wigeon
drifting vessel
#

This is a local DB, only person they'd be screwing is themselves.

dusty wigeon
#

I guess, it might also prevent issue with quotes and other character that could be interpreted by the query*

drifting vessel
#

I've attempted to insert an escape character wherever the quotes occur, but it doesn't seem to like that, either.

dull kestrel
drifting vessel
#

near "Fearless": syntax error

dull kestrel
drifting vessel
#

@dull kestrel @dusty wigeon thank you, chads

dull kestrel
drifting vessel
dull kestrel
drifting vessel
#

Not handling user input, actually, it's all just a list of strings in a text file.

#

I would write my own system to go through the strings myself, but there's 77k of them, and SQLite is probably better written than anything I can do

dull kestrel
drifting vessel
#

I have to leave for work. I'll get back on this tonight. Thank you for your help.

hybrid lark
#

Hey everyone, so I understand the concept of using unity events and scriptable objects to tie things together while leaving things mostly decoupled. The part that comes after that is how do you manage the registration of those unity events? I could create something like a game manager that would instantiate everything and configure event registrations... but is that really the right way to go about it? Things start to get messy if I need to subscribe to an event with something completely unrelated, like I dunno, a projectile event that goes to the UI. Any examples or tutorials you recommend would be awesome.

drifting vessel
#

Where normally you would call the event

#

Events.someEvent();

#

But that can throw errors if thereโ€™s nothing subscribed

#

So instead I use Events.someEvent?.Invoke();

#

Where itโ€™ll check to make sure someEvent isnโ€™t null (it doesnโ€™t have subscribers)

#

You still want to take care of unsubscribing burning their lifecycle management. I typically put subscriptions under Awake, so that the first calls can be made on Start, and I unsubscribe them on their last frame, such as under OnDestroy.

#

Iโ€™ve only ever used UnityEvents when referring to Button.onClick, but the subscriber is just a UI manager thatโ€™s persistent.

hybrid lark
#

I was more talking about managing the subscription references. In order for an object to subscribe to another object, something needs a reference to both in order for that to happen right?

#

Then you run into things that are deeply nested that require some registration to something it's parent's have no reference to

#

Use a singleton to manage it? Dependency injection?

#

Have a singular event hub that everything is registered to that has sole purpose of passing event registrations through events?

sand grail
#

I have been wondering, despites the quality of the shadows and lightin, how would a graphic system be for meshes, like making them from the peak with ultra high graphics orto playdo with super-low?

umbral trail
#

If you use a ScriptableObject as an event type you don't need anything else, just register/deregister to it in your monobehaviour

hybrid lark
#

@umbral trail The monobehavior still needs a reference to that ScriptableObject in order to register it right?

umbral trail
#

Yeah, you just assign it through the inspector in the behaviours that will listen or raise the event

hybrid lark
#

And that's the problem, that seems clunky for larger or deeply nested objects that need to register with each other.

umbral trail
#

well you could pass it down from one monobehaviour to another if you really wanted, but you'd just be adding more dependencies to it

#

The advantage here is that only the things that use it know about it

hybrid lark
#

Let's say I have a UI, and in that UI I have a bunch of elements and down a few layers is a UI element that displays.. a missiles distance traveled or something I also have a player object, with a weapon, that fires a missile that holds the traveled distance. How do I register that in a way that makes sense without having to daisy chain the registration.

#

This mostly comes into play when I need to add a new projectile type, that needs access to some other object, and neither of it's parents or factories have a reference or registration to each other. Maybe I'm just thinking about this all wrong, but it's kind of the trap I ran into last time when using events, and it just got worse over time, and I kind of want to avoid it.

worn reef
#

guys I am working with a way of seperating a sprite into polygons:

#

as far as i know this methos https://github.com/mjholtzem/Unity-2D-Destruction/blob/master/unity2DDestruction/Assets/2D_Destruction/Scripts/ClipperHelper.cs handles the seperation into polygons, my problem now is that i need the polygons to be a minimum size, if they are below that they should be merged with the nearest bigger piece. I tried multiple ways of implementing that, all have failed. How would you do this?

GitHub

Contribute to mjholtzem/Unity-2D-Destruction development by creating an account on GitHub.

open laurel
#

I'm trying to render some textures procedurally using Graphics.Blit(renderTexture, renderTexture, material), but I don't get any output, everything is black / 0
as a test, i have a trivial fragment shader that just outputs 255 everywhere, and the render textures do use a supported format

worn reef
dusty wigeon
worn reef
#

Well thats the thing it seems to work on smaller objects, but fails at bigger ones beacause: ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

#

Im also not as experienced with working with unity so im kinda lost in all that code

dusty wigeon
#

Which, we can hardly do without any code and context.

worn reef
#

I will try some other thing, might come back here once i know whats wrong exactly.

wise bobcat
#

Hello
i need some help here

I have wrote a static library in C++ for android

unlike dynamic libraries
static library is compiled to the executable so I tried to use DllImport(__Internal)
But it gave some linking errors while writing the library to libmain.so

any helps here?

dusty wigeon
wise bobcat
#

the dynamic library name is FSBC

#

and on build
its included in the apk as well

#

but when I use DllImport()

#

it fails again

#

pls help here

#

it took me 3 hours to build and if the results are not working then its painful to see

#

here is the error

#

any help would be appreciated cuz I am spending like hours on this thing

hybrid lark
#

wait, isn't that the FSB converter?

wise bobcat
#

I wrote that FSB converter in C++ myself

#

for converting ogg packets to vorbis compressed fsb5 file

#

FSBANK is supported for windows only by fmod

scenic forge
#

I would think there's a way to call into an Android static library directly from the C# side; but even if not, there's always C# -(via JNI)-> Java -> static library.

wise bobcat
#

so dllimport should work

#

whereas its still not working

#

for static library you call the internal compiled code but the linker was making issues so I went dynamic
its pretty much a .dll but on android

hybrid lark
#

@wise bobcat Ahh I was thinking of FBX not FSB

dusty wigeon
wise bobcat
#

visual studio support ARM and ARM64

#

the ARM64 is traditional

#

i think ARM is armeabi-v7a

#

or maybe simple armeabi

#

I compiled using visual studio

dusty wigeon
#

Also, If I remember correctly, you can directly use C++ file in Unity with IL2CPP.

wise bobcat
#

but I thought it might not work in Editor

#

cuz unity only compiles for C# in editor

dusty wigeon
#

Only in IL2CPP

wise bobcat
#

hmmmm

#

like if i just add a bunch of header files and just compile them to IL2CPP
unity would make sure they are fine

wise bobcat
#

cuz I dont have the source for libogg and libvorbis and they give tooo much errors on compilation
I have their binaries

#

Thanks
let me try this asap

wise bobcat
#

header files are kindda unsupported

dusty wigeon
#

You compile it with your project.

wise bobcat
#

and I have to make use of symbols defined in other libraries like libogg and libvorbis

#

cuz I dont have their source

#

and if I would try
it might cause a crash

#

lets stick to the idea of dynamic library for now

dusty wigeon
#

Anyway, I am pretty sure you want to follow tutorial on how to compile for Android.

wise bobcat
#

but there is one thing

#

most android devices are x86

#

that,s why arm32 is being used

dusty wigeon
#

Yeah, does not mean it works with them.

wise bobcat
#

i have a doubt that armeabi-v7a assembly i compiled is simple armeabi

#

but I am damn sure arm64 is correct

#

If i can get a player that is x64 then I might get a chance

#

know any emulator?

dusty wigeon
#

You might be right, however as things does not work, you should look into making it the write way.

wise bobcat
#

Only android is causing trouble

dusty wigeon
#

Also, you can do a Windows version

wise bobcat
#

for pc it works all fine

dusty wigeon
#

And test if works.

wise bobcat
#

as I first wrote it for editor

#

and then wrote all the codes above it

dusty wigeon
#

Then, even more reason to look into compiling correctly.

#

Your code might also not be correctly added to the APK.

wise bobcat
#

the library was inside the apk

#

meaning its all fine

#

the thing that is causing trouble is maybe the architecture

wise bobcat
#

i fear visual studio doesnt support armeabi-v7a

wise bobcat
#

๐Ÿ˜ญ

#

Ow

#

it hurts

#

now I get it why people only build games for arm64 and x86

dusty wigeon
wise bobcat
#

cuz visual studio doesnt compile for armeabi-v7a

#

it lied

#

as the emulator I was using was a 32 bit emulator

#

it couldnt call the arm64

#

so it tried to call the arm32

#

but the architecture didnt match

#

so the library didnt simply load

#

i gotta wait another 3 hours for build

#

any ways to fasten the build

#

?

dusty wigeon
worn reef
#

okay guys, I am working on a puzzle game where i have a 2d sprite, whch i have to divide into polygon. I found this project which seems to do the job: https://github.com/mjholtzem/Unity-2D-Destruction/blob/master/unity2DDestruction/Assets/2D_Destruction/Scripts/ClipperHelper.cs. But I need the pieces to be a minimum size. Sadly I dont know how to implement that into the class. I tried checking the size before returning the pieces but that just caused pieces to go missing. Would be nice if someone could explain to me how to achive such behaivoir. ๐Ÿ™‚

wise bobcat
#

you can write code that just splits them as required

#

I never looked deeply into how Unity draws the UI

#

but that,s one way go

dusty wigeon
worn reef
#

what do you mean by dynamic cutting?

dusty wigeon
#

Be able to explod things ? Like it suppose to be use ?

worn reef
#

i want it to be cut into smaller fragments which can be individually manipulated, like move

dusty wigeon
#

Does not seem to be the asset for what you want.

#

It explodes things up.

#

You might want to redo the fragmentation process as a whole.

worn reef
#

it does yes, but for that it also cutts them into polygons, so i figured i will just change some of the code

worn reef
dusty wigeon
#

You could, maybe reuse the triangulation of algorithm

worn reef
#

The algorythm stays the same doesnt it? So why not try to implement my behaivoir into that project just to see if it works

dusty wigeon
#

However, the way polygone are generate does not seem to work for your needs.

#

Alternatively, if you do not need to be able to dynamically generate fracture. You can simply do it with an editing software.

worn reef
#

Thanks, i need it done dynamically sadly

#

i will look into that

#

i see now that i already did haha

#

yeah that also didnt work xD

leaden siren
#

Hi guys, does any one try 100 spines animations + a star pathfinding pro (grid graph) , any solution to optimize this case? I want to make some game like survival.io but it's laggy :>

sand grail
#

instead of bulding the path for each indiviudual enemy

#

just a suggestion

thorny lion
#

do you guys have a tutorial for reactive ui in unity? ui components in particular, not ui builder

faint harness
#

Does anyone know what's going on here? I cant seem to enable aspects on entities

faint harness
#

I don't know if its a bug or w/e but I think it is just a visual error, something with Instantiated entities not showing aspects ? I just wrote some aspect logic and it works.

faint harness
open laurel
#

I posted this a bit ago, and also crossposted to gamedev.SE: https://gamedev.stackexchange.com/questions/206242/

I'm trying to render a shader onto a texture, but I'm having trouble using Graphics.Blit(renderTexture, renderTexture, material), it just outputs black no matter what. Code snippets in the link.
This is in editor code in unity 2022 using URP (if it makes a difference).

#

my code is basically ```csharp
var a = new RenderTexture(64, 64, GraphicsFormat.R32G32B32A32_SFloat, GraphicsFormat.None);
var b = Object.Instantiate(a);
var brush = new Material(Shader.Find("Hidden/My Cool Shader"));

// Here I would set up the material properties when using an actual shader.

Graphics.Blit(a, b, brush);
ctx.AddObjectToAsset("test", b);

Object.DestroyImmediate(a);

I use 2 RTs because eventually I'll have to run multiple passes so I'll be doing some double-buffering
nova thunder
#

Hey. Is there anyone here that has experience with Unity and OSC?

regal olive
#

hello everone im currently geting an error with my code and i might just be stupid and not understanding what it means or im doing soemthing wrong but im getting an error saying:

Assets\marching cubes\MarchingCubesBody.cs(86,40): error CS0029: Cannot implicitly convert type 'int[]' to 'int'

i get this same error on line 87, col 40 and line 88, col 40

my scripts can be found here:

tri table: https://pastebin.com/MxsvYARu
main body: https://pastebin.com/6z2Jj8sv (error says its in this script)

any help is greatly appreciated, Thanks!

#

psa: i reversed the names of the scripts in paste bin :p

open laurel
regal olive
sly grove
#

This is a simple compile error

plucky trellis
#

Either you can wrap your rendertexture in an RTHandle and use the new blitter api, which is the new way to do it (various advantages with variable texture size and whatnot)

#

Or you just have to fiddle with it a bunch. What does your shader look like?

#

Note I've only done blitting for realtime (not editor) in urp, but I don't see it being different

open laurel
#

it's linked on the SE, for now it just returns 1,1,1,1 for every pixel

#
Shader "Hidden/My Cool Shader"
{
    Properties
    {
        _MainTex("InputTex", 2D) = "white" {}
     }

     SubShader
     {
        Blend One Zero

        Pass
        {
            Name "Blit"

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma target 3.0

            sampler2D _MainTex;
            
            struct appdata {
                float4 uv0: TEXCOORD0;
            };
            
            struct v2f {
                float4 uv0: TEXCOORD0;
            };
            
            v2f vert(appdata vertex) {
                v2f fragment;
                fragment.uv0 = vertex.uv0;
                return fragment;
            }

            float4 frag(v2f IN) : SV_Target
            {
                return float4(1,1,1,1);
            }
            ENDCG
        }
    }
}
open laurel
plucky trellis
open laurel
#

xD thank you for the links though, i'll read up on those

plucky trellis
#

A good tip is that for blit shaders in the SRP's is to use Blit.hlsl for certain things, I put this under my HLSLINCLUDE at the top of my blit shader. Blit.hlsl provides the vertex function as well as the structures for whatever data you might need in the fragment function. (You define the fragment function yourself obviously)

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
// The Blit.hlsl file provides the vertex shader (Vert),
// input structure (Attributes) and output strucutre (Varyings)
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"

#pragma vertex Vert
#

Oh, another important thing is that in URP _MainTex is called _BlitTexture (Including Blit.hlsl sets this up for you automatically, no need to add it as a property)

open laurel
#

alright

#

this is from core rp right? would this work on hdrp too? presumably not built-in
(i'm working on a tool, so far i try to support builtin+urp, just want to understand the requirements here)

plucky trellis
open laurel
#

fun times

plucky trellis
#

yeahhh

#

I read way too many forums posts to put this together

open laurel
#

alright i'll read up on these and try it out tomorrow, than you immensely for the help!
for today it feels like i'm an egyptian mummy that got its brain scooped out through its nose...

plucky trellis
#

No worries lol, feel free to ping me if you have more questions

open laurel
#

thank you! i will use that power respectfully

plucky trellis
#

fun times indeed

open laurel
#

too real, i have one open right now

#

hallowed be their name, but it is a bit disorienting

plucky trellis
#

Yup

#

Enjoy ๐Ÿ˜„

plush hare
#

So I have a custom interpolator that ticks with my own clock similar to fixedupdate.
Basically whenever something moves during this fixed update, it saves the current and last states. Then it interpolates on renders until the next fixedupdate.

The problem, is that whenever you modify a transform, the physics engine decides to recompute the velocity if it's attached to a rigidbody.
Even setting a rigidbody's position to it's exact rigidbody position (not transforms) while it's sleeping, causes it to wake up.

So how did unity implement interpolation without causing the rigidbodies to wake up?

#

Physx is a damn blackbox and I can't find anything online. I'm guessing their interpolator sits inline with the engine itself, therefore bypassing these wakeup calls. Shame if it can't be bypassed

dusty wigeon
plush hare
#

that's not the issue

#

the issue is the setter on the rigidbody's position forcing a wakeup and setting a miniscule amount of velocity

#

even if both positions are identical

dusty wigeon
#

Why does it matter ?

plush hare
#

because my ragdolls jitter around when they're supposed to be sleeping

dusty wigeon
plush hare
#

It most definitely is

dusty wigeon
#

If you know that the Rigidbody should be sleeping, can you not disable it in a way or another ?

dusty wigeon
plush hare
#

The problem is that it can't sleep.

When my fixed update gets called, and they move, that's fine.
Next the interpolation happens between the fixed updates. This involves setting the transform position connected to the rigidbody

#

setting the transform forces a wakeup even if the physics engine isn't running that frame

#

and it's just stuck with a minimal amount of velocity that causes it to very subtly jitter around

#

what I'll probably have to do is separate the rigidbody from the visuals. was hoping someone had a hack or something

tall ferry
plush hare
#

I don't think that would really do much, since it would just wake back up the next frame and negate any possible optimizations

plush hare
#

Set it very high. Still not sleeping.

#

I'm certain their setter forces a wake up. Unity loves to noob proof stuff like that

#

shame

tall ferry
#

Yea i just tried as well, even infinity sleep threshold doesnt work lol

#

from what im trying, it seems sleeping it on the next frame after adjusting its transform works..

plush hare
#

That works fine, but on the next update frame when the interpolation happens, it's going to wake back up

#

or maybe not. I'm very tired

#

this is a problem for tomorrow

tall ferry
#

code was only

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            StartCoroutine(SleepNextFrame());
            transform.position -= Vector3.right;
        }
    }
    IEnumerator SleepNextFrame()
    {
        yield return null;
        rb.Sleep();
    }

calling rb.Sleep() on the same frame didnt do anything

plush hare
#

๐Ÿ‘

noble stream
#

Does anyone know how using Application.backgroundLoadingPriority affects the SceneManager.LoadSceneAsync for additive loading? I have tried using it to make scene loading smoother in an open world, but it doesn't seem to make any difference in FPS drops when I set it to ThreadPriority.Low;.

jolly token
#

That is actually instantiating the scene

plucky laurel
#

that you can technically time slice yourself

#

at least unity callbacks

uneven wing
#

hey i have been messing around with compute shader and i just dont know what the heck is wrong with it
The Shader:


#pragma kernel CSMain

// Create a RenderTexture with enableRandomWrite flag and set it
// with cs.SetTexture
RWTexture2D<float4> Beginn;
RWTexture2D<float4> Result;
float4 Resolution;

[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
    float2 left = 0;
    left.x = id.x + 1;
    if (left.x >= Resolution.x)
        left.x = Resolution.x-1;
    left.y = id.y;
    Result[id.xy] = Beginn[left];//float4(id.x/ Resolution.x,id.y/ Resolution.y,0.0,1.0);
}
#

The Initalise Script:

using System;
using UnityEngine;

public class Executer : MonoBehaviour
{
    //[SerializeField]private 
    [SerializeField] private ComputeShader _shader;
    [SerializeField] private RenderTexture _textureOut;
    [SerializeField] private Texture2D _textureIn;
    [SerializeField] private float lol;

    private Camera _cam;
    void Start()
    {
        _textureOut.enableRandomWrite = true;
        _shader.SetVector("Resolution",new Vector4(_textureOut.width, _textureOut.height, 0, 0));
        _textureIn = new Texture2D(_textureOut.width, _textureOut.height);
        print("In MipMap: " + _textureIn.mipmapCount + "    Out MipMap: " + _textureOut.mipmapCount);
        Graphics.CopyTexture(_textureOut, _textureIn);
        _textureIn.Apply();
        _cam = Camera.main;
        
    }

    void Update()
    {
        _shader.SetTexture(0, "Result", _textureOut);
        _shader.SetTexture(0, "Beginn", _textureIn);
        Graphics.CopyTexture(_textureOut, _textureIn);
        _shader.Dispatch(0, _textureOut.width / 8, _textureOut.height / 8, 1);
        


        if(Input.GetKey(KeyCode.Mouse0))
        {
            Vector3 pixelPos = Input.mousePosition;
            print("MousPosWhilePress: " + pixelPos);
            // _textureIn.SetPixel((int)pixelPos.x, (int)pixelPos.y, Color.white);
            _textureIn.SetPixel(1000, 1000, Color.white);
            _textureIn.Apply();
        }
        
    }
    private void FixedUpdate()
    {
        
    }
}
light copper
#

I'm trying to create a sand simulator updating with ECS, rendering with a tilemap. I've tried many things but the tilemap only seems to be loading on the first set. Anytime I try to set it another time, it just doesn't want to work.

#

But, when I change my code to the following, it does update, but with a lot of lagg

#

does anyone know how to keep is preformant while still rendering correctly?

light copper
#

I managed to fix the issue, apperently the "Lock Color" flag had to be turned on of the tile

sly grove
#

Do not crosspost

livid kraken
plucky laurel
#

then send impulse to start activity

#

all of this requires bunch of code

livid kraken
#

Yeah I kinda figure the same things yesterday trying to eliminate a small stutter when loading our scenes

#

Why havent unity time sliced the enabling of objects is beyond me

#

I also cant find a ready made solution for this which is strange

plucky laurel
#

it requires heavy architecturing around it

#

cant fit into everything

#

i wonder if it can be done cleaner by overwriting playerloop systems

#

you would be replacing unity phased initialization

#

probably a good idea to keep a stopwatch between each enable, and yield when it exceeds frame budget

livid kraken
plucky laurel
#

i feel this whole thing is one bad idea

#

but i cant put my finger on it

livid kraken
#

I think it should be doable in a clean way

jolly token
#

Because it all may cause unpredictable behaviour to call Start in different frames or have some of scene objects inactive

#

You might just throw scene away and stick with prefabs

sand acorn
#

Hello there, I have been struggling with this for a while and would like some advice, so I have these arrays on a parallel job

    [ReadOnly] public NativeArray<half3> TopFace;
    [ReadOnly] public NativeArray<half3> BottomFace;
    [ReadOnly] public NativeArray<half3> RightFace;
    [ReadOnly] public NativeArray<half3> LeftFace;
    [ReadOnly] public NativeArray<half3> FrontFace;
    [ReadOnly] public NativeArray<half3> BackFace;

I pass them as I normally would and now I need to somehow store that array in a temp variable based on a condition (if for example I have a block on the left direction, I should be able to store that native array on a temp variable so I can later on perform an operation with that on a struct) how can I do this?

I have tried passing a native array of type half3 called FaceComparer with the same lenght as LeftFace and I simply do FaceComparer = LeftFace but this does not work, the values stay at 0 on all indices, what can I do here?

#

I need to assign those values to a struct

currentData[index] = new VertexData
        {
            Position = new float3(FaceComparer[0].x + blockPos.x, FaceComparer[0].y + blockPos.y, FaceComparer[0].z + blockPos.z),
        };

        currentData[index + 1] = new VertexData
        {
            Position = new float3(FaceComparer[1].x + blockPos.x, FaceComparer[1].y + blockPos.y, FaceComparer[1].z + blockPos.z),
        };

        currentData[index + 2] = new VertexData
        {
            Position = new float3(FaceComparer[2].x + blockPos.x, FaceComparer[2].y + blockPos.y, FaceComparer[2].z + blockPos.z),
        };

        currentData[index + 3] = new VertexData
        {
            Position = new float3(FaceComparer[3].x + blockPos.x, FaceComparer[3].y + blockPos.y, FaceComparer[3].z + blockPos.z),
        };
#

Also it is worth mentioning that I am making this equal to the target face on a condition

     //left
            if (blockLeft == 0)
            {
                FaceComparer = LeftFace;
            }

I would tipically just pust he currentData logic inside of the condition too, but doing that never assigns the struct value, it works just fine if I were to use just a list instead of a struct, but since this is a parallel job and I am aiming to implement the MeshData API, then I have to use a struct (I tried using parallel native lists before but there was a loss of data sometimes leading to having incorrect values on some indices, so I heard structs should keep the expected value at the expected index)

tiny pewter
#

your problems is when you assign a NativeArray b to a and a[some index]!=b[some index]?

#

i think this is impossible since the = operator should copy all the data (ptr, length, capacity) from b to a

#

so a.ptr and b.ptr should point to the same memory space

sand acorn
# tiny pewter your problems is when you assign a NativeArray b to a and a[some index]!=b[some ...

Debuging my code a bit, I have proved that the array does indeed get copied but since it is stored only at that very exaxct condition, later on it gets reset to 0. My problem relies on the conditions, to fix this I must have the currentData[index] on all conditions as I was doing before on a non-parallel job, but it seems like it's not possible, the struct values never get assigned, this is what I currently have

#
      //top
            if (blockAbove == 0)
            {
                FaceComparer = TopFace;
            }

            //bottom
            if (blockBelow == 0)
            {
                FaceComparer = BottomFace;
            }

            //left
            if (blockLeft == 0)
            {
                FaceComparer = LeftFace;
            }

            //right
            if (blockRight == 0)
            {
                FaceComparer = RightFace;
            }

            //back
            if (blockBack == 0)
            {
                FaceComparer = BackFace;
            }

            //front
            if (blockFront == 0)
            {
                FaceComparer = FrontFace;
            }

            AssignData(currentData, index, blockPos, FaceComparer);

It makes absolute sense that the array values get reset to 0, but I can't manage to put the assign data logic inside the conditions and still being able to assign the struct data

#
private void AssignData (NativeArray<VertexData>currentData, int index, half3 blockPos, NativeArray<half3> face)
    {
        currentData[index] = new VertexData
        {
            Position = new float3(face[0].x + blockPos.x, face[0].y + blockPos.y, face[0].z + blockPos.z),
        };

        currentData[index + 1] = new VertexData
        {
            Position = new float3(face[1].x + blockPos.x, face[1].y + blockPos.y, face[1].z + blockPos.z),
        };

        currentData[index + 2] = new VertexData
        {
            Position = new float3(face[2].x + blockPos.x, face[2].y + blockPos.y, face  [2].z + blockPos.z),
        };

        currentData[index + 3] = new VertexData
        {
            Position = new float3(face[3].x + blockPos.x, face[3].y + blockPos.y, face[3].z + blockPos.z),
        };

    }

this is the assign data logic

#

I would tipically do this, but it does not work (Sorry, I am new to the usage of structs, so I am confused)

            //outputData is a Mesh.MeshData 
            var currentData = outputData.GetVertexData<VertexData>();
           
             //top
            if (blockAbove == 0)
            {
                AssignData(currentData, index, blockPos, TopFace);
            }

            //bottom
            if (blockBelow == 0)
            {
                AssignData(currentData, index, blockPos, BottomFace);
            }

            //left
            if (blockLeft == 0)
            {
                AssignData(currentData, index, blockPos, LeftFace);
            }

            //right
            if (blockRight == 0)
            {
                AssignData(currentData, index, blockPos, RightFace);
            }

            //back
            if (blockBack == 0)
            {
                AssignData(currentData, index, blockPos, BackFace);
            }

            //front
            if (blockFront == 0)
            {
                AssignData(currentData, index, blockPos, FrontFace);
            }
tiny pewter
#

the currentData[index] not get assigned after and outside assigndata()?
wait you said that assigning a NativeArray a to b (b=a) the b.ptr is being malloc and memcpy(b,a,size) ?
i never assign a native array even use it (the indexer is annoying) and i just use pointer

jolly token
#

Double check if your MeshData is writable

sand acorn
# tiny pewter the currentData[index] not get assigned after and outside assigndata()? wait you...

1, Yep, if I use conditions for assigning data to the struct, the value never gets assigned, however, if I call assign data outside the methods, then the value gets assigned but with position not matching the current face data

2, I am not using memcpy and malloc, I was just using FaceComparer = LeftFace, I also tried using LeftFace.Copy(FaceComparer) with no success, all the index elements would be 0.

3, I guess I should take a look into that, never used pointers before

sand acorn
#

Outside the conditions the struct does add data

tiny pewter
#

i have no idea why assigning native array not work

#

so, pointer

#

oh, face_base_addr doesnt need to be added by index, just pass the base addr

sand acorn
#

I see, I will take a look into that, thanks!

soft moon
#

My brain is not braining, how can this even happen?

private string text
{
    get => _textComponent.text;
    set
    {
        StartCoroutine(SetTextHelper());

        IEnumerator SetTextHelper()
        {
            yield return new WaitUntil(() => _setTextCoroutine == null);

            _setTextCoroutine = StartCoroutine(SetText());

            IEnumerator SetText()
            {
                if (value == null)
                    value = string.Empty;

                value = value.Replace("\0", string.Empty).Replace("\u200B", string.Empty);

                _caretPosition = value.Length;

                if (value.Length == 0)
                    value = "\u200B";

                _textComponent.text = value;

                _textComponent.ForceMeshUpdate();

                AlignCaret();

                if (_textComponent.textInfo.lineCount > _textComponentLineCount)
                {
                    Debug.Log($"before - index: {textComponentIndex}; lineCount: {_textComponent.textInfo.lineCount};");

                    int firstCharacterIndex = _textComponent.textInfo.lineInfo[^1].firstCharacterIndex;

                    string lastLine = text[firstCharacterIndex..];

                    _textComponent.text = text[0..firstCharacterIndex];

                    textComponentIndex += 1;

                    _textComponent.text = lastLine;

                    Debug.Log($"after - lineCount: {_textComponent.textInfo.lineCount};\nlastLine: {lastLine}; text: {text}");
                }

                yield break;
            }
        }
    }
}
#

I don't know why, but that if clause works 2 times here

#

that cannot be so with this nice Coroutine checking

#

ok, actually it can, as we can see

#

but I do think that the issue is in WaitUntil()

soft moon
#

that works now

#

so I can set text directly now

text = text[0..firstCharacterIndex];

textComponentIndex += 1;

text = lastLine;
#

gonna implement backspacing now too, thx @soft moon

#

that doesn't make sense, right?

#

I don't even have while loop

#

or do I?

#

I don't

#

oh, now it's either resulting in StackOverflowException or adding more than one _textComponent

#

it's even worse

#

how I like coding.

#

oh, I have mentioned this recursion:

text = text[..firstCharacterIndex];
#

that's stupid actually

#

it just returns

#

but it shouldn't be overflow

#

oh.. so do I use _textComponent.text ?

#

yeah, that's right

#

it doesn't throw errors now

#

but it still jumps

frigid musk
#

!code

thorn flintBOT
#
Posting code

๐Ÿ“ƒ Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

๐Ÿ“ƒ Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

frigid musk
#

Anyone encountered this issue before?

austere jewel
frigid musk
#

It's only happening on the buttom of the screen, increasing the camera rotation it also increases the zone where the bug will happen.

#

The issue it's with this code and the camera. If I reduce the camera X rotation to 30, the bug completly disappears.

austere jewel
frigid musk
#

I'm trying to implement it now, thank you for the idea.

vestal condor
#

when dealing with asset bundle dependencies, lets say we have

A depends on B, C
B depends on C

when you do GetAllDependencies on A, does the AssetBundleManifest return [B, C]?
in that case if I naively try to load the dependencies in the order B, C i'm guessing it doesnt work?

is there a proper way to obtain the correct dependency loading order? assuming there are no circular dependencies

frigid musk
#

@austere jewel Good sir, you're awesome, it was interacting with a part of the tower as I forgot to remove the collider. Thank you very much

flint sage
#

But it's been a while

vestal condor
#

hm okay

#

I'm having this issue where LoadFromFileAsync just isn't loading

#

I'm invoking LoadFromFileAsync and busy waiting for completion in a coroutine, but it's just straight up not completing for some reason

#

is there a good way to debug this?

#

trying to use VS debug crashes VS lol

vestal condor
royal sequoia
#

Anyways, I will put it here, what Im doing looks advanced to me:
I saw this: https://docs.unity3d.com/ScriptReference/NVIDIA.GraphicsDevice.html
And the docs say that can be used for DLSS, so I started with this to implement it on URP
The thing is, its crashing, and I dont know why.
This is the part of the code thats crashing:

CommandBuffer cmd = CommandBufferPool.Get("ExecuteDlss");
DLSSTextureTable textureTable = new DLSSTextureTable()
{
    colorInput = menu.texture,
    motionVectors = menu.motionVectorsTexture,
    colorOutput = menu.colorOutput
};
device.ExecuteDLSS(cmd, context, in textureTable);
Graphics.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);```
After debugging, I think that the line with Graphics.ExecuteCommandBuffer(cmd) is the one crashing, but I dont know why. All values are initialized. Also, the documentation on this is VERY poor. Do I have to do something special, or Im just dumb and trying to do something its not possible?
#

I have an RTX 4070 btw, so thats not a problem

#

I can show more code if someone wants to

royal sequoia
#

Ok. It looks like when I try to initialize:

data = new DLSSCommandInitializationData()
{
    featureFlags = DLSSFeatureFlags.None,
    inputRTHeight = (uint)menu.texture.texelSize.y,
    inputRTWidth = (uint)menu.texture.texelSize.x,
    outputRTHeight = (uint)(menu.texture.texelSize.y * menu.urpAsset.renderScale),
    outputRTWidth = (uint)(menu.texture.texelSize.x * menu.urpAsset.renderScale),
    quality = quality
};```
The texel size value is incredibly low, and gets rounded to 0.
Im completely lost now. How Im supposed to get the texel value?
Also, this is starting to become a graphics issue, but I dont know if I should move it to [#archived-urp](/guild/489222168727519232/channel/900380950083534888/)
bleak citrus
#

texelSize is the size of a texel -- the smallest unit of texture size

#

For a square image with square pixels, it'd just be 1f / width

#

I suspect you just want to be using the height and width properties of the texture

bleak citrus
royal sequoia
bleak citrus
#

in texels

#

you're giving it the size of one texel

royal sequoia
#

Oh

bleak citrus
#

I'm unclear how texels aren't just equivalent to pixels here

royal sequoia
#

So its width * texelSize.x?

bleak citrus
#

no, that would be 1, most likely

#

imagine 100 texels equal 1 inch

#

a 3 inch by 2 inch texture would be 300 by 200 texels

#

width * texelSize.x would be 3, then

#

300 texels, 0.01 inches per texel, 3 inches

royal sequoia
#

I have a 2560x1440 pixel texture (Its the screen) and the texel size is close to 0

#

In x is 0.000390625

bleak citrus
#

what is the type of menu.texture ?

royal sequoia
#

RenderTexture

bleak citrus
#

you want to pass 2560, not 0.000390625 or 1

bleak citrus
royal sequoia
#

Its not

#

I dont know why

#

But the texture class has one if you look on the code

bleak citrus
#

huh, yeah, it does exist

royal sequoia
#

Ok, it crashed again

bleak citrus
#

did you update the output sizes as well?

royal sequoia
#

yes

bleak citrus
#

what does the code look like now?

royal sequoia
#
data = new DLSSCommandInitializationData()
{
    featureFlags = DLSSFeatureFlags.None,
    inputRTHeight = (uint)(menu.texture.height * menu.urpAsset.renderScale),
    inputRTWidth = (uint)(menu.texture.width * menu.urpAsset.renderScale),
    outputRTHeight = (uint)menu.texture.height,
    outputRTWidth = (uint)menu.texture.width,
    quality = quality
};```
#

I also changed the renderScale thing to be on the input

bleak citrus
#

since it's < 1 ?

royal sequoia
#

The small one is the input

bleak citrus
#

Right. I just figured you were using a value greater than 1 based on the original code

#

hm, well, I don't see why that'd be bogus now. definitely ask about this in #archived-urp

#

the documentation is definitely...spartan!

royal sequoia
#

It looks like they didnt spent too much time on documenting this

soft moon
#

that shouldn't be so, right?

#

I am missing something

#

My _setTextComponentCoroutine is null here, but _setTextCoroutine isn't

onyx blade
#

If I have a grid based movement system, can I use the navmesh from unity? or would it be better to write a custom pathfinding solution?
I need to call a move function between each tile, to animate the move correctly, I'm not sure I can do it with the navmesh system or I need to write my own.

#

can I leverage the navmesh and still have control over what goes on with the movememt?

sly grove
#

use standard graph pathfinding algorithms like djisktras/A*

#

as for animation that has nothing to do with the grid itself really

onyx blade
#

fair enough, shouldn't take that long to write either way

sly grove
#

that would just be interpolated motion between two points

onyx blade
#

i basically have a creature doing a hopping motion to move, which I coded to follow an animation curve.

#

I want that animation to be used for each move to adjacent grid pieces

#

not familiar with djisktras, I gotta read up on it.

tiny pewter
#

dijsktras is just f=g+0*h

#

ie nothing to do with heuristic, simply ignore it

sly grove
#

what?

tiny pewter
#

if you can write a* then you can write dijsktra...

sly grove
#

yes

#

Djikstra is A* without a goal node (and without a heuristic based on the goal node)

normal tinsel
#

Hello!
Does someone here have experience with VContainer in their projct and has a couple of minutes to help me out?

normal tinsel
#

true, my bad, sorry!
Let's then be a bit more specific.
I'm new to DI and although the documentation for VContainer covers a lot of cases they are mostly writen in a "per unit" way (e.g thats how you register interface, that's how you register prefab etc). Which is fine for someone who already has experience with other DI frameworks/libs but imo not for a new commer like me. For me the easiest way of learning new stuff is by looking at real life examples and trying to undestand them in this particullar case. Are there such examples that successfully use VContainer? Another thing that I could ask and that would help me: would be Is it worth looking on e.g zenject examples to also udnerstand VContainer or are they too different?

jolly token
normal tinsel
#

Thank you! I will look into those asap (havent seen the recommended one so big kudos!) ๐Ÿ˜„

spiral swift
#

"Shader error in 'Barracuda/StridedSlice': Bitwise integer instructions are not supported on GLES 2 (on gles)"

#

what can I do with this?

#

none of my code even does anything about shading

#

though i'm using barracuda for machine learning

#

and 2d lights

sly grove
#

what is Barracuda/StridedSlice

spiral swift
#

but they're completely separate

sly grove
#

is that a compute shader?

spiral swift
#

seems like it yeah

#

also

#

the error is only when building for WebGL

sly grove
#

ir's doing somethign that's not supproted on your target graphics framework

#

Are you sure barracuda supports WebGL?

spiral swift
#

it worked fine before I started using 2d lights

spiral swift
#

then it started giving me those errors

sly grove
#

Looks like it only supports CPU inference on WebGL

spiral swift
#

so i'm guessing the lighting is causing this?

sly grove
#

no

#

Barracuda is causing this

#

Did you read above?

spiral swift
#

yeah but i mean that it worked on webgl before

sly grove
#

It only works with CPU on WebGL according to the docs

#

so maybe you were only using CPU workers before

spiral swift
#

since i'm only using it with numbers, nothing graphically related

#

yeah

#

i haven't chagned it at all

#

oh

#

hmm

spiral swift
#

wait no

#

haven't changed the workers at all

sly grove
#

what workers are oyu using?

spiral swift
#

or anything about how I'm using barracuda

sly grove
#

which worker types?

spiral swift
#

the only thing I chagned was moving a few objects around and adding lights

#

lemmecheck

#

Worker = WorkerFactory.CreateWorker(WorkerFactory.Type.Auto, runtimeModelo);

sly grove
#

I would try using explicitly a CPU worker type

#

instead of Auto

#

see if the error persists

spiral swift
#

yeah

#

i'll see

#

@sly grove i didn't get an error.........but for some reason none of my UI loads

#

it's supposed to be like this

#

it works well when building it for PC

spiral swift
#

"[.WebGL-000049E802774D00] GL_INVALID_FRAMEBUFFER_OPERATION: Framebuffer is incomplete: No attachments and default size is zero."

#

@sly grove

sly grove
#

No idea what that means

#

Google it

spiral swift
#

wait

#

seems like i was still using GPU

#

lemme check once more

spiral swift
#

I think I'll just do it on PC and give up on WebGL

flint shore
#

I don't know exactly which text channel to say this on but

#

Is it possible to change the color of a sprite of an unlit/Transparent type material?

#

I tried with a simple material.color through code but it still doesn't work

gilded palm
#

hi, if i instanced an animation clip, how can i save it with code so it would work even on the build version of the game

#

i really need help with this

long ivy
#

save the instance with AssetDatabase. Unless you mean create at runtime in a build, in which case you'll have to store the data you used to create the clip instead and re-create it

gilded palm
#

Ok

gilded palm
#

Just wondering since I would rather spent my time working on the other parts of my project than working on saving files

long ivy
#

so this is saving at runtime? You can save your data however you want

gloomy mica
#

How to preserve assembly's all classes and their default constructors in link.xml?

tulip jetty
#

Hello guys! Is there any way to localize visual scripting string nodes using unity's localization system? Thanks!

stuck plinth
gloomy mica
#

[Preserve] on top of each class can do the trick, however there are too many classes

open laurel
#

I again abstracted it into an utility class, but stepping through the code this is what I'm doing

var target = new RenderTexture(128, 128, ...);
var material = new Material(Shader.Find(...));

var handles = new RTHandleSystem();
handles.Initialize(128, 128);

var front = handles.Alloc(target);
var back = handles.Alloc(Instantiate(target));

front.rt.Create();
back.rt.Create();

var commands = new CommandBuffer();
commands.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.Ortho(-1, 1, -1, 1, -1, 1));
CoreUtils.SetRenderTarget(commands, front);
Blitter.BlitCameraTexture(commands, back, front, material, 0);

Graphics.ExecuteCommandBuffer(commands);
ctx.AddObjectToAsset(target);
#

if I paste this code (filling in the ...s for my shader and texture format) on a monobehaviour's Update method it works, yet if I run them in an importer's OnImportAsset it doesn't sunglasses_in_tears

novel talon
#

whats up guys, i recently have been working with customs srp and shaders. If i move my game window at all the games fps drops to around 5ps. Note this only happens in the editor, if i build the game and play it on any device it runs fine.

On my profiler im getting 99% on FlushCounters.

Any help would be great!

craggy spear
#

Dont cross post. Delete that q from here and u-talk, and ask in #archived-shaders ... but with more info or you'll get ignored there too

plucky trellis
# open laurel I lied, i meant "to-workday-morrow". So, I just tried using the RTHandle-based m...

Because it's running in an importer, you need to (probably) create your own RTHandleSystem(), which I noticed you did. Looking through the docs, It seems that you might need to run handles.SetReferenceSize(width, height); after initializing the system, the docs are a bit unclear, but check under "Updating the RTHandle System" on this page https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@12.0/manual/rthandle-system-using.html.

This might be redundant, since you might be setting this value in Initialize(), but that's what I can think of off the top of my head.

novel talon
craggy spear
#

but it's.. shader code, yes?

modest sinew
#

i dont know if this belongs here in advanced but here we go anyway.

so im developing a package to easily load in multiple scenes, part of it using async. The SceneManager.LoadSceneAsync() returns an AsyncOperation which is not an awaitable task that can be cancelled by cancellation tokens by default. That is where UniTask comes in which allows users to do await SceneManager.LoadSceneAsync("myScene").WithCancellation(token);

my question is then, does this properly handle the scene so it is unloaded from memory?
from what i have talked to other people this might simply kill the operation without handling the unloading, the readme for the package doesnt mention anything about this specifically.
and secondly is there any other ways i could cancel and unload a partially loaded scene? from googling the common answer seem to be no, but none of those posts mentioned UniTask either so shruggie

candid shore
#

actually i think my wuestion goes in brignners

#

sorry guys wrong section

open laurel
# plucky trellis Because it's running in an importer, you need to (probably) create your own RTHa...

I thought so too but it didn't make a difference.
I got some progress, if you could call it that, by not using an externally created RenderTexture as the input for the Alloc calls, instead passing the creation arguments directly to it.
However, that causes the resulting RTs to be somehow different, as I couldn't store them in the asset. So I'm copying it to a Texture2D as a last step using CopyTexture, which gives me... Something?

#

actually let me make a thread for this to not hog the channel (should have done so sooner sorry)

past silo
#

Hello and sorry to get you intrigued!

Let me introduce the wall of text. I have struggled with this for an hour and a half now, before i decided to check up with the pros over here :).

I have an gameobject in my scene, whitch is inherritate from Interactable, and is also on the layer "Interactable".

When i interact with the gameobject, i want to "Activate a quest", and spawn a random item. I might have nested myself into the doom of code, but please check if you can point me in the right direction ;D.

There is a huge wall of text, but im mainly experience some errors on the "Interact" function in "TakeAquest", line 223 in the Codeshare-link! https://codeshare.io/24Aj4K

fresh salmon
#

some errors on the Interact function
What errors?
abstract class Interactable, methods Interact, ActivateQuest: as they're not meant to have code in them, they should be abstract, not virtual

past silo
fresh salmon
#

Yeah, abstract methods don't declare a body { }

#

End them with a semicolon

#

public abstract void Sample();

#

This now forces the inheriting classes to implement the methods, whereas with virtual, it was optional

past silo
#

Awesome, well its getting somewhere, but im getting this problem now

StackOverflowException: The requested operation caused a stack overflow.
Interactable.BaseInteract () <0x20dd4e77f40 + 0x00008> in <102e6767c7284913bc07b0deef5c95a6>:0
TakeAQuest.Interact () (at Assets/SCRIPTS/Intreact/Objects/TakeAQuest.cs:11)
Interactable.BaseInteract () (at Assets/SCRIPTS/Intreact/Interactable.cs:25)

fresh salmon
#

Sweet, infinite recursion

past silo
#

Sounds sweet! ๐Ÿ˜„

fresh salmon
#

A method is calling itself uncontrollably, which exhausts the memory space it was given

#

I see it, TakeAQuest's Interact executes BaseInteract, which executes Interact, which executes BaseInteract, which executes Interact...

past silo
#

I think i managed to solve that perticular Infinite Recursion,

I had "double" interacts here, i guess that triggered it. The TakeAQuest-script is only suppoed to use the "ActivteQuest"-method.

#

Thanks alot SPR2, now im on the road again!

gray hound
#

Is there a way to compare a AssetBundle object to a local assetbundle file?
Unity knows to throw an error you try to load an assetbundle that has already been loaded, so I'm sure its possible, but there's no exposed method in the documentation that I can find. And I'm not downloading an AssetBundle so I can't compare raw bytes either. I'm just loading an assetbundle from disk, and as far as I can tell, there's no way to compare an assetbundle file and an assetbundle object.

scenic forge
# modest sinew i dont know if this belongs here in advanced but here we go anyway. so im devel...

I haven't looked into it myself, but UniTask is open sourced so you can check it out: https://github.com/Cysharp/UniTask/blob/master/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs#L28

GitHub

Provides an efficient allocation free async/await integration for Unity. - UniTask/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs at master ยท Cysharp/UniTask

icy smelt
#

You guys know how I can prevent one CharacterController from pushing the other using the "Physics Contacts API"?

sly grove
sly grove
#

though it may "depenetrate" if it finds itself inside some other collider

icy smelt
#

Yes

sly grove
#

physics contacts api won't help you here

#

if you want them not to collide, you should be able to use layer based collisions

icy smelt
#

There is the point

#

They should collide, but only enemies can depenetrate

#

Not the player

#

And both uses CharacterControllers

sly grove
#

I don't understand what that means

#

what kind of gameplay interaction are you trying to create

icy smelt
#

I'm porting a raycasting engine game to Unity, so physics interactions there aren't the same as Unity ones

sly grove
#

That's not really an answer to the question.

icy smelt
#

A bit of patience, let me explain it

#

In the original engine, the player do collides with enemies, etc, but the player position never changes when a given enemy (character controller) collides with it

#

But the enemy position can change in response to colliding with player

#

Eg: it can be pushed away when colliding with player

#

Maybe it is something with my code, but it looks like character controllers are pushing each other (there is a depenetration at both controllers, player and enemy)

#
#

Characters pushing each other

sly grove
plush hare
#

@icy smelthttps://docs.unity3d.com/ScriptReference/Physics.ComputePenetration.html

#

Here's something you should look into

#

You can essentially write your own bare depenetration algorithm for a completely custom character controller

icy smelt
#

The contact modification api does nothing in this case?

#

Afaik, it can be used to modify collision response

#

And it works with character controllers

#

I mean, I havent used it yet bc I dont fully understand it. That is why Im unsure about it

plush hare
#

It completely depends on what you want. If you want to design exactly how your character responds to collisions on a movement basis, then ComputePenetration allows you to do that

#

You can make your enemy AIs depenetrate out of the player, but not the other way around

icy smelt
#

That is the goal

plush hare
#

You're essentially making your own CharacterController component with the link above

#

this doesn't use rigidbodies

#

and therefore won't react to physics in any way

icy smelt
#

I guess I will keep the map character collision the same and use computepenetration for special cases with other characters

plush hare
#

You can't use this on top of CharacterController

#

you would have to write your own solution

icy smelt
#

I already have a kind of rigidbody based character controller, but not using it yet

#

I see no reason why I cant use the depenetration with a character controller

#

If I disable character/character collision

plush hare
#

Since that's it's only purpose.

icy smelt
#

I just cant let characters push each other

#

Maybe checking their next moving position and prevent them from moving at all

#

Instead of depenetrating them

plucky laurel
#

@icy smelt this may be a long shot, but you can set up parallel physics world, or do it in the same, you create rigidbodies that sync to cc's, and if collisions between rbs happen you snap cc's to rbs

#

this may also not work at all

#

yeah it wont

icy smelt
#

I guess simply prevent characters from moving when any collision will happen is going to work

#

I mean...

#

They can collide with each other and the map at the same time

#

hmm

#

I guess it is going to work (prevent them from moving)

plucky laurel
#

sure but it will require you to handle it the same way you handle walls

#

collide and slide

#

otherwise they will get stuck in each other all the time

icy smelt
#

Doing an overlapcapsule on the target position adding the moving delta magnitude as the capsule radius seems to work

#

I simply prevent enemies from moving when that happens

#

Have to test it better

hoary plinth
#

Does anyone know of a resource that would contain a full map of all fields and properties of a monobehaviour? I'm working on writing some Asset Code for managing save data. I'm considering using reflection to save and load all fields/properties (Including Base Classes) that have setters both public and private. However, I know monobehaviour has allot going on under the hood so it would be nice to see what all is included so I can understand what all would be saved.

sly grove
#

Or any existing serialization tools like Newtonsoft JSON, MessagePack, etc

novel plinth
#

Unity supports STJ too now since 2022.2

#

stj in Unity is weed! ๐Ÿฅน

hoary plinth
# sly grove What's wrong with Unity's existing serialization mechanism

I'm trying to write it generically for a unified saving system. I'm admittly not well versed in Unitys serialization so forgive me if I'm missing something. I've already written a system for storing a list of a specific type. Deserializing that is pretty straight forward. However, I'd like to be able to inherit from Monobehavior and extend it, so it can automaticly handle collecting data that needs to be saved on an event, hand it to a storage container, which then hands the all the data collected into a dataserializer to be saved to file via binaryformatter. In the load event we deserialize the saved data, but we can't just create a new instance of the saved class, we need to transfer the values to the fields and properties of the existing class such as with a component on a scene object, right?

hoary plinth
sly grove
#

Perhaps just combining that with reading/writing to/from a file

#

That's all a save system is of course

#

But basically you can just use an existing serialization library rather than writing your own

sly grove
#

And no, serializing Monobehaviour is usually a bad idea

hoary plinth
obtuse remnant
#

Anyone know ArborXR or got advice about packaging content for remote distribution to clients?

Basically, like localization but we need to swap out specific materials and prefabs, as well as sometimes run completely different scenes etc.
I can script all the changes, so there's a scriptable asset that we can call a public method on that sets everything we need. This way (I believe) when we do a build it won't include the scenes or prefabs if nothing references them directly. (And yes, we'll need to update the scenes listed for the build)

What I don't know is how we should manage this, especially long term. We distribute via ArborXR, and I don't know if I can distribute separate "asset packs" or something to automatically push to the clients. I know if we've got everything in a build we can push it to the clients, so I'm thinking for step 1 to just make a separate build for each client.

But it'd be WAY nicer, of course, to make one build and have the content separated somehow, so the clients still get both but they can all get the same actual "product build" and separate "content"

I know the basics for things like addressables, and I can look up more info. I'm mostly hoping for someone who's done something similar to say "Yeah, you can send out content with ArborXR" or "don't bother using addressables, manage it directly in the build by doing X" or "Yeah, just use addressables" or whatever ๐Ÿ™‚

cloud badger
#

I'm sorry to add another question on top of yours, but would anyone know how to get around this?

#

I'm writing an encoding/decoding bytes script for my multiplayer game and I'd like to have an all-encompassing function that just lets me convert an array of bytes to whatever type I pass in

#

i was able to get this to work here for doing a switch based on the type of an argument passed into a function, but I don't know how to do this just based on a type

#

i know this isn't really the best workflow but it would be incredibly helpful for what i'm working on and any advice would really help <3

#

there's also a question above this one

#

i was thinking of using "out T variable" but it would be really clunky to use and i'd like not to if possible

flint sage
#

Can't you just do an if instead?

cloud badger
#

i could but i was really hoping i wouldn't have to do that either

#

it's a bit more complicated than it'd need to be but i could just fall on that if nothing else works

flint sage
#

Switch vs If is not that different really

cloud badger
#

i know i was just hoping for cleaner code :(

flint sage
#

Anyways, I don't think you can make it work with a switch

plucky laurel
cloud badger
#

well actually hold on i couldnt do that anyways

#

i cant return any type i want it needs to be of type T

#

how should it be done?

flint sage
#

cast it to T

cloud badger
#

i can't

flint sage
#

Oh yeah you gotta cast it to object first

#
            return (T)(object)true;```
plucky laurel
#
class Converter{
    
}

abstract class Converter<T> : Converter
{
    public abstract T Convert(byte[] bytes){}
}

class IntConverter : Converter<int>
{
    ....
}

class Converters
{
    Dictionary<Type, Converter> converters;

    public T Convert<T>()
    {
        Converter<T> converter = converters[typeof(T)] as Converter<T>;
        return converter.Convert();
    }
}
#

this is almost pseudocode i hope you understand it

cloud badger
#

that would work too

#

thank you both, i think i have a lot of rewriting to do

random dust
#

Did you try it?

#

STJ is not supported for variants of .NET Standard (which is what unity uses) so unless you messed with the linker there's no way you can get it to work on Unity.

novel plinth
#

bruh, been using it since 2022.2

#

download the nugget package extract to your project folder

#

set the linker so it won't get stripped by il2cpp and works on webgl (Mono is fine)

#

it's been working since 2020, but the difference is that it used to not take advantage of Span<T>... but now it does

random dust
novel plinth
#

the setup is far from difficult atwhatcost .. just copying the dlls and set the linker

random dust
#

So if you used STJ, I can only assume you are using some fork that has been adjusted to build with .NET Standard

novel plinth
#

uh, no?

random dust
#

Then what is the issue? ๐Ÿ˜„

#

That's not exactly something the average user is going to do though

novel plinth
#

in what context that do you think the linker is difficult? it's just xml ๐Ÿ˜„

random dust
#

Perhaps not for you, but it strafes away from the usual setup

novel plinth
#

it's much faster and less alloc than newtonsoft's, two important things when talking about stj

random dust
#

Whatever, there's no use bickering back and forth. My point is that STJ is not supported because the version does not match what Unity allows, and you need extra work to make it work. I think that was proven already, but feel free to explain how easy it is to set it up for those that have no idea

austere jewel
#

NuGet, please stop with the double g notlikethis

novel plinth
#

mb

#

and it did finally supported

random dust
#

Nice, I was actually under the impression that the steps were way harder than described ๐Ÿ‘

novel plinth
#

they're not hard really ๐Ÿ˜†

random dust
#

Granted, too bad it still requires all this work, but I do agree it's a step ahead compared to Newtonsoft

novel plinth
#

oh no, the turtle Newtonsoft that keeps spewing unnecessary allocations... yeah stay away from that prick ๐Ÿฅน

desert hare
#

I am trying to make selectable objects through scene (editor) view but im unable to identify what's the issue with the cursor, when i tested the mouse position it felt like it was working properly but it feels broken on the monobehaviour, perhaps i didn't write a proper solution, i need help spotting what's wrong

Monobehaviour:

        /// <summary>
        /// Selects a transform based on the mouse position in the scene view.
        /// </summary>
        /// <param name="mouseWorldRay"></param>
        /// <returns></returns>
        public Transform TransformClosestToCursor(Ray mouseWorldRay)
        {
            Transform closest = null;
            foreach (Transform obj in transforms)
            {
                var objAccuarcy = Vector3.Dot(mouseWorldRay.direction, obj.position - mouseWorldRay.origin);
                var closestAccuarcy = closest == null ? 0 : Vector3.Dot(mouseWorldRay.direction, closest.position - mouseWorldRay.origin);
                if(objAccuarcy > closestAccuarcy)
                    closest = obj;    
            }

            return closest;
        }

Editor script:

        private static Vector3 MousePosition => Event.current.mousePosition;
        private static Ray MouseRay => HandleUtility.GUIPointToWorldRay(MousePosition);
        void OnSceneGUI()
        {
            _target = (CollisionBuilder) target;
            _target.CalculateClosestTransform(MouseRay);
        }
sick hound
#

!code

thorn flintBOT
#
Posting code

๐Ÿ“ƒ Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

๐Ÿ“ƒ Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

modest vale
#

can someone think of a more efficient way to check for bounds collision than checking for each point if it is in the other bound and vise versa?

bleak citrus
#

are these axis-aligned bounding boxes?

modest vale
#

yes so the bound is just defined by a vec3 btmL and a vec3 topR

modest vale
#

that s great but it does not explain how efficient bound collision is calculated

modest vale
#

thank you very cool

jolly token
#

Did you share it as editable? Someone sabotaged it

past silo
jolly token
past silo
jolly token
past silo
#

And its different on all t he quests im creating ๐Ÿ˜„

jolly token
#

So that sounds wrong

past silo
#

Well, actially, the Transform is a prefab, haha. It is a shitshow. But okey, that is actually the problem

#

The problem is, the Transform aint being spawned

jolly token
#

So your log message is wrong or your condition is wrong

flint sand
#

I ils like to implement a local avoidance for a group of units, similar to RTS behavior. Is there any suggestions how to implement this?

dusty wigeon
# cloud badger

Just to add to what has been said consider the following. The Get method will return an exception while the Get2 will not.

// Online C# Editor for free
// Write, Edit and Run your C# code using C# Online Compiler

using System;

public class HelloWorld
{
    public static void Main(string[] args)
    {
        try
        {
            var t = Get<float>();
            Console.WriteLine ($"The result is: {t}");
        }
        catch(System.InvalidCastException e)
        {
            Console.WriteLine ("An Exception has been launch for var t = Get<float>() !!!");
        }
        
        try
        {
            var t = Get2<float>();
            Console.WriteLine ($"The result is: {t}");
        }
        catch(System.InvalidCastException e)
        {
            Console.WriteLine ("An Exception has been launch for var t = Get2<float>() !!!");
        }
    }
    
    private static T Get2<T>(){
        if (typeof(T) == typeof(float))
            return (T) Convert.ChangeType(GetValue(), typeof(float));
            
        return default(T);
    }
    
    private static T Get<T>(){
        if (typeof(T) == typeof(float))
            return (T)GetValue();
            
        return default(T);
    }
    
    private static object GetValue()
    {
        return (object)0;
    }
}
trim vine
#

I designed a chart that explains how Unity developers can create a form of lagless frame generation

#

This applies to any framerate to any framerate, even though it was part of an article about enabling-tech for future 1000Hz displays.

#

Hope the chart is useful to devs (VR, etc) looking to fix reprojection lag (timewarping, spacewarping) and remove double-image artifacts (etc) on some displays.

The article is up at blurbusters too, and there is a "Developer Best Practices" chapter ( blurbusters.com/framegen#dev ), from our tests.

Unity-powered source code is linked over there, although it is very Wright Brothers (simple graphics, doesn't implement all best practices yet). LTT covered it at https://www.youtube.com/watch?v=IvqrlgKuowE but my article now links to the Unity source code of the lagless framegen demo!

Get up to 25% Off Pulseway's IT Management Software atย https://lmg.gg/PulsewayLTT

Save up to *40% off and get Free Worldwide Shipping until Dec. 22nd at https://www.ridge.com/LINUS

What if you didnโ€™t need the best frame rate to reduce input latency? What if your displayโ€™s refresh rate was enough all on its own? With Async reprojection, anythin...

โ–ถ Play video
tired fog
#

I have a native array, or a mesh, containing the vertices position, i need to use them on a compute buffer, what's the best way to do it?

tired fog
#

Im not sure how I would use that

tired fog
#

Im still not following, i know what the compute buffer and shader is. Until know I've been mapping the height of the vertices and passing that to the compute shader as a texture. But I'm wondering if there's a shortcut to transform a Native Array into a compute buffer

#

This Append compute buffer is a compute buffer than can get it's size increased through append, which is nice, but not surr how it's relevant

dusty wigeon
bleak citrus
trim vine
# bleak citrus i watched stinger (the guy who made that reprojection demo) develop that thing i...

I have tried to reach out to him, to ask what source code license he put on the code that he linked to. The source code is linked from the blurbusters article, from the link on the YouTube channel, but there is no LICENSE file.

I personally want to light fire under manufacturers, game engine makers, and API vendors. Just need to give due credit.

I suggest MIT or Apache 2.0 for maximum industry impact, with name credit mandatorily in lights

bleak citrus
#

I'll ask him about it

#

he said he meant for it to be public domain. he also said the code is, to quote, "cringe" and that he didn't expect people to want to re-use it :p

#

probably needs some prettying up

plucky laurel
#

so its not theoretical?

trim vine
#

Tell him to put a CC-by-SA 0

#

Some countries doesn't permit public domain without a "license"

#

So that's the defacto "public domain" license.
It may be cringe, but some people will still try to play with it anyway. Be amazed how such simple code pulled it off. And take upon challenge to rewrite a better implementation

bleak citrus
#

just for using reprojection to make mouse look nice and smooth even with awful framerates

#

3kilksphilip has a good video on the topic https://www.youtube.com/watch?v=f8piCZz0p-Y

DLSS 3's framerate doubling feature is all well and good, but that lag is painful. But... what if there was a way to reduce it? Welcome to the wonders of Framerate Independent Mouse Movement.
Download Comrade Stinger's demo here: https://drive.google.com/file/d/1lSONJxTz3ThsKSoYwm7lP3sAuYN5rLyg/view
It took him one evening to make, and another f...

โ–ถ Play video
#

well, 2kliksphilip

#

close enough

plucky laurel
#

havent watched him in a while, thanks

trim vine
#

Brand new article that went up yesterday

#

I am lighting a fire

#

I have over a hundred friends at GPU employees

bleak citrus
#

basically, you can warp the last frame's image a bit to create a new image

#

you can do this for both translation and rotation

#

possibly including the depth buffer to figure out how to do the parallax correctly

#

It's very fast compared to rendering a whole frame

trim vine
#

Yes. Needs to be built into FSR 3 / XeSS 3 / DLSS 4

bleak citrus
#

This is already done in VR.

trim vine
#

And built into Unity and Unreal

#

For desktop use

bleak citrus
#

It's why I don't immediately die when I'm in a VRChat instance with 80 people in it

trim vine
#

To replace BFI and ULMB

bleak citrus
#

my framerate is like 20, but my head motion is still handled at a high refresh rate

#

you'll have to explain what those are :p

#

i'm not terribly familiar with stuff like strobing and monitor motion blur

trim vine
#

However, VR needs to stop flickering. Not everyone can handle flicker. Flicker is great, but we need to kill blur strobelessly in future

#

So to go strobeless AND blurless, we need 1000fps 1000Hz reprojection

#

Reprojection at 8x+ ratios can be commandeered as strobe free low persistence sample and hold

#

Ergonomic PWM free blur reduction. And only reprojection can easily do 8x ratios or better at low compute cost

#

Tests show we can reproject to 1000fps on RTX 4090 already!
Imagine 1000fps pathtraced graphics on near term GPUs.

#

Read the new article to see why I am so freaking excited when testing on my prototype displays

#

I work for display manufacturers

#

I am in 25 peer reviewed research papers

mortal igloo
#

I was summoned ๐Ÿ‘€

trim vine
#

But what source code license does your reprojection sample use?

#

Since I have hundreds of friends at AMD and NVIDIA I am trying to light a few fires.

mortal igloo
#

haha yeah fen informed me, I love how far it went, really hope more people do research into it

#

hell yeah

trim vine
#

But companies (in some countries) won't touch unlicensed code

#

Public domain code should have a CC-by-SA 0

#

Or use MIT or Apache 2

bleak citrus
#

you mean CC-0?

#

CC-BY-SA-0 is a contradiction

mortal igloo
#

thing is too, my demo doesn't actually do asynchronous reprojection. It runs as fast as it can and "simulates" a low framerate, which it then reprojects.

#

so the only interesting part of it is the reprojection code itself, but I feel any competent graphics programmer should be able to re-implement that part pretty easily.

#

the hard part (which I have not done) would be spinning up a separate higher priority render context and then coercing unity into using it

bleak citrus
#

that sounds scary

mortal igloo
#

yeah.. as far as I understand this is how VR games do it. It's almost like two games running at the same time. one renders the game, the other does reprojection. and the reprojection one is allowed to interrupt the game one whenever it feels like it

bleak citrus
#

i was about to say

#

i wonder if you could just make two games lol

mortal igloo
plucky laurel
mortal igloo
#

yeee

trim vine
# bleak citrus that sounds scary

Then tell Unity developers to make engine compatible with the algorithm. We need to refactor the rendering ecosystem to be friendly to this

plucky laurel
#

that sounds like it will never happen

dusty wigeon
#

@trim vine Would you already be able to do so with Scriptable Render Pipeline ?

plucky laurel
#

at least not by unity hands

trim vine
#

But ideally it should be same process, possibly as a third party library.

plucky laurel
#

im saying its unlikely unity will lift a finger

#

im not sayings its not possible

trim vine
#

We can still tip a few dominoes, even if others have to do the heavy lifting

#

It's a full decade iteration

#

240Hz OLEDs are flooding inwards and they benefit from warping/reprojection way more than LCDs

#

480Hz OLEDs roadmapped 2025ish

plucky laurel
#

something like create a working tech, paper, and visit siggraph with it

trim vine
#

Maybe I will for 2024 or 2025, but I'd have to find funding (or Patreon it)

mortal igloo
#

this article goes into how to do it in DirectX 12
but yeah, non-trivial. would very likely require engine modification to work right

trim vine
#

The main rendering thread may need to be paused mid-render to let a secondary thread do a surge execute to reproject a previous frame. That'd be 2000 context switches for 1000fps, but not altogether impossible on certain GPUs.

Some cache/pipelining optimization needed, but, we gotta tip some dominoes on that if it framegen is ever to be used in esports

We can begin with reproject/warping any low frame rate to 240fps for the OLEDs that has more
dramatic 120-vs-240 visibilities than LCDs

Tsunami flood of 240Hz OLEDs coming

#

critical mass to help devs be more interested in all this.

#

Could be added to FSR 3 or DLSS 4

#

Which would help Unity need to do minor tweaks to not underperform with those, and even more important if a future Vulkan later this decade gain some (more) warp-related helper APIs (etc)

#

It's all about tipping dominoes - have 3 more framegen related articles planned this year

azure moss
#

i am doing culling stuffs
culling can do that
where it keeps record of transition and states only
but gets back on track after turned on
in my case i dont want animations to be played at far distance
at the same time i want to turn on and off however i feel like it

#

anyone?

#

posting this because its advance code stuffs

hard lily
#

@azure moss Not really advanced, you can just measure the object distance to your camera and if it passes a certain threshold you can disable the animator component or change the animation to idle / however you want.

#

So, just create a script that references the camera and the animator of the object it is in, then check how often you want for distance -> disable animator / change animation to idle, vice-versa.

wicked shell
#

or did i missunderstand

azure moss
#

Let's say its fine you turned off