#archived-code-general

1 messages Β· Page 435 of 1

cold parrot
#

what you say there is the global access issue

misty drift
#

I mean that unity a bit fragile regarding configs in editor.

cold parrot
#

using a DI container to solve that is maybe a bit off the side.

#

it also doesn't solve it entirely, you loose all static code analysis regarding dependencies

misty drift
#

may be u right, I don't have much expirience with Unity. And generally guides/tutorials doesn't go too deep on design. So try and error is a way for me at the moment.

misty drift
cold parrot
#

you can check for missing references.

misty drift
#

I mean i see if I run program and I can check manually. Is there way to do it automatically?

#

maybe I'm misunderstanding smth

cold parrot
#

personally i think many ideas from DI are very valuable, i just don't like to have a framework dictate which ones we use in a project πŸ˜‰

cold parrot
#

what i like to do is make static editor references for everything thats part of a scene and use a service locator (basically a container) to lookup the managers/systems that any dynamically spawned objects belong to, register themselves with that manager and have that manager manually inject the dependencies OnRegister.

#

i find the ceremony that creates strikes a balance that it makes people think of how they want to organize their systems and offers sufficient resistance to "just inejct one more thing" while also making it easier to setup, debug and robust.

#

if you pair that with asmdefs for all primary systems and design your systems in a layered way, the project can partially self-guide a developer to a correct solution by offering a path of least resistance that we actually want to take.

misty drift
#

yep, I tried to do it with asmdefs, but it's too much for me for now - i spent a lot of time on design, while not having enough expirience. as a result I had a lot of code to support design, but had very few fetaures) As of now I'm going with "go fo features" and "refactor when it's needed". Since I'm doing sorta pet project myself, it works for me. for bigger projects focourse it wont work)

#

But you right, I need to be more carefull with injections, since it becomes spagetti quite fast.

low scaffold
#

Is there a way to access the C# 10.0 file-scoped namespaces feature in Unity? Would like to make use of namespaces for my current project, but adding an extra layer of indentation is a bit aggravating.

steady bobcat
#

no because unity uses an old version of mono

quaint rock
#

unity 6 is on C#9 feature wise but also is missing a few features

#

also namespace per file is more namespaces then i would want, and would not worry about 1 extra indentation level

night harness
#

i dont know if "don't worry about it" is a valid response to someone's problem lol

chilly surge
#

IIRC file scoped namespace is a compiler feature not a runtime feature, so you could get it to work in Unity by patching the compiler binary to a higher version

#

But eh, I wouldn't recommend it.

cold parrot
agile axle
#

Hey folks! Have run into quite the doozy of a bug, and there's nothing online I can find to help.

We have one user who is experiencing a crash just after opening our program. The issue is a StackOverflow exception originating from the Cursor.SetCursor() function.
This works on thousands of other devices, so I assume it's something specific to the user's machine that's causing it. If anyone has any ideas on how to troubleshoot this one, it would be mighty appreciated.

Stack trace below:

StackOverflowException: The requested operation caused a stack overflow.
at (wrapper managed-to-native) Interop+Kernel32.DeleteFilePrivate(string)
at Interop+Kernel32.DeleteFile (System.String path) [0x00008] in <694551e795764b938030a3128fac2b36>:0
at System.IO.FileSystem.UnityDeleteFile (System.String path) [0x00000] in <694551e795764b938030a3128fac2b36>:0
at System.IO.FileSystem.DeleteFile (System.String fullPath) [0x00000] in <694551e795764b938030a3128fac2b36>:0
at System.IO.File.Delete (System.String path) [0x00014] in <694551e795764b938030a3128fac2b36>:0
at (wrapper managed-to-native) Interop+Kernel32.DeleteFilePrivate(string)
at Interop+Kernel32.DeleteFile (System.String path) [0x00008] in <694551e795764b938030a3128fac2b36>:0
at System.IO.FileSystem.UnityDeleteFile (System.String path) [0x00000] in <694551e795764b938030a3128fac2b36>:0
at System.IO.FileSystem.DeleteFile (System.String fullPath) [0x00000] in <694551e795764b938030a3128fac2b36>:0
at System.IO.File.Delete (System.String path) [0x00014] in <694551e795764b938030a3128fac2b36>:0
at (wrapper managed-to-native) Interop+Kernel32.DeleteFilePrivate(string)
at Interop+Kernel32.DeleteFile (System.String path) [0x00008] in <694551e795764b938030a3128fac2b36>:0
at System.IO.FileSystem.UnityDeleteFile (System.String path) [0x00000] in <694551e795764b938030a3128fac2b36>:0
at System.IO.FileSystem.DeleteFile (System.String fullPath) [0x00000] in <694551e795764b938030a3128fac2b36>:0
at System.IO.File.Delete (System.String path) [0x00014] in <694551e795764b938030a3128fac2b36>:0
at (wrapper managed-to-native) Interop+Kernel32.DeleteFilePrivate(string)
at Interop+Kernel32.DeleteFile (System.String path) [0x00008] in <694551e795764b938030a3128fac2b36>:0
at System.IO.FileSystem.UnityDeleteFile (System.String path) [0x00000] in <694551e795764b938030a3128fac2b36>:0
at System.IO.FileSystem.DeleteFile (System.String fullPath) [0x00000] in <694551e795764b938030a3128fac2b36>:0
at System.IO.File.Delete (System.String path) [0x00014] in <694551e795764b938030a3128fac2b36>:0
at (wrapper managed-to-native) UnityEngine.Cursor.SetCursor_Injected(UnityEngine.Texture2D,UnityEngine.Vector2&,UnityEngine.CursorMode)
at UnityEngine.Cursor.SetCursor (UnityEngine.Texture2D texture, UnityEngine.Vector2 hotspot, UnityEngine.CursorMode cursorMode) [0x00000] in <ac95ed96621641249c5b2cf74e341b4b>:0
at CursorManager.SetCursor (CursorManager+CursorHovering hoverMode) [0x00014] in <6e83f6c4bf5f4c66a3cb9e8f835d6063>:0
at CursorManager.Awake () [0x0003c] in <6e83f6c4bf5f4c66a3cb9e8f835d6063>:0

leaden ice
#

Perhaps isolated to whatever hardware or operating system version the user is on

#

Do you happen to have those details?

agile axle
#

All I've got is that it's Windows 11. It's a very low-tech-skills user, so stepping them through the process of getting more detailed system specs will be a challenge

hexed pecan
#

Why does FileSystem have a unity-specific class/method πŸ€” (I don't really know how these things work)

leaden ice
hexed pecan
#

πŸ§™β€β™‚οΈ

steady bobcat
#

well you can view the il2cpp generated src from a build so that may reveal some info

agile axle
steady bobcat
#

managed mono only, if this is a call to native engine code it wont help much

agile axle
steady bobcat
#

where I work moved to enterprise so soon i get to view the unity source which sounds useful for stuff like this 🧠

agile axle
#

It's been tempting to grab it. Worried about being locked to a specific version though. The ~20k price tag is a lot as well πŸ˜›

steady bobcat
#

yea i know it can be expensive. hopefully you can figure it out without

agile axle
#

Fingers crossed. Worst case, a refund for this extremely rare bug is cheaper

dense pasture
#

there a way to correct that tilt? thats the general camera perspective (static camera) and it's getting noticable tilting. Whats the correct math here? google-fu failing me. maybe its the shader i'm using (distance field)

#

(line 105 is where its facing the camera), dont think the rest is having any effect here but just in case

leaden ice
# dense pasture

you want it to look not at the camera but at the nearest point on the camera's plane sounds like

#

So you could do this:

Transform camXform = Camera.main.transform;
Plane camPlane = new(camXform.forward, camXform.position);
Vector3 lookAtPosition = camPlane.ClosestPointOnPlane(tmp.transform.position);
Quaternion rotation = Quaternion.LookRotation(lookAtPosition - tmp.transform.position);
tmp.transform.rotation = rotation;```
agile axle
# dense pasture

I think it's just a function of having a perspective camera. It looks tilted because of the angle it's on

dense pasture
#

The tmp is set to orthographic

agile axle
leaden ice
agile axle
#

What you'll likely need to do is figure out the apparent rotation of the text in the axis from the camera to the text, then rotate the text around that axis so that it appears straight.
I'm about to head to bed, so I definitely don't have the mental space to figure that code out

#

Since it's facing the camera already, you're basically just creating a W axis along that Vector and rotating the text around it

dense pasture
#

easy fix

#

Quaternion rotation = Quaternion.LookRotation(tmp.transform.position - lookAtPosition);
just had to reverse that line

leaden ice
#

Yeah since it's really the back of the TMP you need to see

blissful bay
#

Anyone have much experience with Unity Terrain & Trees? I have an open world which contains a very large amount of trees.
I'm adding "destroying" to the trees. But currently I have to map every tree on game load into a spatial map, then when a player tries to break a tree, do a lookup find the tree index ect.
Then when they actually break it, I have to swap out the prefab index, to a "hidden" tree (blank prefab effectively)
Then I have to swap collision on and off for it to recalculate my new prefabs collision (if i don't do this the old trees collision remains)

Is this a poor design choice? Should I be using game objects for trees, not terrain data. Then despawn them far from the client? (I have a server that I've mapped all terrain trees so that I can send tree information to the clients given they are close enough)

The other solution I thought of was a hybrid approach where I keep the trees on the terrain but disable collision, and spawn box colliders over the trees.

I'm finding some conflicting information from what i've read. Curious if anyone has ever dealt with this. Thanks!

agile axle
#

IIRC Unity's terrain system is rather inefficient. Gameobjects with occlusion culling and LoD/fading out at distance with box colliders should be very performant

#

I'd probably go the gameobject route personally. Also gives the option for further functionality that the unity trees system can't provide

blissful bay
#

Thanks for the info!

cold parrot
latent latch
#

Oh uh. I thought it was the other way around. The terrain provides a brush to instance the trees while removing the overhead of using gameobjects

#

Makes sense to make them GOs if you are destroying them though, but then you need to compare batching all of them vs chunking

mossy shard
#

How can i stop a 2d object from rotating? When i change it's linear velocity it tends to rotate on the z axis, and when i set from code it's rotation to always be 0 it's twitching

latent latch
#

Rigid body? You can lock the axis

mossy shard
#

i really am dumb

#

thank u

sick hawk
#

hey yall, I have this script

using EnemyNun;
using UnityEngine;


namespace EnemyDummy {
    public class DummyController : EnemyController<DummyController> {
        
        public GameObject prefab; //respawn yourself when you die
        public Idle idle;
        public Death death;

        private void Start() {
            SetState(idle);
        }

        public override void OnDeath(HitData data)
        {
            base.OnDeath(data);
            SetState(death);

            Invoke("SpawnNew",1);
        }

        void SpawnNew() {
            Instantiate(prefab);
        }
    }
}

and im having a weird issue. When a dummy dies I want it to respawn a new version of it. I have made a dummy prefab, set the prefab reference to that prefab, and placed one in the scene. However, when I run it, it immediately sets the prefab to itself, the scene instance, rather than the actual prefab. This is not what I want because then it spawns a glitched out dead prefab. Is this normal? is unity just being weird? Or is this some stupid thing where unity can't tell the difference between a prefab instance referencing the prefab and referencing itself

#

since the prefab DOES reference itself maybe its just like

#

assuming thats what the instance is doing

night harness
#

Yeah Unity does like convert refs to self prefab assets to the instance of itself

#

unfortunately

#

the same way components on the prefab reference the instance

lean sail
#

Ah I was replying in #πŸ’»β”ƒunity-talk about that. I completely forgot the reason that issue exists is because other components need to reference the spawned instance rather than the prefab's component

night harness
#

Makes sense but it's a real shame there isn't a solid, streamlined solution to it

sick hawk
#

idk how it would work but maybe a PrefabReference container or something would work

#

thats kinda hacky too idk

night harness
#

its not how it works but ideally would be great to just have some attribute we could use to mark stuff to not like transfer

sick hawk
#

oh an attribute would probably be best yeah

lean sail
#

in your case, i dont know if you'd have an external object that could store the reference to the prefab. Maybe doing it through a scriptable object is simplest

sick hawk
#

imma make a dummy spawner script and hope I never need to solve this issue again

steady moat
night harness
#

I don't think it's a solution but in theory it is possible to iterate through the prefabs and compare object names but blahh

steady moat
#

Which does not have the issue, you might want to use the same strategy here.

lean sail
steady moat
#

It helps in the event that you need to reference the "meta" object. I.E. the name, description or other settings that should live without an instance of a prefab.

night harness
#

iirc you can iterate through the scene objects in the hideanddontsave scene which will be the currently loaded prefabs in memory

#

string comparison still yucky but a abit more controlled since both comparison points are established during runtime yknow

lean sail
#

πŸ€·β€β™‚οΈ never really heard of that myself but either way that's still not what anyone would wanna do. just putting it in a scriptable object would be miles better

night harness
#

SO in a lot of cases is probably preferable yeah, But there's reasons I've found to at least be interest in that approach though

lament wasp
#

The issue is NOT time.deltatime

lean sail
#

also, use cinemachine and you dont need to make your own camera controller

lament wasp
latent latch
#

immma take a guess and say you've got it parented and you're trying to override the rotation but it's fighting

lament wasp
#

i've used cinemachine before idk why i didn't think of that

#

thanks

lean sail
#

yea that setup of setting the rotation of 3 things looks questionable

shadow wagon
#

I'd also suggest debug log the two xyrot values, but cinemachine is the better choice

#

Were you calling the function inside FixedUpdate?

lament wasp
#

no

unkempt bloom
#

Should I be learning Unity 6 or is 2022 still more stable?

vestal arch
#

2022 is probably slightly more stable? 🀷

unkempt bloom
#

I'm assumming there's more tutorials around the 2022 version? or are they similar enough to the point where those tutorials should still apply?

quaint rock
#

there is not that much different

#

mosty 20xx stuff will apply just fine to 6

soft shard
#

There might be a few parts of the API that have different naming for some things in 6 compared to 2022 (for example, rigidbody .velocity in 2022 is .linearVelocity in 6 for reasons), and there might be some visual changes but functionally 2022 tutorials should work fine in 6, even older 2018/early 2K tutorials should largely be fine too

unkempt bloom
#

Got it. Thanks! Would you say that most have switched to 6 by now or is it still fairly new?

soft shard
# unkempt bloom Got it. Thanks! Would you say that most have switched to 6 by now or is it still...

For some devs, its not uncommon to have multiple Unity versions installed for various projects, some ongoing projects might find it better to stick to a particular version instead of dealing with the possible issues that can happen with upgrading/downgrading a project, some devs use different versions to support older assets, some may even just want to try out the newest features, others may see no reason in using 6 for technical or other reasons, but unlike OS updates, Unity versions are one of those things you dont absolutely NEED the latest version, you can use any version for as long as you want (albeit, some versions may have LTS (Long-Term Support) updates and others are "as-is" so any issues with non-LTS versions will not get patched in the future)

modern atlas
fierce cargo
#

I have a question. Has anyone been able to integrate unity level play into their project without issue?

#

I would consider myself a competent fledgeling game developer. But, I have never encountered a more challenging task than this. I have endured four days of agonizing troubleshooting and I am still incapable of getting ads to run on my game

#

I tried rolling back to the legacy ad system and just kind of forgetting about using a mediation system

#

But, I am still getting these stupid windows32 errors where the android dependency resolver freezes. Then i put the gradlew.bat file into the temp folder like internet forums suggest. Then it starts resolving but then fails again. Im dealing with such significant frustration from this that I am starting to doubt myself and my skills even though I have been coding for well over three years now

#

Sorry. I'm aware it's inappropriate to vent my frustrations like this on here. Honestly, I am just looking for some help from a more experienced developer

#

Maybe this is a sign to shift my monetization strategy away from advertising lol

shadow cradle
#

has anyone used the firestore sdk? im having problem with the constructors. they are being called twice in deserialization and after Start()

undone prism
#

Could anyone help me with my problem? I am making a carcontroller and want to use my own system (so not using unity's wheel colliders). In the Wheel script it seems to go wrong but I cant find why. It starts wobbling side to side when on low speeds. I think it could maby have something to do with unity's way of calculating physics but im not sure, maby im just doing something fundementaly wrong.

Wheel script: https://paste.myst.rs/lz3oz71v
Suspension script: https://paste.myst.rs/osd53mbd
WeightDistribution script: https://paste.myst.rs/dklxwo3a

#

Here also a small video of the problem. The green lines are the velocity of the main rigidbody and the red stripes are the suspension force.

wide totem
#

How can i go about playing an animation in reverse from its current frame, as in, if its halfway through, it will start playing backwards from that halfway mark.

vestal arch
wide totem
#

i mean thats kinda what im trying to do, but from any frame

hexed pecan
#

Or use a float parameter and use it as a speed modifier for all the states you want to be able to reverse

vestal arch
vestal arch
#

convert it online or something

vestal arch
#

(btw, why not unity's system? did you have issues with it, or do you just want to make your own for learning purposes?)

hexed pecan
#

They appear wobbly when the velocity is near zero and you are normalizing it

#

So I don't think it's an issue really?

#

If it actually has some physical issues you can try smoothing/damping the forces somehow so it's not as jittery

undone prism
vestal arch
undone prism
#

here you can see the problem better. i prefer not smoothening the grip since it isnt going to feel right but rather floaty and the requirements i got was explicitly not to make it floaty. any other sugestions on what could solve it?

undone prism
vestal arch
#

what about just damping the speed?

undone prism
#

in what way would i be able to damp the speed?

#

you mean the velocity?

vestal arch
#

yeah

hexed pecan
#

Btw, I see you moving the wheel in Update.
Better keep its visual as a separate object and control its position in update, and control the physical wheel in FixedUpdate instead

vestal arch
#

if you have a dynamic rigidbody, you could apply damping/drag on that

hexed pecan
#

Otherwise you introduce framerate dependency here

#

I was thinking you can damp the individual forces of each suspension point over time, to avoid harsh movements

undone prism
hexed pecan
#

Yeah. Pretty minor thing, but thought I'd point it out

vestal arch
#

physics should be done in fixedupdate in general

hexed pecan
#

You generally don't want anything in Update affecting stuff in FixedUpdate

#

Except for some inputs ofc

#

Not a minor thing now that I think about it

undone prism
#

i get what you mean, minor mistake. it didnt solve the problem tho. i also tried to do some things with the built in dampening of the rigidbody but it doesnt seem to make a difference

vestal arch
#

is it dynamic or kinematic?

undone prism
#

dynamic

undone prism
hexed pecan
undone prism
#

i dont know if thats the problem tho since the suspension worked perfectly before the wheel script was made. i did add anti roll bars in after posting here that should effectively do a similar thing and i hoped that would maby solve the problem since it was another kind of dampening in the system but it didnt seem to help.

#

i have a feeling this problem might be a bit harder to solve than a dampening factor. i hoped i maby made a small mistake in coding it and somebody would maby find it here. i have already searched for hours on the internet and got experienced coworkers check it but nobody seems to find the problem

hexed pecan
#

Does it happen if you disable UpdateLateralGrip?

undone prism
#

if it helps to mention i am at unity version 6000.0.40f1

hexed pecan
#

You can also see physics settings like "default velocity iterations" or a smaller fixed timestep to see if it's just a physics instability issue. Doubt it tho

undone prism
hexed pecan
#

So your issue is somewhere in there

undone prism
#

yeah, i dont know where tho

hexed pecan
#

I'd try damping that but you seem really convinced that it's not a damping issue

#

So πŸ€·β€β™‚οΈ

undone prism
#

i made a script in a 2022lts about a year ago doing the same thing but with a calculation in velocity instead of weight on the tyre to calculate it and that worked fine but the system used colliders which i cannot for this project. i also cannot change any physics settings because it has to go into a really big existing project.

hexed pecan
#

Yeah, using physical colliders for wheels sounds like a pain

undone prism
#

i was thinking it might have something to do with the way it is applied and stuff like that but i have already tried a lot of stuff that didnt work

hexed pecan
#

I feel like you should scale the slip force with your current speed

undone prism
#

chatgpt has told me it might be floating point errors but it seems so extreme for floating point problems. it already starts doing it at around 1.5 on the velocity.magnitude

undone prism
uneven mortar
#

here's the code (ignore the croatian comments, this is for school)

#

i have more scripts but i believe this one's the one that needs tweaking

hexed pecan
#

This script spawns pipes on its own position (with a random Y offset).
So you should move the object that has this script, to the right

#

In the editor

uneven mortar
#

omg thank you!

wide totem
#

"this behavior" refers to the instance of the script right?

rigid island
wide totem
#

behaviour

#

like for stopAllCoruntines()

#

its all of them in that instance of the script yes?

rigid island
#

On the Monobehaviour script

#

yes

wide totem
#

thank you

thorny rock
# undone prism Could anyone help me with my problem? I am making a carcontroller and want to us...

Cool stuff! It looks like either floating precision error or because you are not using the physics system, the steps are calculated faster and thus the camera (Who's probably following it in the Update loop, called 100's of times) is getting a small reposition every frame, not physics frame: https://docs.unity3d.com/6000.0/Documentation/Manual/execution-order.html (scroll down for the Script lifecycle flowchart)

Every frame depends on your computer speed and physics frame is ~60 a second. You usually see this kind of behaviour in Unity too when you are following a Rigidbody object with the camera in an update loop (That's why we have LateUpdate, an update after game logic/physics calculations) . Just a thought πŸ˜„ .

stuck dirge
#

hello, I'm just getting started in Unity, I have an error or I don't know what it is going to, I want to create a GameManager but when I create the Scrip it does not adopt the nut icon and will not react as it should, I think it is due to an error of the Unity since the same thing happens when creating a new project, I'm on the latest version

vestal arch
stuck dirge
#

I want to upgrade to an LTS version to see if the error persists

vestal arch
#

i mean, what's the issue there?

#

GameManager is only special with the icon, it works the same as any other script

vestal arch
stuck dirge
vestal arch
#

the latest version isn't on alpha

#

ah well.. the latest as in highest version number is alpha, i was looking at the wrong column

#

but you really don't need that

#

just use full releases

pastel atlas
#

Is there any easy way to track variable references when its being passed by reference between methods? As in if I have a variable _position...
A call is being made to MoveCharacter( _position, _velocity, etc... )
MoveCharacter method header is ( ref position, ref velocity, etc.... ) and inside the method it calls more methods which again have method headers where its inputs are being passed with ref keyword.

So a method 2-3 calls deep is making its way back to modifying the variable I really care about _position. I know visual studio has a way to check for references, but only 1 layer deep. It's not tracking if its being passed to more methods by reference. My code base isn't massive or anything so it's not like it would be very difficult to brute force it but I don't know if there's a tool that can do it for me so the human element is taken out of the equation

soft shard
# pastel atlas Is there any easy way to track variable references when its being passed by refe...

Not 100% certain if this is the best way but it is one way you could try - you could make your variable a property and use an observer pattern (event in your property setter) then you can have some debugger script subscribe to that and print the stacktrace, or you could just log the Environment.Stacktrace from the functions your variable is passed, or you could try using breakpoints, I believe in VS you can "watch" variable changes this way

late lion
mossy shard
#

What does it want from me?

#

haven't i setted the animator in code or sum

somber nacelle
naive swallow
mossy shard
naive swallow
#

to an animation

mossy shard
#

how do i delete it

shadow cradle
#

is there a way to create curved ui lines?

rigid island
#

to some extend line renderer can also do curved lines but more difficult

#

for spline you can use it to create a mesh , basically what a line renderer does anyway (its a mesh)

shadow cradle
#

i want to avoid rendering 3d on the ui, the only thing i could think of was connect str8 thin images but then i would get corners not curves

#

which isnt bad if done right

rigid island
shadow cradle
rigid island
#

wouldn't it be easier to make a node editor using something like the Visual Scripting API ?

#

or now I think unity also put the GraphAPI or whatever

shadow cradle
#

those dont work in runtime unfortunately

#

althought they may make the new graph tool work in runtime at some point

rigid island
#

hmm I think the new Graphics API did that but i can't find the exact link

shadow cradle
#

new graphics api?

#

dont think theres such thing

rigid island
#

yeah I'm trying to find it

#

its what the new Behavior graph uses

#

ugh

#

seems down now?

shadow cradle
#

Yea we talk about the same thing

#

Unfortunately its editor only

rigid island
#

balls

#

could've sworne runtime was mentioned but ig it was another thread requesting it.. unfortunate

#

the only thing I can think is using Splines, the most straight forward way

#

there is GL but thats pretty advanced and probably overkill here

#

Line Renderer / Spline imo is the easiest way

shadow cradle
ionic grove
#

Do you guys know how I can get this field's value through code?

lean sail
ionic grove
lean sail
#

its the same name just under unityengine

vestal arch
#

ah whoops

rigid island
# shadow cradle How can this be implemented?

for Splines you can set up the path / points then put a mesh between those points.
for line renderer you do the same but adding curves would involve some special technique forgot the name, I can find it rq
edit :
there is another one for line renderer but forgot the name
https://www.gamedeveloper.com/business/how-to-work-with-bezier-curve-in-games-with-unity

vestal arch
lean sail
#

lol it really looked the same at first

ionic grove
#

Ok I looked at that already but got caught up on how we only have an animation clip and not an animation

vestal arch
#

can you elaborate?

lean sail
vestal arch
#

animationclip -> actual animation data
animation -> component that run animationclips
animator -> component with a state tree to run animationclips

ionic grove
#

Right, the clip is the actual animation. The Animation state is what is holding the speed variable.

shadow cradle
ionic grove
#

Animation clip

rigid island
ionic grove
#

Animation state

#

Here is my code:

IEnumerator PlayAnimationAndAct(string animationToPlay)
{
    float animationTimeToComplete = 0f;
    float animationSpeed; // Default animation speed

    // Wait until animation done
    if (animationToPlay == "BackUp")
    {
        animator.Play(standUpAnimation_BackUp.name);
        animationTimeToComplete = standUpAnimation_BackUp.length;

        animationSpeed = animator.GetCurrentAnimatorStateInfo(0).speed; // Get current animation speed
        print("Animation Speed: " + animationSpeed);
    }
    else if(animationToPlay == "FaceUp")
    {
        animator.Play(standUpAnimation_FaceUp.name);
        animationTimeToComplete = standUpAnimation_FaceUp.length;

        animationSpeed = animator.GetCurrentAnimatorStateInfo(0).speed; // Get current animation speed
        print("Animation Speed: " + animationSpeed);
    }

    yield return new WaitForSeconds(animationTimeToComplete);

    // Set variables
    SetCanMoveAndLookToTrue();
}
vestal arch
#

@ionic grove what's your question and what are you trying to do?

lean sail
#

using the multiplier

ionic grove
#

I figured I wouldn't have to because there would be an easy way to get that value, but I guess not

ionic grove
vestal arch
#

well, no, it's just that length but scaled, and how's that an issue?

ionic grove
#

It's not an issue.... It's just that I'm altering variable values when the animation is done. So the game thinks it's taking "X" seconds to complete when really it's taking "X/Y" seconds to complete

vestal arch
#

why not use animation events?

#

that way you don't have to deal with time at all, and you would just let the animator handle that

#

if animation events aren't what you're looking for, then

So the game thinks
🀨 can you be more specific here about "the game thinks"

ionic grove
#

Now that's a better idea

vestal arch
ionic grove
#

I think an anim event would work fine here

#

It was an "Ugh" gif

vestal arch
ionic grove
#

Speeeeeeeeeeeeeeeeeeeeeed

vestal arch
#

that makes much more sense to the rest of your questions lol

ionic grove
#

Lol omg

#

When you linked that Motion doc, I was like.. Bro that's so unhelpful πŸ˜„

vestal arch
#

you didn't actually say what you wanted in the message, the arrow looked like it was pointing to motion to me lol

lean sail
#

Honestly not a huge fan of either approach (probably cause I dont fully understand animation transitions) but I do instead try to define stuff like this in code and inspector. The code dictates how long it should take, and tells the animation it, adjusting the speed multiplier

ionic grove
#

Yeah I don't understand how this isn't a simpler process. I don't like the whole set float thing either, but at least then my animator can set it in the inspector

lean sail
#

i do remember having cases where animation events didnt trigger as i wanted it to. also its just a huge pain in the ass to setup

vestal arch
#

oh also; timelines are also another option, but iirc that's a pain to make work with animators

ionic grove
#

It meant that the time to complete the animation is now length / speed. But my code just sees length right now, so it's taking too long when the speed is set to 1.75

lean sail
naive swallow
#

The current Animator workflow with transitions and parameters is capable of taking so much of the cognitive load off of you it's very much worth learning

#

You can look at VRChat avatars, every single bit of functionality those have is driven almost entirely by the animator and parameters

ionic grove
sick hawk
#

its useful for sooooo much

#

it can do very simple functionality quite fast

ionic grove
sick hawk
#

its really not hard!

#

its basically just a timeline

#

also animation is fun! you can add a ton of juice just by messing around with animation scale, color, position, rotation

ionic grove
#

But I can't drive myself nuts trying to proceedurally animate things before my animator gets things done then lol

sick hawk
#

sounds like me ~3 years ago

latent latch
#

Animator is sweet but I never get the chance to use it

naive swallow
latent latch
#

Really if I didnt have to bloat my project with controllers id use them more over tweens

#

Vrchat creation does sound like fun though. Need to really figure out bone and cloth physics more

naive swallow
#

It's definitely one of those "When all you have is a hammer" things. But it turns out most problems can be reduced to a series of nails

vestal arch
#

screws are just really detailed nails

#

tenons? wooden nails

dense pasture
#

Curious, is the visual scripting system possible to leverage in a similar way to scriptable objects?

Case in point: I’m building a suite of β€œcodeless tools” so my team can contribute content without needing to follow c#. In this case I was thinking about a way to build something like a quest storyboard.

Could I leverage visual scripting engine to make that easy to put together or would I be better off making my own abstraction and making custom UXML editor?

#

I wanted to leverage the graph/node format similar to shader graph

rigid island
#

been trying to do a few tools myself so I've been where you at lol

onyx dirge
#

how do i code a spinning text mesh

rigid island
dense pasture
onyx dirge
#

spin on Z axis

rigid island
# dense pasture Which have you settled on?

I haven't had time to try the others, I was going to wait for the new one but meantime use the Visual Scripting graph I think thats what shadergraph used before merge to Graph toolkit ?

dense pasture
#

I don’t need a whole lot of bells or whistles, just a way to use custom scripts for advanced purposes. Yeah I think VS looked close to viable for this

#

I got the custom scripts support into my cinematics framework but the whole thing is just a linear array editor

#

Being able to work it up to something like a graph/node based workflow would be ideal

rigid island
#

I think that the most mature of them all and probably easier to integrate as running code rn VS one

dense pasture
#

I’ll have time to explore it tomorrow I’m just not gonna be at my pc all night to see if my theory was right

#

Thanks for the info

rigid island
onyx dirge
#

nothing i cant code 😭

rigid island
tawny elkBOT
#

:teacher: Unity Learn β†—

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

onyx dirge
#

ty

wide totem
#

do buttons need textMesh attached to work??

rigid island
#

the two aren't related , so no

wide totem
rigid island
wide totem
#

oh

rigid island
#

if you put a blank Image component it would work too for example

wide totem
#

does the button shape itself not count?

rigid island
#

the button uses whatever shape the target is

#

keep in mind Button is just a component, what Unity does for the premade button is just combining the image component with that button component, then TMP Is just a child

wide totem
#

thank you

wide totem
#

why is it displaying white and not the selected color (was set that color in script)

#

as soon as i edit it at all it turns back to the purple

#

but like

#

why is it white 😭

wide totem
#

oh

next sail
#

Hey everyone, I was just wondering if its a good idea to child the camera to a moving first person character with animations. It works well with 50+ fps but under that(or fluctuating fps) I could notice a lot of jitter and snappy movement of the camera. The only reason I am using this as a solution cuz I want the camera movement to be realistic. Is there any other way I could produce a similar effect. Thank you.

somber nacelle
#

obligatory: use cinemachine

next sail
#

alright, I will try

warm gulch
#

w h a t

kind willow
#

anyone using the localization package? how can I force it to halt loading locale on game start?
I want to reproduce an error from a webgl build

#

I am trying to get a localized string somewhere before making sure the localization is loaded

#

alternatively since I am always seeing 2 errors I can just add debug logs to all my localized strings calls to see at first 2 but I have no idea how to

#

any visual studio code way to add a new string under all strings containing matching code?

vestal arch
#

ctrl+shift+f

kind willow
#

I have like 100 calls

vestal arch
#

im not sure i understand what you want

vestal arch
#

write a regex to match the call you're targetting to add debug.logs

kind willow
#

regex 😒

#

the issue is that I am using GetLocalizedString not on just it's own but also to build strings

#

if you say regex can help with inserting code, well, good to know, but I ain't going to this rabbithole yet

vestal arch
#

doesn't sound too hard in this case

#

if you could show a few examples of what you want to debug, i could write one for you

kind willow
#

I am having 2 use cases for GetLocalizedString(), I either assign text.text = something.GetLocalizedString(); or text.text = something.GetLocalizedString() + "something" + "optionally something else"; ect

#

either way it's not a huge deal for me to debug manually and those errors are not causing anything bad

#

I am mostly asking all that out of curiosity to learn how to be handling that properly

vestal arch
#

well this is kinda a bodge, but giving that it's for debugging, it's probably fine lol

kind willow
#

I would honestly don't mind being able to just redefine localization method for getting localized strings to insert a debug into it

#

this sounds more simple

#

or as I was saying at the start find a way to make getting localization very slow so errors pop up in the editor

vestal arch
#

as in, what to put in the debug.log

#

(also interpolated strings exist, might want to try those)

kind willow
#

well nothing since I just need to see the first 2 calls (hopefully they are the ones causing errors, if not, well, it sucks)

#

and logs have a bunch of info if you click on them in console

vestal arch
#

^(?=( +).+something\.GetLocalizedString\(\)) replace with $1Debug.Log("call"); //--\n

#

the //-- is just you can search to remove them later

kind willow
#

looks ominous

vestal arch
#

it really is just "find the thing and put a debug before it"

#

the $1 is to get proper indentation

#

this wouldn't work if the statement with the localization were a 1-statement if or something like that though

#

i wonder if c# has the comma operator one sec

kind willow
#

where do I even type in and execute the regex?

vestal arch
#

in search, ctrl+shift+f

vestal arch
#

but it'd be harder to remove

vestal arch
#

(and you can filter by file extension/name with the 3 dots)

vestal arch
#

well that's what you gave as an example of the call to match lol

#

if "something" can be arbitrary, you can use \w+ for any identifier

kind willow
#

alr I will just give the actual code sample I use
string multiplierString = multiplierPreString.GetLocalizedString() + " x" + currentMultiplerString;

vestal arch
#

is it always multiplierPreString or can it be some other name?

kind willow
#

the point of GetLocalizedString is that you call it for different variables

#

aka localized strings

vestal arch
#

aight, so use \w+

kind willow
#

you are getting a string.... out of a string

vestal arch
#

right, but i don't know if you're using existing constants directly or if it's in a function where they all end up with the same parameter name

#

i don't know how specific you want to get lol

kind willow
#

right, was bold to assume everyone know the specifics of this package

#

anyway I have no idea what do you mean by use

vestal arch
#

ah sorry

#

^(?=( +).+\w+\.GetLocalizedString\(\)) replace with $1Debug.Log("call"); //--\n

kind willow
#

^(?=( +).+\w+.GetLocalizedString()) something like that not workign

vestal arch
#

make sure you've selected regex mode

kind willow
#

now it works ><

hexed pecan
#

Regex looks so insane to the untrained eye

vestal arch
#

true

#

if you want a different debug message, just change it in the replacement

#

it's pretty much plaintext except for escapes \x or replacements $x (for any x)

kind willow
#

well, it worked (also it did find my old code commented away but whatever I take this collateral)

#

I guess I will have to learn regex at some point

vestal arch
#

ah, forgot to check for that

elfin walrus
kind willow
#

for a moment I thought that the idea of finding and replacing code using vague word descriptions would be a perfect fit for a neural network but then I realized it would botch it harder than people

vestal arch
#

brief explanation:
^ is an anchor, it matches the beginning of a line
(?= ) is a lookahead, it checks the following text without matching it
( ) is a capture group, it captures whatever it matches to be used later (as \1 or $1, since this is the first capture group)
+ matches multiple spaces. ( +) is used to grab the indent depth (though should probably be ( *) to handle unindented code; + requires at least one)
. matches any character other than newlines, .+ matches a section of any character (this should probably also be .* to handle the general case)
\w is any word character, aka a-z, A-Z, 0-9, and underscores. \w+ is a section of any word character, to match an identifier.
the rest is literal matching, \., \(, and \) are escaped to avoid regex features
the entire regex matches a 0-character string that's followed by the call in question; specifically, it's at the beginning of the line
i'm using a lookahead here to not match the call in question, so we don't have to add it back in when doing the replace
since it's at the start of the line, and the replacement ends with \n, this basically adds another line before the targetted line
$1 in the replacement grabs the first capture group, the indentation depth, then the rest is literal

kind willow
#

I have already peeked regex symbols and get scared, you don't have to project my phobia here too

vestal arch
lean sail
# hexed pecan Regex looks so insane to the untrained eye

Quite literally half of it is to denote stuff like how many occurrences of a character you want, and backslash for special characters or predefined groups \w being for words
It's really not complicated to use. In most cases, if you're using it in a really complex way, it's the wrong way to be doing something

#

And yea regex101 is a must use tool. It describes it step by step

vestal arch
#

then you get to the weird stuff like matching emails πŸ˜†

#

or valid dates, accounting for leap years
or emojis, including combining emojis

lean sail
#

In the problem of matching emails, it's gotten more accepted to go with the naive approach

#

Because there are a lot of cases where a solution is proposed and whoops one user suddenly doesnt work

vestal arch
#

hey, i never said practical stuff lol. just weird πŸ˜†

#

ah man there's probably a regex for urls with punycode support lmao

lean sail
#

True, what I said above also kinda addresses the whole issue of regex. Like it's usually just a waste to validate everything with regex when its miles easier just directly in code. Leap year being just math

#

I've always found it weird when people who learned it claim regex is insanely hard. There is almost always an easier alternate solution

#

Not directly talking about the case above cause that actually requires regex for the built in search

kind willow
#

I only heard bad things about regex so I am withstanding to learn it so far

#

also this is like the first time I have encountered a need for it

lean sail
#

I've used it in the past in similar conditions, mass editing text in my ide. If you learn the absolute basics of it, you'll be able to play around in regex101 and get the result you want

kind willow
#

no wait ti's the second time... first time I just went for manual editing like 30 times

lean sail
kind willow
#

complex code is just a combination of a bunch of simple code

shadow wagon
#

biggest downside to regex is it limits who can help troubleshoot it

#

I suppose thats the case for all programming languages

vestal arch
#

well, it's opaque. hard to debug if it doesn't work
unless you have a dedicated debugger like on regex101, but that doesn't always help. it's kind of an esoteric system

it is just a state machine, but damn is it a complicated state machine

shadow wagon
#

benefit of it being esoteric is you get bragging rights!

naive swallow
#

Once I tried writing a regex and I accidentally summoned a demon instead

vestal arch
#

normal occurance tbh

#

just make sure it's not the html demon

chilly surge
#

It is quite convenient for simple stuffs, but for complex stuffs regex code basically becomes read only.

gray cloud
#

Not sure if mentioned here, but Regex is one of those things that language model AIs are pretty good at. They can both break them down to explain them but also construct them. Something with how regex is a pattern system and AI excels at patterns. Might be a useful tool for debugging them too.

chilly surge
gray cloud
#

You would of course copy it to regex101 to test it, they aren't mutually exclusive tools, rather complimentary ones

vestal arch
#

regexes are more finite than code, probably just more examples to directly copy

#

but still, nowhere near a guarantee

#

besides, different flavors and newer features exist

open plover
#

Can you check if the phone is using dark mode

rigid island
#

there isn't any built in unity method afaik. you can probably easily call the native scripts though to do so

#

it will probably be wayyy wasier for android

vestal arch
rigid island
#

oh there ya go lol

open plover
#

Chatgpt says β€œIf you’re using Unity UI Toolkit, you can detect dark mode in Application.theme”

#

I guess they implemented it in newer versions

rigid island
#

is not possible GPT invented something ? seems the usual for me

open plover
rigid island
#

not surprised

steady moat
vestal arch
#

this is definitely not typical regex

#

i don't know of any flavors that use the middle dot

#

i think you're talking about a different kind of regex? in cs?

steady moat
vestal arch
#

yeah, in formal language. regex doesn't use it

steady moat
#

Obviously, that is beside my point.

vestal arch
#

it's not really obvious. it seems like you're talking about actual regex, especially when you say there's only 4 symbols

#

the perceived complexity in regex comes a lot from how many special symbols there are

steady moat
#

It would be more accurate to say that there is mostly 4 operator.

vestal arch
#

sure

steady moat
vestal arch
#

tbh though, i think for learning just to use regex, using the regex terms would make more sense
sets, quantifiers, anchors, and groups

empty elm
#

does Physics2D.CircleCastAll find colliders that are inside (not intersecting) the initial circle? If so is it because it is able to detect points inside the circle, or it notices the collider intersection as the shape exits the circle that is being dragged

leaden ice
#

ther eis no such thing as the "initial" circle

#

or things "entering" or "exiting"

empty elm
#

whoops I meant circleCastAll

leaden ice
#

Yes 2D raycast and raycast-like queries detect colliders that overlap the start of the cast

empty elm
#

Thanks

leaden ice
#

note that 3D is different

#

In 3D it never detects such things

next isle
#

what in the name of all things magical causes unity to register clicks somewhere other than the button? πŸ’€

I'm building a menu for my VR game

for reason's i can't begin to fathom, The click is not being triggered on the button, but below it.... it's as if the trigger area didn't resize/move with the Rect Transform πŸ€”

in the video is a bog-standard UI button, which is a child of a world canvas (sorry, I'm so new at game dev i don't even know what to offer in the way of context)

I could do with some help here This is a bug in Unity.... the issue is not there when you build and run the game

rigid island
#

pretty sure world canvas is still not a thing for VR. isn't it ?

rigid island
#

oh okay

#

Im confusing it with something else lol I dont touch vr

next isle
rigid island
#

yah for me its not having it a headset, maybe you need a special type of Input module, I have no idea

next isle
rocky mauve
#

Using ScriptableObjects as a basis for an inventory/item system is common in Unity, but how do people deal with it when item state is mutable and needs to be persistent? For example if items have a bunch of stats on them that need to be saved.

tired shore
#

void Start() {
     MyItem = ScriptableObject.Instantiate(MyItem);
     MyItem.DamageStat += 10; // this only changes this local runtime SO, not the base on in your project
}```

Create a clone you can edit without affecting the original base stats.
#

That said, I've kinda fallen out of love with SOs when it comes to mutable stuff and mostly use plain c# classes with the serializereference attribute

steady apex
#

Is there any implementet function for finding (k) biggest elements ? k<< n

var closestGameObjects = gameObjects
            .OrderBy(go => (go.transform.position - origin).sqrMagnitude)
            .Take(5)
            .ToList();

that part of code have O(n) or O(nlogn ) ?

hard estuary
# rocky mauve Using ScriptableObjects as a basis for an inventory/item system is common in Uni...

ScriptableObject asset should be treated as template. Depending on the game, you will want to either create an instance of a ScriptableObject, or create some sort of class that can wrap reference to the template and overridden stats. The second approach is more flexible, because you have an easy access to the template (which is useful if for some reason you want to restore the default state) and lets you easily swap templates without having to make a deep copy of it. But with enough effort, you will be able to achieve same goal with a single instance.

Wrapping it might be more performant in multiplayer games, because syncing whole object could take longer than syncing data about overridden fields. But it might be the opposite, if you're always overriding most of fields.

night harness
#

I'm still in my runtime SO usage arc so I haven't implemented anything like this before but is there a solid pattern to this kind of thing where your base is an Interface that both a base class and the scriptableobject inherit from that creates like a common and paired matching between them?

hard estuary
# steady apex Is there any implementet function for finding (k) biggest elements ? k<< n ``...

Sorting algorithms take nlog(n) operations.
When it comes to dynamically sorting elements, you can speed it up by preprocessing data into a self-balancing binary search tree. Modifying 1 element has O(log(n)) cost (where n is the number of elements in collection), but you would be able to retrieve k objects in time O(k), which works well for small k.
https://en.wikipedia.org/wiki/Self-balancing_binary_search_tree
But this solution wouldn't be efficient if you updated whole collection before accessing results (which is what will most likely happen, if you're comparing positions of objects that move every frame). Treat it as good solution for sorting,

If you're working with positions, then I would suggest trying a quad tree instead (or its 3D version). It's great for finding nearest elements.
https://en.wikipedia.org/wiki/Quadtree

steady apex
#

Move obiect (i detect object in range) i know that you can do it in O(n) if k is much smaller than n

#

I was not sure about that build in function (maybe it actually don"t make a sorting)

lean sail
hushed laurel
#

Is there a reason to use a continuous extension of linear interpolation based on deltaTime instead of just calling it normally in a fixed update frame?

For anyone unaware, Lerp(a, b, f) called every second can be extrapolated into the equation
y=(a-b) (1-f)^x + b, where x is a float representing the number of seconds passed.

This would allow it to be called every Update() instead of every FixedUpdate(). Does anyone think this is useful?

somber nacelle
lean sail
hushed laurel
somber nacelle
#

then the amount of movement obviously depends on the framrate
not if you use it correctly

hushed laurel
somber nacelle
#

accumulate deltaTime in a variable, divide that by desired number of seconds the lerp should take and use that as the t value

hushed laurel
#

I don't.

somber nacelle
#

i am assuming you want to use lerp over a specific period of time which is what lerp is for

hushed laurel
lean sail
#

just saying, i dont think your equation makes sense either. it isnt the same as how you're supposed to use lerp, and suddenly you have 4 variables instead of 3

somber nacelle
lean sail
somber nacelle
hushed laurel
somber nacelle
#

have you checked the docs?

hushed laurel
rough condor
#

how to make a variable public and readonly but modifiable in inspector

mossy snow
#

public property with private getter + SerializeField attribute targeting the backing field. Doesn't make it read-only from the class but other scripts won't be able to modify it which is what I assume you want

#

alternatively, private serialized field + public getter which is less brittle but not as slick

night harness
#

its a shame unity doesn't have a nice working readonly attribute

oblique spoke
#

Don't crosspost.

golden breach
#

my bad where should i post it then

#

wasnt sure what the right place was

stone rock
#

Hello, does Unity provide any sort of info on whether the user is actively resizing the window? I would like to enforce the width and height to be an even number but not when the user is actively resizing the window.

#

I mostly need to know that the user is done with resizing

cold parrot
fringe ridge
#

If i have a BaseClass, and then ChildClass1 and ChildClass2, all are serializable. How can i have a list of BaseClass and create/edit instances of childClasses in editor?

#

really dont want to create a custom editor

stone rock
#

If it doesn’t update during that may actually already solve it then. I want to prevent the window adjusting when someone is resizing. I’ll go and test it and see what happens

fringe ridge
quartz folio
#

There are various packages out there that add a drop-down as a drawer

lean sail
flint musk
#

so how are hitboxes and hurtboxes supposed to work?

which one of them are supposed to be trigger, have rigidbody, or both?

#

i may be wrong, but neither of them is supposed to be a collider with the environment or characters , right? since they only serve to detect attacks and things of that nature

elfin walrus
#

usually hurtboxes are the ones that scan for hitboxes and if they detect one, they deal damage to their owner

#

so hurtboxes are the things that take damage

#

and hitboxes deal damage

flint musk
#

right

elfin walrus
#

because usually there are more hitboxes than hurtboxes

flint musk
#

hereΒ΄s my hitbox and my enemyΒ΄s hurtbox

#

the problem im having rn is that ontriggerenter is triggering multiple times

#

and the way that my hitbox works is that it gets enabled and disabled inside the attack animation

elfin walrus
#

usually the solution to that is having iframes, basically a fraction of a second of invincibility once something gets hit

flint musk
#

so whatΒ΄s the point of OnTriggerEnter if itΒ΄s not gonna check only once?

elfin walrus
#

usually it only gets called once, not sure why it's getting called multiple times tbh

flint musk
#

iΒ΄ve seen around that if a trigger collides with another trigger it causes issues

#

and that at least one of the parties needs to be a collider or have a rigidbody

#

okay, i seem to have fixed the issue

#

it was the animationΒ΄s fault that seemed to be activating the hitbox multiple times

#

but thank you

vestal arch
prime heath
#

Hello does anyone Have good ressources for UI architecture ? I'm currently trying to do everything or most with UI toolkit

mossy shard
#

How can i call a functions after a few seconds in update (like looped) as in every 5 seconds an enemy spawns or smt

shadow wagon
shadow wagon
#

yeah, thats the other way

fading epoch
#

https://paste.ofcode.org/ahKmTCq5hcKNPUvVupEb9v
So, I'm trying to initiate a command for Yarnspinner where I enter a command named objectEnable, alongside the name of an object, into my Yarn file with the hopes of having the object be enabled when I do so and in the project itself, I'd have the objects disabled beforehand. The problem is, I keep getting a NullReferenceException: Object reference not set to an instance of an object error and I don't know why that is. Can anyone help me figure this out?

ripe epoch
# prime heath Hello does anyone Have good ressources for UI architecture ? I'm currently tryin...

Not sure if it counts as "good," but what I did for my project with UI elements is make my own "clickable" parent class that child classes can derive from. Whenever the player clicks, a manager on the player records all of the clickable scripts that were hit by the player, and calls functions like OnMouseDown, OnMouseUp, OnMouseEnter, OnMouseExit, OnHold, and updates a boolean that shows wether a player is hovering over something or not. I found that this approach let me make really robust systems easily, and I avoided a lot of the hassle that comes with UI toolkits by making my own barebones one. If you'd like, I can share the code.

somber tapir
somber tapir
# fading epoch I still do!

which line is the error? Are you sure you have the dialogueRunner assigned in the inspector? Does the Debug fire in your method?

fading epoch
mortal gate
#

How about making gliding like this, but using character controller? https://youtu.be/dQq9synN9r8?si=uTR5msd3f3mCMSwp

GitHub Project : https://github.com/SOMENULL/Gliding-Project

Music Attributions :

Music from #Uppbeat (free for Creators!):
https://uppbeat.io/t/kidcut/flamingo
License code: TSGHFYAYFKBMLCIF

Music from #Uppbeat (free for Creators!):
https://uppbeat.io/t/mountaineer/fly-away
License code: VEUQYEESKSSSI4ZN

Music from #Uppbeat (free for Creato...

β–Ά Play video
acoustic star
#

This is essentially a copy paste I am making from the server whose tutorial I am watching so sorry for it being a little lengthy

#

Actually nvm

#

I'll explain it fresh

#

So I am watching a tutorial rn to make 3D chess

vestal arch
#

ok, start with the issue and immediate context

acoustic star
#

and it makes a 8x8 chessboard

vestal arch
#

we don't need the entire story

acoustic star
#

the problem is that when I hover it the tile changes layer

#

but the material doesn't change to the hover material

#

as you can see in the picture the layer is hover

dire crown
#

I've found a unity bug inside code, how do I report it efficiently?

vestal arch
acoustic star
#

(usual layer is tile) but the material is still the same as all other tiles which aren't being hovered

vestal arch
gray cloud
vestal arch
acoustic star
#

So I am trying to change the material through the URP asset, with the changeObject feature

#

both of the materials are transparents

gray cloud
#

I've done hovering code dozens of times but never used that Renderer Feature I'm afraid PepoThink

acoustic star
#

The raycasting code

dire crown
# vestal arch (since you're here though, wanna run it past us in case it isn't?)

Sure, it's more of code missing a line. I'm making use of UnityEditor.Searcher package, and i was calling the method CustomSearchTreeUtility.CreateFromFlatList to ensure that, passed a set of elements like node/type/name they were properly sorted and organized.

However, I wanted to make use of the SearchItems property called Synonims, that basically allow you to add extra words that should return that item. But for some reason, they weren't working.

I checked the code of the package and found that on line 71 of that class there should be an additional
currentSearchNode.Synonyms = item.Synonyms;
to ensure that the synonims are transfered to the new SearchItems, otherwise they are lost

tender willow
dire crown
gray cloud
# tender willow RayCast on every single frame?

Yep - that is completely fine if it's just like a "one time per frame" thing.
I know there's some controversy around it and bad practices, but that's how all hovering works afaik. And also, you won't see a single RayCast like that make a dent in the profiler.

What is a bad practice is to do that for a bunch of units, if you want something like an ant colony to use RayCasts to avoid bumping into walls, then that would be an issue.

But generally, things that are just for the player character you will have a lot more leeway for

#

One charater - fine. One frame - fine. Many characters every frame - double-check that.

acoustic star
#

Yeah this is just one player per frame

#

Board generation if you wanted to see that

hybrid flower
#

so i have this movement script that uses swipes on a mobile device to move, how would i translate this into a A & D keyboard movement

#

private void Update()
{

if (Controls.swiperight == true && Lane3 == false && Lane1 == true)
{
    Lane2 = true;
    Lane1 = false;
    Lane3 = false;
}
else if (Controls.swipeleft == true && Lane2 == true && Player.position.z <= 0.2f)
{
    Lane1 = true;
    Lane2 = false;
    Lane3 = false;
}
else if (Controls.swiperight == true && Lane2 == true && Player.position.z >= -0.2f)
{
    Lane3 = true;
    Lane1 = false;
    Lane2 = false;
}
else if (Controls.swipeleft == true && Lane1 == false && Lane3 == true)
{
    Lane2 = true;
    Lane1 = false;
    Lane3 = false;
}

}

rigid island
#

if(input.getKeyDown(KeyCode.D)){ if(currentLane < maxLanes) currentLane ++;

lanes[currentLane]
etc.

gray cloud
#

!code

tawny elkBOT
acoustic star
#

Or do you have any tutorial suggestions for doing it

hybrid flower
rigid island
hybrid flower
#

so those 3 lines of could would be enough >?

#

i would need it for the A key aswell surely

rigid island
#

all you're doing is ++ the index/int or --

half venture
#

Is this the right place to ask netcode and parenting questions?

rigid island
#

and post the full question, don't ask to ask

hybrid flower
#

right

rigid island
hybrid flower
#

as bools ?

rigid island
#

why bools?

#

you cant ++ / -- a bool

#

its an int

#

lane 1, 2, 3

hybrid flower
#

my Lanes are bools

rigid island
#

why are they bools

gray cloud
# acoustic star Mr. Chexxor, you said you have done hovering a bunch of times, do you think you ...

I'm about to grab some food but at least a couple pointers for now:

  • In your Tile script, add a reference to the tile's Renderer (You will use this to switch materials manually)

  • Add a material field for where to put the default material (so you can switch back when no longer hovering)

    • In Awake/Start or similar, set this ThisTilesMaterial = ThisTilesRenderer.SharedMaterial to save it for later (choose variable naming as you see fit)
  • Add another material field for the HoverMaterial and assign this in the inspector for each of your tile prefabs if you have those

  • Add a method on your tile class to enable/disable hovering

  • In your current RayCast code where you switch layers, call this method as well

    • (You could move the layer switching code into this new hovering method)
  • In the hovering method if setting to true then ThisTilesRenderer.SharedMaterial = HoverMaterial otherwise = ThisTilesMaterial

mossy wedge
#

Store the bools in an array and index them with an int, how about that?

rigid island
#

sure that could work but still no idea why they are bools in the first place

mossy wedge
#

Fair enough

rigid island
#

if you miss something bools can let you be in 2 different states/lanes at same time

mossy wedge
#

I'd prefer an enum for this tbh

rigid island
#

yes enums just numbers with labels

mossy wedge
#

They are one of my favourite language features, i just really like them

rigid island
#

I was looking at some GTA Vice City source code and the amount of enums/switches is fantastic lol

#

no bullshit abstractions for state machines, just good ol plain enums

mossy wedge
#

Source code from where?

rigid island
#

github

mossy wedge
#

Link please, i wanna take a look

#

Nvm found it

rigid island
#

niceee . I had the gta3 link avail, forgot where i put VC

rigid island
#

ped state has over 50 of them..crazy

tender willow
#

can someone help me please? I made somewhere in making multiplayer mistake and nothing works when 2 players join xD

tender willow
rigid island
tender willow
rigid island
#

if you don't know how can a total stranger to the problem possibly know without any context

#

frankly if your first project is networking you will struggle more than need to

#

suggest you get more comfortable in unity before doing net

mossy wedge
#

Networking is my second project and my codebase just runs on black magic it feels like

tender willow
rigid island
#

what you learned in experience on those project is much more important

tender willow
#

UnassignedReferenceException: The variable rb of NZombie has not been assigned.
You probably need to assign the rb variable of the NZombie script in the inspector.
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at <44f3679c53d1477a9c6e72f269e3a3a9>:0)
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at <44f3679c53d1477a9c6e72f269e3a3a9>:0)
UnityEngine.Rigidbody.get_linearVelocity () (at <33f9ec680d9d4a85b09adc18a20b37f0>:0)
NZombie.MoveTowardsPlayer () (at Assets/Scripts/Zombies/NZombie.cs:28)
NZombie.Update () (at Assets/Scripts/Zombies/NZombie.cs:19)

can someone by any chance help me fix this error?

rigid island
#

this isn't even a networking question, this kinda hits that all your projects you did not learn the fundamentals

#

it tells you in the error what could be wrong

#
UnassignedReferenceException: The variable rb of NZombie has not been assigned.
You probably need to assign the rb variable of the NZombie script in the inspector.```
tender willow
sonic portal
#

ehy do you have 2 rigidbody variables... Player Rb & Rb ...?!?

tender willow
rigid island
vestal arch
#

!code

tawny elkBOT
vestal arch
#

please don't use screenshots

rigid island
tender willow
vestal arch
#

because that zombie has a rb?

sonic portal
#

yeah you use the RB variable but attached the Rigidbodfy to the Player Rb variable..

vestal arch
#

look at those 2 objects at runtime

sonic portal
#

you only need normaly only one Rigidbody for the object..

vestal arch
#

if you want to be sure, just add a [RequireComponent(typeof(Rigidbody))] to your parent script

rigid island
sonic portal
#

you use 2 and attached it to the wrong ones

vestal arch
#

and the "player rb" is not the rb of the zombie

sonic portal
#

in code he uses rb = GetComponent ...

rigid island
#

assuming they want to do maybe like a Hit react with AddForce to player or something

sonic portal
#

not PlayerRb thats the prob

vestal arch
rigid island
#

Just assign rb through the inspector (no need for rb = GetComponent here)

vestal arch
naive swallow
sonic portal
#

yeah cause it isnt even used

rigid island
#

we havent seen the entire script

sonic portal
#

in the code above he posted its not in

rigid island
#

I mean they showed us 2 functions not the entire script

vestal arch
#

@sonic portal how is any of that relevant
the problem is with rb, as evidenced by the error
and it's being assigned by GetComponent
that's all
playerRb is completely irrelevant

tender willow
sonic portal
#

he just asigns the rb var

tender willow
rigid island
#

its possibly playerRB is a hit react

vestal arch
#

yeah how is that relevant to the issue

rigid island
#

playerRb isnt even being accessed , so its irrelevant

sonic portal
#

he asigned the Rigidbody to the PlayerRb.. thats not used

naive swallow
vestal arch
sonic portal
#

need to asign it to the Rb

vestal arch
#

it's completely unrelated

naive swallow
rigid island
#

why would they assign the playerRB to the rb variable

tender willow
naive swallow
#

They're not related to the problem at all

tender willow
#

no need to speculate

rigid island
#

put the rigidbody and assign it in the inspector..

naive swallow
#

And drowning out the solution

rigid island
#

rb = GetComponent<Rigidbody>(); is not needed anyway if you assign it through inspector which you should do for components on the same object

mossy wedge
rigid island
#

DI > runtime

#

also GetComponent can get unnecessary extra compute time..
Imagine you have thousands of gameobjects with GetComponents in Start /Awake.

#

You're gonna have a bad startup time

naive swallow
#

If you can drag it in, you should. It's faster that way, reduces scene load time

vestal arch
#

πŸ€” i tend to use RequireComponent+GetComponent for that
i guess "good DX" can be different for different people

rigid island
#

OnValidate I do use GetComponent some times
but thats editor only anyway and takes care of autoassign

vestal arch
#

but i haven't made scenes with a ton of objects, so maybe i'll encounter that load time issue later 😁

naive swallow
#

It's not a huge benefit, but when it's completely free, why not go for it?

mossy wedge
#

Ig I will continue on my getcomponent ways for now and really consider DI if I reach a scale where the performance impact is significant

vestal arch
mossy wedge
rigid island
#

if you have like 10 fields for the same gameobject yeah its a pain lol

#

but yeah as you said Editor things like RequireComponent or GetComponent in things like OnValidate can mitigate that you get best of both worlds as long as it aint runtime

vestal arch
mossy wedge
rigid island
#

its not a huge deal esp if you dont have many objects but yeah its free optimizations so why not

rigid island
#

oh nvm lol I get it

mossy wedge
rigid island
#

aside from OnValidate now I only use GetComponent if I need a runtime ref through collision or other queries

#

but TryGet ofc

#

we don't have built in TryGetInParent/Child but made extension method for it πŸ™„

mossy wedge
#

What would the use case of a get comp be in on validate? I'm curious

rigid island
mossy wedge
rigid island
#

its the next best thing to SerializeField assignment imo

#

the problem only comes with the same issue at runtime, if you have multiple of the same component (two box colliders) but you want to only work with a specific one, you can't tell GetComponent which one you want as it grabs the first one

tender willow
#

if I have problem regarding multiplayer I should go to #archived-networking even tho the problem is somewhere within code?

rigid island
somber nacelle
rigid island
#

Ah UnityChanClever Reset forgot about that lol

mighty herald
#

Can anyone help me, I'm trying to create a "Map" extension function which will map a value to another one as long as it's set.

// Given
int? i = null;
int j = 4;

AudioClip? c = null;
AudioClip d = /* a non-null audio clip */

i.Map(x => j);  // Should be an int? which equals to null
i.Map(x => d);  // Should be an AudioClip? which equals to null

c.Map(x => j);  // Should be an int? which equals to null
c.Map(x => d);  // Should be an AudioClip? which equals to null
#

I have this so far, but that won't work as it uses default, so when I map to a boolean it'll use false...

public static TResult? Map<TValue, TResult>(this TValue? value, Func<TValue, TResult> fn)
{
  return value == null ? default : fn(value);
}
rigid island
#

ohhh thought that was a Predicate<T>
nvm this goes beyond my monkee brain forget me.. lol

mighty herald
#

If I try to return null, it complains with this: Cannot convert expression type 'null' to return type 'TResult?'

mighty herald
#

No, I'm just trying to map a value which may be null to another one, just when it isn't null

leaden ice
#

not sure i understand tbh

mighty herald
#

The code I'm using it for is this:

TaskResult? maybeResult = audioSource
  .Map(src => audioClip.Map(clip => PlayClip(src, clip)))
  .Map(x => TaskResult.Success);
#

The idea being I have an AudioClip? and an AudioSource? and I just want to play a sound if both are not null, then I want to get TaskResult.Success if that worked

#

Assuming PlayClip never fails of course (it always returns true for now)

leaden ice
mighty herald
#

Not in the way I'm used to code in πŸ˜…

tender willow
fading quail
#
using PrimeTween;
using Unity.Cinemachine;
using System;

public class CameraTransition : MonoBehaviour
{
    [Header("Cinemachine settings")]
    [SerializeField] private CinemachineCamera virtualCam;
    [SerializeField] private Transform followTarget;

    [Header("Initial values")]
    [SerializeField] private Vector3 startPosition = new Vector3(0, 0, -10);
    [SerializeField] private float startSize = 10.8f;
    [SerializeField] private float waitTime = 2f;

    [Header("End values")]
    [SerializeField] private float targetSize = 5f;
    [SerializeField] private float transitionDuration = 1f;


    private void Start()
    {
       
        transform.position = startPosition;
        virtualCam.Follow = null;
        virtualCam.Lens.OrthographicSize = startSize;
        Invoke("StartCameraFollow", waitTime);
    }

    public void StartCameraFollow()
    {
        // Tweenataan ortho-zoom
        Tween.Custom(virtualCam.Lens.OrthographicSize, targetSize, transitionDuration, onValueChange: value =>
        {
            virtualCam.Lens.OrthographicSize = value;
        });

        Vector3 destination = new Vector3(followTarget.position.x, followTarget.position.y, startPosition.z);
        Tween.Position(transform, destination, transitionDuration)
    .OnComplete(() =>
    {
        virtualCam.Follow = followTarget;
    });

    }

}```


Quite a long code but my cinemachine does a little down up when I set the followTarget. How can I avoid that?
leaden ice
#

That's like 6 lines of code, not long lol

#

as for the "updown" it's not clear just from the code what's causing it

fading quail
#

Well That is the only thing attached to the cinemachine

leaden ice
#

That might be the only piece of your code on the object but there are certainly at least 2 cinemachine components

#

What I mean is that your configuration of the camera along with the position and behavior of the objects in your scene is causing it most likely

fading quail
leaden ice
#

what object are you having it follow

#

also it seems like your script is also manually moving the object

#

so it may be fighting with the CM stuff

fading quail
#

Its just this player. It doesn't have anything else than sprite now

leaden ice
#

you should be using Framing Transposer not CInemachineFollow afaik

fading quail
#

Yeah 2d

#

Oh every Unity tutorial uses cinemachine πŸ˜„

rigid island
#

the new 3.0 changes are still a bit confusing πŸ˜…

fading quail
#

Framing Transposer is deprecated

#

I see that position composer is the new

rigid island
#

yeah they split some stuff up and confused me lol

#

worse case scenario i switch to 2.x

proven thicket
#

Ive been looking to create some voxel destruction similar to games like clone drone in the danger zone. Ive struggled to find any tutorials or templates for it

#

anyone have any recommendations?

leaden ice
proven thicket
leaden ice
#

I think there's a combination of effects at play here

#
  • a VFX for the little random cubes that break off
  • Possibly replacing the character model with a set of individual MeshRenderers at the moment of death
  • the particular renderers that god hit maybe using a "slice" style shader to simulate being sliced to pieces
#

Oh i see they also can have their legs broken off and stuff - probably just the characters are made of several pre-built pieces (individual MeshRenderers) rather than one SkinnedMeshRenderer

#

This doesn't scream to me full-fledged voxel engine destruction the way Teardown is for example

hybrid flower
#

where can i upload code to send here

vestal arch
#

!code

tawny elkBOT
hybrid flower
#

So im making an endless runner that will spawn (for the time being) these 3 variations of Tiles that will continously spawn and move away from the camera,

vestal arch
#

ok, what's the issue

hybrid flower
stone rock
#

Is it required to use ComputeShader.FindKernel()?

If you have 2 kernels first CSMain for example and then below it CSSecond for example. Will the main one have index 1 and second index 2? Or is it a bit random?

hybrid flower
#

@vestal arch any clue why the tiles are spawning so weirdly

leaden ice
#

then look at your prefabs and make sure the root object pivot is correct

#

and that the prefab root is not offset weirdly

hybrid flower
#

root object being the player ?

leaden ice
#

the root object is the "main" aka topmost object in the hierarchy of the prefab

#

talking about the tile prefabs

vestal arch
hybrid flower
hybrid flower
hybrid flower
leaden ice
#

Not hugely offset from the root or something?\

hybrid flower
leaden ice
#

note that your code is repeatedly setting th eposition of StartPlane3

#

Also rather than going down the YandereDev path of "variables nam,ed with numbers after them" and "huge blocks of repeated code" I recommend to take a minute or so to learn to use arrays and lists in C#.

barren glade
#
public class MovementController : MonoBehaviour
{
    [Header("components")]
    [SerializeField] private Rigidbody player_rb;
    [SerializeField] private Transform character;

    [Header("keybinds")]
    [SerializeField] private KeyCode crouch_bind;
    [SerializeField] private KeyCode jump_bind;

    [Header("movement")]
    [SerializeField] private float max_speed;
    [SerializeField] private float speed;
    [SerializeField] private float drag;

    // state
    private enum state {
        AIR,
        WALK,
        IDLE,
        JUMP,
        SLIDE,
        CROUCH,
    }

    private state player_state;

    public void state_manager() {
        if (player_rb.linearVelocity.magnitude <= 0) {
            player_state = state.IDLE;
        }
        else {
            player_state = state.WALK;
        }

        if (Input.GetKeyDown(crouch_bind)) {
            if (player_state == state.IDLE) {
                player_state = state.CROUCH;
            }

            if (player_state == state.WALK) {
                player_state = state.SLIDE;
            }
        }

        if (Input.GetKeyDown(jump_bind)) {
            if (player_state == state.AIR) {
                return;
            }

            player_state = state.JUMP;
        }

        if (player_state == state.AIR) {
            if (!is_grounded()) {
                return;
            }

            player_state = state.WALK;
        }
    }

    public void slide() {
        // early exit
        if (player_state != state.SLIDE) {
            return;
        }

        player_rb.AddForce(transform.forward * 10);
        
        // idk how to check if slide ended
        player_state = state.WALK;
    }

    public void jump() {
        // early exit
        if (player_state != state.JUMP) {
            return;
        }

        player_rb.AddForce(Vector2.up * jump_force);
        player_state = state.AIR;
    }```
#

I'm guessing I'm doing it completely wrong

#

cause it just looks wrong

#

and there might be even more states let's say wall-running

#

it woudl probably add like 4 more if clauses

rigid island
barren glade
#

i mean yeah I kind of need these

#

cause i don;t want to slide mid air or crouch

rigid island
#

whats the point of JUMP if you have AIR

#

if you jump you're already in AIR no?

barren glade
#

cause when im in jump state

#

the jump() function executes

#

once

#

and switches to air

#

cause it would keep adding force

rigid island
#

but you can just check if you're AIR to prevent multiple jumps

barren glade
#

I guess

#

but the point still stands

rigid island
#

and your jump should probably use an Impulse rather than applying constant force

barren glade
#

if i need

#

a lot of states

#

like wall-running

#

or any others

#

if i want to extent

#

scale the system

#

it looks wrong idk

rigid island
#

you dont want to split into many states imo

#

some states can coexist

barren glade
#

okay but am i doing this wrong

rigid island
#

partially , I would clean it up a bit

#

starting with the suggestions i've made above

elfin tree
#

I'm trying to modify all my prefabs material, before a build, to be compatible with WebGL. My issue is that it modifies the actually prefab, not only it's instance in the build. How could I modify my code to only modify it within the build?

shadow wagon
#

you have to do cs instead of csharp with the backticks

elfin tree
#

the formatting is a bit off cause i ran out of characters

#

had to send as .txt

shadow wagon
#

mhmm

#

its interesting, ive seen a few people make the same mistake

elfin tree
#

csharp works btw

tawny elkBOT
shadow wagon
#

it does?!

elfin tree
#
example
rigid island
#

normally large code you send via links

shadow wagon
#

my bad then!

#

thinking back, i have only ever seen csharp when it comes to blocks of text sending as .txt

rigid island
#

both work fine

elfin tree
#

ah kk

#

for my issue chatgpt suggests modifying the prefabs then reverting the changes after the build is complete, feels bad but would work most likely

#

and the prefabs would get corrupted if the build fails

#

ikr lol

rigid island
#

I still don't understand, what exactly needs to be modified here? and why

elfin tree
#

some of my materials are broken in WebGL

rigid island
#

oh like the shader?

elfin tree
#

yup

#

so i'm trying to replace some shaders during the build

#

if the build is webgl

rigid island
#

you have 2 different versions already yes ?

elfin tree
#

kinda

lean sail
rigid island
#

Im oldschool..i would just make 2 copies instead of doing it by code

elfin tree
#

was doing this

    if (originalShader.name.Contains("poiyomi", System.StringComparison.OrdinalIgnoreCase)) {
                    var newMaterial = UnityUtility.CopyMaterial(renderer.sharedMaterial);
                    renderer.material = newMaterial;

                    newMaterial.shader = Shader.Find("Stamdard");
                    newMaterial.SetColor("_FirstOutlineColor", Color.black);
                    newMaterial.SetFloat("_FirstOutlineWidth", 0.025f);
elfin tree
shadow wagon
#

discord puts massive walls of text into a .txt file

elfin tree
#

forgot about that

shadow wagon
rigid island
shadow wagon
#

what kind of message would you need to send thats 4000 characters long, to warrant nitro

elfin tree
rigid island
#

you're in the editor so you already know you're doing webgl

elfin tree
#

then same question. how does it know which prefab to use?

#

i mean desktop builds can use any shaders, just not the webgl ones

rigid island
#

cause you're in the editor as WebGL build so you can make for example a WEBGL Boostrapper etc

elfin tree
#

it doesn't quite work like that, it will still work in play mode, but when you build it will break

#

(pink materials)

rigid island
#

I mean the object you need already has the shader with webgl compatible

#

all you need is a separate scene to initialize those instead of the "normal ones"

#

its probably more crude / less programmer friendly but it works, imo is most straight forward

#

they have all the same scripts anyway so the logic should still work the same

elfin tree
#

I feel like there has to be a way of doing this during the build instead

rigid island
#

sure there is, but more complicated

#

basically saying yes its a pain cause now you have copies of objects which can introduce annoyance at scale if you forget to change 1 but not the other.

elfin tree
#

well.. i guess i can just make a custom instantiate method that checks what material the prefab has (if in webgl) and modifies the material when needed

#

hopefully wont be too slow to do that in the browser

rigid island
#

do it during loading but if its a webgl not point to even put in the build the shaders/materials non-compatible

#

I would understand if you did automated CI/CD deploy but if you're in the editor mind as well do that before build

elfin tree
#

that's what i was doing IPreprocessBuildWithReport

#

but it modifies the prefabs

#

every item in the game pretty much needs that change so doing it by hand is not an option

rigid island
#

makes sense

#

mine had a few things so it was no biggie hmm

twilit girder
#

when i call
if (dataTotal.TryGetValue(kvp.Key, out uint currentValue1))
currentValue1 is always 0 instead of the actual value. Any ideas?

leaden ice
twilit girder
zinc flax
#

I'm using cinemachine camera for 2D but whenever I increase the X and Y damping, when I move the player the camera follow but it's not smooth as if the camera act with low fps. I followed a tutorial on youtube and he doesn't experience this problem.

leaden ice
#

as well as your cinemachine settings (including the brain update mode)

#

and how your player object is moving

zinc flax
#

Without camera damping, the player move is very smooth no problem here

#

This is the brain set on my camera

#

and this is on my cinemachine camera

tardy tendon
#

Can anyone spot what I'm missing here? No matter what I click, the ID is being set to 1.

edgy ether
#

this might be a bit of a strange question but is it possible to detect 3d colliders with a physics2d.linecast?

elfin walrus
#

why not a 3d linecast

latent latch
#

Two different physic APIs

leaden ice
edgy ether
#

well yeah that's the response i was expecting. but i was just curious if it was possible because i mostly didnt want to spend time rewriting all the 2d ray/line casts into 3d equivalent, so i was looking to see if there was any small workaround.

elfin walrus
#

doesn't look like you can tho

edgy ether
#

ah ok

#

well guess i'll just bite the bullet

edgy ether
#

was using 2d linecasts and raycasts to detect some collisions, but im in the middle of making some 3d sections and wanted a nice way to switch from 2d colliders and 2d rigid body to 3d without doing too much. but it's probably better i tackle this anyways for learning sake

latent latch
#

If you're going to use 3D, then just use the 3D API and forgo the 2D

#

lock axis if needed

tardy tendon
leaden ice
#

the point is

#

exactly what you have but with the temp variable

tardy tendon
#

I get it, but it's still not working. Using a temp variable now sets the ID to the array length...

tardy tendon
leaden ice
# tardy tendon

looks fine. What makes you say it's setting the ID to the array length?

tardy tendon
leaden ice
#

what are we expecting to see here?
Also you have a lot of other errors πŸ€”

#

Where is that Debug.Log from?

tardy tendon
#

2 secs, gonna try something quick with some debug logs

#

I check what Portrait ID is set when the DrawActorWindow is called.

leaden ice
#

where is portaitID declared?

tardy tendon
#

The only other time I change this value is when I click on an actor to load up their details

#

This is the editor window

#

When you click an actor it resets the Portrait and Sprite IDs

leaden ice
tardy tendon
#

When the Window is created

leaden ice
#

well that's your problem

#

you have one portait id for the whole window

#

not one per button

#

er.. hmm I guess... this should actually work anyway?

#

Can you show that Debug.Log?

tardy tendon
#

Which one sorry?

leaden ice
#

!code

tawny elkBOT
leaden ice
#

Show DrawActorWindow

tardy tendon
leaden ice
#

I don't see anything wrong with the code πŸ€”

#

Start adding more logs yeah

#

Make sure portraitId is not set anywhere else

#

and put a log every time you do set it.

tardy tendon
leaden ice
#

add those logs :p

zinc flax
leaden ice
#

and how you do movement for it