#archived-code-general

1 messages ยท Page 21 of 1

covert turret
#

time to learn how vectors work @low nymph

#

Try using LookAt

robust spire
#

I want to ensure that I am instantiating my gameObject with enough space around it, such that when it rotates around (2D space), it won't clip with anything. I thought bounds would be the solve, but as I rotate, the bounds (understandably) updates. Any tips on a programmatic way I can find the maximum possible value of a bounds extents? Ideally something I could determine in editor, rather than runtime.

steady moat
robust spire
# potent sleet https://docs.unity3d.com/ScriptReference/Physics2D.OverlapCircle.html

For this to work appropriately, I need to know the radius I want to search within, which my current thinking leads me to the extents of the collider (forgot some important context: it's an EdgeCollider). The collider shape is non-uniform so its extents change as it rotates on its Z axis, so I can't easily find the radius of which to put into such a function

potent sleet
robust spire
# potent sleet use the longest corner / vert point

Ah, thanks. Browsing the Scripting API no built in method for this stands out so I suspect this would be a custom method parsing each point for the furthers from center - is that your understanding also or is there another approach?

potent sleet
#

get roughly the right radius from center

#

you can also get array of points in the Collider since it's a edge collider , find your radius by getting your largest distance from 1 collider point to another, I think

robust spire
modest carbon
#
public class NoteScript : MonoBehaviour
{
    public GameObject noteText;
    private bool isReading;
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.E) && noteText.activeInHierarchy==false)
        {
            noteText.SetActive(true);
            isReading = true;
        }
        if (isReading && Input.GetKeyDown(KeyCode.E))
        {
            noteText.SetActive(false);
            isReading = false;
        }
    }
}


is this note system realiable

broken light
#

what would the general technique be to press and hold a ui button in unity and have it execute a function every x milliseconds

#

because onclick requires press and release so thats no good

cosmic rain
cosmic rain
broken light
#

is that still used if using the new input system?

cosmic rain
#

Is UI affected by the input system?

broken light
#

i assume so

cosmic rain
#

Hmmm... I don't know about it. Haven't used it yet, so not sure.

broken light
#

ill play around with it and see

cosmic rain
#

But I don't think it is. These are event system events, so they're probably independent from the input system.

crimson rune
#

Hey, im making a chess game. I am trying to move the peice i am currently dragging to mouse Position. When using transform.position, it breaks my movement logic. What should i do? My code is attached

#

(This is for school btw thats why there is so many comments)

mental rover
crimson rune
#

When i do it the reference of the previous sqaure my peice was on is dropped so i cant move my peice back to that square

#

@mental rover

#
            Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            currentlyDragging.transform.position = mousePos;
        }
#

That code

mental rover
#

it looks like you're doing some strange casting between Vector2's and Vector2Int's, storing board positions as Vector2's?

crimson rune
#

Im storing them in dictionaries

mental rover
#

you might well be running into rounding and float comparison issues there

crimson rune
#

hmm

#

should i change everything to int?

#

Since i dont really use float bar the mouse Pos

#

_ExactPeices[new Vector2(previousPosition.x, previousPosition.y)] = null;?

#

mabye i can drop the reference of the previous pos

mental rover
#

I'd try to approach it as having two layers, a data layer and a visual layer - the data of the pieces/board should be described with strictly ints, or Vector2Int if you prefer

#

the visual should use the data where appropriate, but has some freedom with where you have the visual gameobjects

#

in the case of an invalid move, you can refer to the data for where the piece should've been, and just discard the temporary visual

crimson rune
#

Oh right, i didnt think of that

#

Thank you!

wide fiber
#
  private void Update()
    {
        SwitchingLevel();
        pressed();
    }

    void NextStage()
    {
        stageSelect = 2;
    }
    void SwitchingLevel()
    {
       if (stageSelect == 1)
        {
            Instantiate(Stage[0].stages);
            stageSelect = 0;
        }

       if (stageSelect == 2)
        {
            Instantiate(Stage[1].stages);
            stageSelect = 0;
        }
    }```

hi. i want everytime i complete stage it will go to the next one which i will put "stageSelect++" BUT it will keep update every frame on that instantiate which i do not want, any suggestions? i just want that stageselect to spawn only once ๐Ÿ˜…  sorry
crimson rune
#

By stage do you mean scene?

wide fiber
crimson rune
#

What exactly is the problem? Do you not want the function to be called? If so, what function?

wide fiber
#

I want my instantiate to do it only once, reason i put stageSelect = 0 after select a stageSelect is because i want it to spawn only once. But now i want to put stageSelect++ everytime i completed that wave so i cannot put stageSelect = 0 however the problem of that is it will spawn every frame which i do not want. Any suggestion?

mellow sigil
#

If you want it to happen only once at that point then why don't you just call the function there where you want to

crimson rune
#

yea? Or add a parameter before calling the function in update

mental rover
#

they are a complication that isn't needed but, if you're doing that in Update, are probably missing from your toolbox and are powerful to know

wide fiber
#

ah ok. will search on that! thankss and thanks all of u too!

viscid sleet
#

Any idea how to make an object go from point A to point B in a curved path, like half a circle

wide fiber
#

easy to understand

obsidian trench
#

(targetPos - transform.position).sqrMagnitude > Mathf.Epsilon
what does the above line mean?

cosmic rain
#

More or less that the distance(actually distance squared) to the target position is more than epsilon(an extremely small value close to 0)

obsidian trench
#

ahhh got it

rapid prairie
#

We always have the problem that when opening a UI element it is not resized correctly. This always affects game objects that are activated and filled at runtime (e.g. tooltips). I analyzed this and found out that ContentSizeFitter does not wait for TextMeshPro rendering among other things.

If something is changed (e.g. a text in the inspector) everything looks top. But independently unity does not get that done.

There must be a way to make this easier. Does anyone have an idea?

viscid sleet
desert shard
#

Gimble Lock Issue (I think)

calm bobcat
#

Hi all! l am currently having issues with a small "dungeon-like" generation l am making. In order to avoid the path overlapping itself, l have tried to use the Physics.OverlapBox() function to help with that but l am not very sure how to set it correctly, resulting in scenarios like these.

#

Each object l am making has a box collider, which gets used to determine the parameters needed in that function.

#

Here's where l have defined the overlapping function (l don't think there is need of showing what's in that Extension.DisplayBox() function)

calm bobcat
#

l copied it from somewhere so l won't go and bother with Gizmos

leaden ice
#

ok so... what's the point of the overlapBox thing?

#

it's just setting a bool

#

are you doing aything with the bool?

#

Why is it running in Update?

#

What object is the script attached to?

calm bobcat
leaden ice
#

that's the point of all this

#

why not jsut directly do the overlapbox here

#

why does the object need to do its own overlapbox?

calm bobcat
leaden ice
#

and then you're doing this waiting thing, seems overcomplicated

leaden ice
calm bobcat
#

Well, it meant to make it easier

leaden ice
#

how does this make it easier?

calm bobcat
#

well l just didn't want to fit that much into one entire class

calm bobcat
leaden ice
#

you're doing this:

  • spawn an object
  • wait for its Update to run
  • in update if it overlaps comething it sets a bool to true
  • you wait some time then check if that bool is true.

Wouldn't this be simpler:

  • Do an overlapbox
  • if it doesn't hit anything, spawn the object
  • if it does, pick another place
  • spawn the object once you've found a free place
calm bobcat
#

l get it

#

But l'm not sure how to simply that overlapbox

leaden ice
#

like you have this whole extra obejct you're spawning, you don't need to spawn an object just to run OverlapBox

calm bobcat
#

if you want, you can modify it

leaden ice
#

I won't

calm bobcat
#

But l still don't get it why can't l just set a position and some start and end points to make that overlapbox

#

Would look slightly easier that way

#

At least in my perspective

calm bobcat
#

How?

leaden ice
#

wdym?

calm bobcat
#

l can't understand how to it

leaden ice
#

Just call OverlapBox with whatever parameters you want

calm bobcat
#

no l mean why do l need to even give it a center

#

why couldn't be just a from vector3 to vector3

#

and just check whatever it gets in these positions

leaden ice
calm bobcat
#

hm?

leaden ice
#

just make a function that takes a "from" and "to" vector3, does a little math, and does the correct OverlapBox for it

late lion
#

This seems like it could be simplified by not using the physics engine and just comparing the bounds of each room manually. Then you don't even need to spawn anything until you've found a layout that works.

leaden ice
#

that too

#

just use a grid coordinate system

calm bobcat
leaden ice
calm bobcat
#

l will give that a look

#

Never heard or used that type

late lion
#

An integer grid will definitely simplify things, but it doesn't look like your rooms are designed to fit inside a grid.

calm bobcat
#

each part consists of quads with the same size

elfin basin
#

I noticed whenever I do anything with either of these, to fade my audio out and in for a pause menu, it doesn't do anything. Everything seems set properly. I don't get any errors. Any ideas here? It doesn't do anything for either line here. Have tested both themselves and together here.

            vehicleMixer.SetFloat("Attenuation", carVolume);```
calm bobcat
late lion
calm bobcat
#

what's the difference with Bounds and BoundsInt actually?

#

l've seen other people doing stuff like IntVector2 and such

late lion
#

Bounds uses float and BoundsInt uses int

calm bobcat
#

l mean

#

does it really change the workflow?

leaden ice
#

yes

elfin basin
#

Nothing to do with playerprefs or anything like that

calm bobcat
#

Anyway l will try and give a better look

#

Thank you @leaden ice and @late lion for your suggestions

#

l will see what can l do

desert shard
uncut vapor
#

Does anyone have some nice code for fractal noise generation? I can't find any

west sparrow
#

That's also a great question for ChatGPT

compact socket
#

i need help , for whatever reason the code in the 3rd image executes the code in the first image when it is supposed to execute the second when calling the Condition () function ; does anyone know if i'm missing something ?

tawny elkBOT
#
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.

compact socket
#

hold on, "new" to this

#

ok lets try this again , hello i have a problem where for whatever reason when i call my Condition function , the base form of this function is executed and not it's Ovewritten form ; https://paste.ofcode.org/uxf3dhF59PdUPTyxVXPLEt code here ,
does anybody know what i might be missing ,
the 2 functions are the first one on a base class and the second one on a 2nd class that inherits the first class

proper oyster
#
chilclassInstance.Contition(player,point);
compact socket
compact socket
proper oyster
#

Martial is the child class isntance?

#

or is it the instance is stored in a variable of the base type

compact socket
compact socket
#

funny thing is that this works with Other inherited classes and with other classes that inherit this base class

proper oyster
#

can you do

Debug.Log(player.AbilityInventory.Martial.GetType().ToString());
compact socket
#

sure , good idea

#

the result is that it sees this class as it's base class
Ability_OBJ
UnityEngine.Debug:Log (object)
basic_melee:Update () (at Assets/Scripts/basic_melee.cs:28)

proper oyster
#

so you would need to change the type or cast to get what you want

compact socket
#

funny thing is that it woks with a similar class , hold on ...

proper oyster
#

if you define a variable of type Collider
why would the code know that you wanted to use the Box collider that is stored in there
so it behaves like you wrote it

compact socket
#

this class also inherits this Ability_OBJ class(and it is called the same way as my "problem class" ) and yet the condition function works as intended here

proper oyster
compact socket
#

cs // [SerializeReference] public Ability_OBJ Martial;

#

this one doesnt work

#

however
cs// [SerializeReference]public Ability_OBJ Lethal;
this one does

proper oyster
#

why would you expect a variable of type Ability_OBJ to be somthing other then Ability_OBJ if you don't cast it to a sub type?

compact socket
proper oyster
#

let me do a quick test

compact socket
proper oyster
#

mmm wired
you where right it should have worked

compact socket
#

thanks @proper oyster but i found my problem , i initialized by class wrong

proper oyster
#

ah ok

#

sorry for possible steering you in the wrong direction

compact socket
#

aka i missed a constructor and it was creating it as Ability_OBJ class and not it's intended class

compact socket
#

this....

#

agghhh

swift falcon
#

Is it possible to have an advanced code editor (like vs code or pycharm) in a game, so the player can edit scripts? Is there a way to run a .exe File on Windows and somehow "capture" the gui as an image and display it in a unity game?

dawn dock
#

https://gdl.space/pojuyiqama.cs - Does anyone know why this code enables the player to jump infinitely in the air? It's a 2D game where the player should only be able to jump everytime the player lands on the ground.

mellow sigil
#

don't cross-post

proper oyster
#

if you are looking into allowing some kind of scripting at runtime you might want to look at lua

swift falcon
#

so i can distribute it

swift falcon
swift falcon
knotty sun
#

or better yet, a Winfoms shell which spawned the Unity build

swift falcon
#

i haven't heard anything about these things, can you provide a little more detail or an idea where i could find more information

knotty sun
swift falcon
#

i googled it

#

thanks for you effort, but like one sentence what this is and how the image of the applicaiton gui would "go into unity"

#

because it seems like windows forms is a tool to code windows applications, but i want to "capture" them

ancient cloak
#

capture them how

#

by like hijacking the process?

knotty sun
ancient cloak
#

you need to apply a vertical impulse or apply an additive force over a set interval

dawn dock
#

Ok

dawn dock
swift falcon
#

If I spawn a sword prefab with ScriptableObj embedded in its references, will spawning a shield, with same SO embedded, create a second copy of SO?

ancient cloak
# dawn dock So how would I go about doing that

you can use Input.GetKeyDown to check only the frame that a key is pressed
you can use ForceMode.Impulse for an instantaneous force

Rigidbody rb;
rb.AddForce(Vector3.up * whateverMyJumpForceIs, ForceMode.Impulse);
dawn dock
#

Thanks

slender nymph
#

is their anyway i can minimize unity standalone on a button click ?

ancient cloak
#

windows+d, clicking the icon

#

windows+down arrow

swift falcon
swift falcon
#

Another way could be to use Vscode in a browser. Is there a reasonably fast way to have webbrowser in a unity game?

knotty sun
swift falcon
#

yeah ok, so you say there is a way to capture the image output from winform programs?

knotty sun
#

of course

swift falcon
#

and you are able to give mouse and keyboard inputs back from unity to the winforms applicatio?

ancient cloak
#

oh boy

knotty sun
#

if you write a shell around the unity build, yes

#

this is WinForms 101

ancient cloak
#

i'm getting the feeling that you're being aggressive unnecessarily, especially because either your conceptual understanding of windows applications is wrong or your vocabulary is inaccurate

#

would you call wpf and uwp apps "winforms"?

swift falcon
#

ok. i don't have any idea how to do this. What about using a webbrowser in unity? I've tried some "unity webbrowsers" but none seemed to work (last github commit 4 years ago type of stuff).

knotty sun
ancient cloak
#

oh i thought you were saying that every windows application is a winform application

#

idk if there's anything already built in the asset store @swift falcon but you can build your own web browser for sure

knotty sun
#

we are talking about a unity build, it's not for nothing that unity has a separate uwp build platform

calm delta
#

my instantiated objects are spawning like 1+e12 away..?

i'm setting the x position to something between 0-15

ancient cloak
#

and it's deprecated so RIP all that effort

proper oyster
swift falcon
swift falcon
knotty sun
swift falcon
#

yeah nice, but it says here that unity uses emscripten to compile into webassembly but that's far from what i need

swift falcon
#

i have no idea how this could be usefull for my application

knotty sun
#

As this started as a question about windows builds, neither do I

swift falcon
#

Ok, my question is again, how can I have a code editor for python inside a unity game, so the player can edit scripts. So my question is, if it is possible to run a windows application inside unity, so that the gui windows is "inside" the unity window, for example on a render texture.

leaden ice
#

run a windows application inside unity
Seems like a very poor way to accomplish:
how can I have a code editor for python inside a unity game

swift falcon
#

Yeah true, but i want a high quality editor (syntax highlighting, autocompletion etc) but I'm definitely not able to code this from scratch in unity

leaden ice
#

I would approach this by including a python interpreter in my game and building out the UI etc in Unity

swift falcon
#

yeah ok, another idea might be to have a python language server running with LSP and using this data to power the editor features

leaden ice
swift falcon
#

No, vscode and intelij are released with the MIT and Apache license

knotty sun
swift falcon
#

what do you mean, if i want to have the editor on a "screen", that you can move around in 3d space, a render texture seems straigt forward

knotty sun
#

but a texture is just that, a bitmap image, not an editor workspace

swift falcon
proper oyster
#

@swift falcon its a bit of work but that git package works

swift falcon
swift falcon
leaden ice
proper oyster
#

like the documentation says
(still some errors that i would have to figure out)

knotty sun
hybrid rivet
swift falcon
#

how to have 2 keys at a time on input manager on unity ?

swift falcon
proper oyster
potent sleet
swift falcon
proper oyster
#

just open the file

potent sleet
#

if(Input.GetKey(key1) && Input.GetKey(key2)) //do stuff

swift falcon
#

like:

swift falcon
potent sleet
swift falcon
potent sleet
proper oyster
#

@swift falcon you might also need to setup some stuff in the inspector

swift falcon
#

I used the prefab from the samples thing

swift falcon
potent sleet
swift falcon
#

yes

#

wait

swift falcon
#

actualy i already combined in one animation called shot + run

potent sleet
#

so what is it you want to do

swift falcon
#

i just wanted something that triggers this animation

#

like 2 keys at a time

#

now ik

#

thanks

swift falcon
swift falcon
potent sleet
#

your IDE should automatically fix it usually

swift falcon
proper oyster
swift falcon
#

yeah

proper oyster
#

wired it works for me

swift falcon
#

even tho it's the same name

potent sleet
#

!code

tawny elkBOT
#
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.

swift falcon
#

you have to use three of these ` @swift falcon

{

                if (Input.GetKey("Wforward") && Input.GetKey("Hit"))

                {

                    GigaKnight.GetComponent<Animator>().Play("Hit + Run");

                }


            }
        }

swift falcon
#

when ever i copy it doesn't want to

void ledge
#

Hi I am currently working on the animation for my character but once I hit play it for really reason plays a random pose that was not included in my imported animation and stuck at that pose without changing to any others. the mesh of the character also moved vertically. Do anyone have any suggestions on how to fix it?

heavy sun
#

Anyone here a 3d modeler (if you are pls DM Me)

potent sleet
prime sinew
#

quit dodging the question.

#

if it's for collaboration, you were directed to the forums already

void ledge
heavy sun
#

Bro forms are dead

void ledge
#

I set up the animator like this

prime sinew
# void ledge

show the animator component please? it'll be in the inspector

swift falcon
void ledge
swift falcon
#

here'

prime sinew
#

the place you see your scripts on your objects. Show me the Animator component on it

potent sleet
potent sleet
#

also that animation name is sus @swift falcon

swift falcon
#

Input Key named:Wforward is unknown

prime sinew
# void ledge

are you sure this is the only Animator component in your scene?

potent sleet
prime sinew
# void ledge

can you please type t:Animator in your scene search bar?
then see if there's an animator that does not have the Controller assigned

potent sleet
#

or make one called Wforward @swift falcon

#

it's missing in Input asset

swift falcon
potent sleet
mellow sigil
#

Are you trying to use virtual buttons defined in the input manager? It's GetButton for those

potent sleet
#

this ^

void ledge
swift falcon
prime sinew
swift falcon
swift falcon
potent sleet
prime sinew
#

Scene is where you see all your gameobjects in your scene

#

oops

#

i think it's called hierarchy

#

my mistake

void ledge
#

2 results

#

not sure what's the first component is ๐Ÿค”

prime sinew
prime sinew
void ledge
prime sinew
#

I googled "Animator is not playing an AnimatorController", if you want to find more info on it yourself

void ledge
swift falcon
#

i'm having some trouble formatting a date string correctly
i call this function with the parameter being in seconds but i only get 00s 01ms, or if i remove the if statements and just set it to days and hours i get 00d 01h

i've debug.logged both the time and timespan and they're both accurate, it's the formatting that's not working for some reason

{
    TimeSpan t = TimeSpan.FromSeconds(time);
    string timeString = "";
    if (t.Days > 0) timeString =  string.Format($"{0:00}d {1:00}h", t.Days, t.Hours);
    else if (t.Hours > 0) timeString = string.Format($"{0:00}h {1:00}s", t.Hours, t.Seconds);
    else timeString = string.Format($"{0:00}s {1:00}ms", t.Seconds, t.Milliseconds);

    return timeString;
}
void ledge
ember cedar
#

projectile doesnt destroy itself and doesn show particles when collides with bricks, what did i do wrong

simple egret
#

Make sure OnTriggerEnter2d actually runs

somber nacelle
#

and that the colliding object has the Bricks tag

simple egret
#

Oh and Invoke is useless here, just call the method directly

ember cedar
viscid sleet
#

How can I make an object follows a path from A to B in a curve like this?
Like how can I make that curve, and how can I tell the object to follow that curve (path)

faint scroll
#

how to edit these two colors through script?

leaden ice
#

or is this a particle system? What is it

faint scroll
#

stuck here:
transform.Find("Exhaust").GetComponent<ParticleSystem>().startColor.

faint scroll
#

dont know if it belongs here as it is more scriptrelated

faint scroll
#

i saw that, but it only accepts one color, no? lemme try

faint scroll
#

thanks

viscid sleet
#

OK thanks a lot, I will learn about it ๐Ÿ‘๐Ÿป

faint scroll
#

uhm

leaden ice
#
var mainModule = blahblahblah.main;
main.startColor = ...;```
faint scroll
#

im confused

#

why is that?

leaden ice
# faint scroll why is that?

it's a quirk of how C# treats value types that are returned from properties, combined with a quirk of how Unity designed structs like ParticleSystem.MainModule

#

Unity basically is abusing structs to act like pointers into their native code, and C# isn't used to structs that do that and assume you're going to shoot yourself in the foot changing a struct that doesn't actually get saved anywhere

proud juniper
#

Is there a simple way to have transform.TransformPoint(Vector3) ignore local scale? I tried dividing by localScale but I can't seem to divide two vector3's

proud juniper
#

Will try, thanks

leaden ice
#

take that back - TransformDirection should be right

proud juniper
# leaden ice use TransformDirection instead

TransformVector takes scale into account which is undesired, and TransformDirection doesn't seem to respect local space because I had it transform Vector3(0, 3, 5) and it just set my world position to 0, 3, 5. I guess I probably just need to add the result of transformdirection to the target transform's position

#

I think TransformDirection was the right answer and I'm being a goof

leaden ice
#

or you can do this:

Matrix4x4 mtx = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
Vector3 result = mtx.MultiplyPoint(theLocalPosition);```
proud juniper
#

what you sent makes sense btw

#

thanks for the insight and alternative approach

zinc parrot
#

Why does ComputeBuffer.GetData allocate GPU memory that it never unallocates?'

zinc parrot
#

it does

leaden ice
#

if it does that's a bug I suppose

zinc parrot
#

if I call it 17000 times
I end up with 40 gigs of VRAM used

fallow abyss
#

Anybody had issue before with netcode doubling their NetworkList? I used NetworkList for chest storage and when I launch host and put something in and then launch client and deposit something in chest either from host or client it duplicates the list content. So if I put 3 items there it will show 6. Strangely this only happens on first client load. When I close the client and start again, it works correctly.

zinc parrot
#

that is a lot of times, but when you have a complex scene with l.ots of meshes...

#

and its a huge problem for me rn
it happens in 2021 and 2022 at least

proper oyster
#

maybe ComputeBuffer.Release handels that?

#

or that is only to get rid of the compute buffer

zinc parrot
#

no it doesnt

#

I properly release all the compute buffers and such but still

leaden ice
#

doesn't VRAM imply CPU memory?

zinc parrot
#

GPU shared memory

#

hang on I got a screensho tof it

#

if I remove the call to GetData this doesnt happen

#

the climb in RAM and shared GPU ram

leaden ice
zinc parrot
#

btw what I am doing is reading from a vertexbuffer into a compute buffer to then get it on the CPU

#

wanted to make sure theres nothing I am missing before doing so

teal knot
#

Asking here because I didnt get an answer:
Anyone know why this code is causing the cube to rotate weirdly sometimes? I'm not sure what is causing it and it seems to only happen randomly. It might be an issue with DOTween but could not find anyone online mention it.

        visualCubeTransform.DORotate(cubeRotation, 0.2f, RotateMode.WorldAxisAdd).SetEase(Ease.InSine);```
steady moat
zinc parrot
#

shrug

#

it dont
I release the buffer manually

steady moat
zinc parrot
#

no?

#

I release the buffers used manually

steady moat
zinc parrot
#

no?

#

this is on a yes highly detailed scene but still a normal scene

#

I dont think I understand what you are asking

steady moat
#

You have an issue: Creating a buffer and releasing it seem to increase the memory used. If you isolate the issue, and do it till the memory is filled, does it cause an error ? Or the system continue to work as intended ?

zinc parrot
#

no
the buffers are fine
its the call to GetData that increases memory used

#

and it crashes my PC when memory fills up

steady moat
#

If it is really the GetData, I don't know what to say. Try to isolate the issue and replicate on a small project than do a bug report.

#

You have the Async equivalent, maybe it wont have the same issue.

zinc parrot
#

I tried async, same problem

#

and itll be really hard to create a small sample

steady moat
steady moat
zinc parrot
#

no but it needs to iterate over lots of thjings

#

oh wait no I see what you mean

#

if its an issue with just the getdata, simply calling it thousands of times should be good enough

steady moat
zinc parrot
#

yes

#

wouldnt make sense if its something else because it only happens if I use getdata, but we will see I suppose

#

hmmmm no its not doing it wtf

#

hrmmm

zinc parrot
steady moat
zinc parrot
#

I did
it didnt have the issue when I removed GetData
now im working in the opposite direction

steady moat
#

I feel like it might be the SetBool or SetBuffer

zinc parrot
#

hmmmm

#

but I clear all the buffers at the end

steady moat
#

You use Dispose, but the function is Release in the documentation. Is there anything I am missing ?

zinc parrot
#

no they do the same thing afaik
using either produces the same result

#

hmmm I wonder... hang on

leaden ice
#

well the using keyword would call Dispose

#

so if Dispose doesn't work that won't help

#

I would expect Dispose to call Release though

#

or vice versa

steady moat
#

Yeah, but it seems release call dispose

leaden ice
#

especially if they went out of their way to make these classes implement IDisposable

steady moat
#

scope your code down, and you will eventually find the issue.

#

At the moment, there is to much going on.

leaden ice
#

I do highly recommend the use of using rather than manually calling Dispose though, if applicable to your code.

zinc parrot
#

alright

#

yeah
having trouble getting it to recreate it tho

teal knot
#

no idea whats even happening here

#

although thats with the code altered to work on both axis' but even so that sort of thing shouldnt be possible

#
        visualCubeTransform.DORotate(cubeRotation, 0.2f, RotateMode.WorldAxisAdd).SetEase(Ease.InSine);``` different.y and x can only be 1 or 0
faint scroll
#

Input goes in Update and Physics in FixedUpdate right?

somber nacelle
#

typically yes

zinc parrot
#

uncommenting the GetData does it

#

wait lets see how much of the code I can remove

#

wait
one important thing, this is all being done in one frame

#

this is the new climb, with the dip there being a new frame

zinc parrot
#

any ideas?

late lion
#

Maybe ComputeBuffer.Release is queueing it for the next frame.

zinc parrot
#

is it not possible to release a compute buffer during a frame?

#

yeah thats what I am thinking... so theres no way really to fix this and keep it on the same frame then...?

#

is there ANY way to get around this?

leaden ice
#

Why do you need multiple buffers?

#

Can this not be done in one large buffer

zinc parrot
#

no
because every mesh has a different vertex buffer

#

and I need a running sum kind of thing

steady moat
#

you could still sum it all in one buffer

cedar tendon
zinc parrot
steady moat
zinc parrot
#

because my project has a hierarchy of root -> parent -> children
where the meshes live in children, and the buffers live in parent, and there are many children per parent, and many parents in root

late lion
# zinc parrot no because every mesh has a different vertex buffer

Either you need them all allocated at the same time, which means you need that much memory allocated anyway (so what difference does it make if it stays allocated for the whole frame?), or you only need to do one at a time, which means you can reuse one big buffer.

zinc parrot
#

uuggghhhh
so much work just to make it so I can read a mesh that isnt read/writeable

steady moat
#

Is it all about that

#

lol

zinc parrot
#

yes lol

#

so people can just drag and drop and not need to change data of their mesh

steady moat
#

Just toggle the toggle

zinc parrot
#

but I am making something for otherse to use

#

so while I could just toggle the toggle, itll be more work for others

steady moat
#

toggle the toggle with code

zinc parrot
#

wait you can do that?

steady moat
#

lol

zinc parrot
#

thought you couldnt do that to an already imported mesh

steady moat
#

you could even do it in the import process

#

and after

zinc parrot
#

wait how do you do it on already imported meshes?

steady moat
#

reimport them

zinc parrot
#

but...
for others with say hundreds of meshes already in their project

steady moat
#

you do it once

zinc parrot
#

(and meshes that you cant do that to)

steady moat
#

why you cant ?

zinc parrot
#

static meshes, or meshes imported with the gltf importer

#

Are not read/writeable and donโ€™t allow you to change that

late lion
#

And you need the mesh data on the CPU? You can't do whatever you need to do on the GPU?

zinc parrot
#

Yes I need to to build raytracing acceleration structures

late lion
#

Why do you need to make a ComputeBuffer though? Can't you just read directly from the GraphicsBuffer you get from GetVertexBuffer?

zinc parrot
#

Itโ€™s in a funky format ainโ€™t it?

late lion
#

Not any funkier than what you're already reading in the compute shader, I'm assuming.

zinc parrot
#

Yes but in the compute shader itโ€™s much faster to loop over everything and apply the appropriate offsets and such but Iโ€™ll look into the graphics buffer directly, very little info on it afaik

steady moat
#

Why are you building raytracing from scratch ?

zinc parrot
#

Compute shader based real-time pathtracer, able to handle millions of tris, been working on it for 2 years

steady moat
#

it already exist doesnt it ?

zinc parrot
#

No

#

Not for unity

#

And certainly not one this fast that doesnโ€™t use rt cores

steady moat
zinc parrot
#

yes? long time ago

opaque moon
#

Hello Everyone

zinc parrot
#

but this also allows me to explore graphics things and implement them such as ReSTIR and ReSTIR GI

fallow abyss
#

Anybody had issue before with netcode doubling their NetworkList? I used NetworkList for chest storage and when I launch host and put something in and then launch client and deposit something in chest either from host or client it duplicates the list content. So if I put 3 items there it will show 6. Strangely this only happens on first client load. When I close the client and start again, it works correctly. How is it possible that NetworkList has different value on client and server. It should be always synced right?

steady moat
#

There is always a difference when you are doing thing to learn. I'm just making sure that you are not losing time on something that won't be profitable

zinc parrot
#

mhm
I want to go into graphics research as my job as well

#

hmmm how do you get the vertexbuffer of a mesh on the CPU if you dont know its exact structure, do you have to have like 40 different structs, each with a different combo of elements?

steady moat
#

No, you use array and size

#

You push an array with a size, then read from the array given the size

zinc parrot
#

yes but the type

steady moat
#

The type you use to push the individual point

barren kelp
#

Iโ€™m watching a YouTube tutorial on aoe damage (my concept is a flash baton) in the tutorial he is doing this for a character. So his position is transform.position. Would I need to write something different so that the position it for the object I want it be attached to?

zinc parrot
#

on the GPU I would make it a byteaddressbuffer and read that but that doesnt work on the CPU

late lion
zinc parrot
#

oh?
ok
tried it as byte[] but that didnt work, will try nativearray

late lion
#

Either should work, as long as you have the right length.

zinc parrot
late lion
#

How did you calculate the length of the array?

steady moat
zinc parrot
#

wyes thats what I do
but the vertexbuffer contains multiple kinds of data

late lion
zinc parrot
late lion
#

A managed array won't be freed until the garbage collector collects it, which could take longer than a single frame.

zinc parrot
#

it doesnt create CPU memory, it creates GPU memory
shared GPU memory

late lion
#

AsyncGPUReadback does?

zinc parrot
#

yes

#

the GetData function

steady moat
#

GetVertexBufferStride, GetVertexAttributeOffset and related methods can be used to query the exact mesh vertex data layout and format, so that the compute shader can access it properly.

zinc parrot
#

yes
but then I need a seperate struct for each possible VertexBufferStride

late lion
# zinc parrot the GetData function

Are you sure? You mean you've tried using AsyncGPUReadback on the GraphicsBuffer returned by GetVertexBuffer and that allocated GPU memory? The examples you've shown so far all included creating a ComputeBuffer.

zinc parrot
#

no
not tried it yet directly on graphicsbuffer because i cant think of a way to create an array with the same stride

late lion
#

You just need to match the byte length, which is count * stride

#

And then you can read it as a byte array

#

And reinterpret it later with the information you get from the vertex attributes.

zinc parrot
late lion
zinc parrot
late lion
# zinc parrot

Try Data = new byte[MeshBuffer.count * MeshBuffer.stride]

zinc parrot
#

Hell
well that works but
same issue

steady moat
#

What are you expecting to do ? You are uploading the mesh data into the GPU then releasing it every frame ?

zinc parrot
#

no
reading the mesh data from the GPU back to the CPU

#

because it exists on the GPU for non read/write enabled meshes, but it doesnt on the CPU

steady moat
#

And why you need to do it every frame ?

zinc parrot
#

I dont
I need to do it in one frame one time

steady moat
#

You memory is released ?

zinc parrot
#

unity doesnt let it be released till the next frame

steady moat
#

And why is it an issue ?

zinc parrot
#

because for massive scenes, thats a LOT of data

steady moat
#

Which is what your operation demands

zinc parrot
#

yes

steady moat
#

Could you not divide the operation in multiple frame.

zinc parrot
#

not... really

steady moat
#

and why so

#

A loading is not expected to be instantaneous

zinc parrot
#

I mean I could
itll just get really complicated

steady moat
#

To be honest, if you truly want to learn. Maybe you should not use Unity. Unity seem to be more a pain in the ass then a tool for you.

zinc parrot
#

oh it is
but it makes it easy for others to use and learn from

steady moat
#

It should not matter whatever you are using Unity or not if you are trying to learn. I've use OpenGL to learn the basic of Graphic.

zinc parrot
#

fair

steady moat
#

There is a lot of tutorial on the topic.

#

And what is more, if you are going to work in graphics, you are expected to know theses API.

#

Direct X, Vulkan, etc.

zinc parrot
#

yeah

steady moat
#

Do your own engine. That is what you should strive for as a aspiring Graphic Engineer.

#

Sorry that I could not help you more.

zinc parrot
#

its fine, thanks!

late lion
#

@zinc parrot Would it be possible to move the acceleration structure calculation to a compute shader and keep everything on the GPU?

zinc parrot
#

I am actively looking into that tbh
its a complex acceleration structure but I know its possible, itll just be super complicated

fallow abyss
#

Anybody knows Unity Netcode here? I am struggling with NetworkList sync. Somehow it breaks on client but only on first load. If I add 1 item to NetworkList on host, connect client and then increase value of that item it duplicates it on client. So client's list now has count 2. If I close the client and then connect again, it works fine. No idea why it's only happening on first client load and why NetworkList doesn't sync correctly.

grim marlin
#

I have a question concerning camera. I am making a first person view controller. I have my player and a component who follows my player and inside this component my player.
When I want to move my camera should I rotate the object contening it or my camera ?

plucky inlet
grim marlin
leaden ice
plucky inlet
#

But if the container is just on root hierarchy and only holds the camera, it would make sense to rotate the container and not the camera to not mess up local and world rotation

grim marlin
#

Okay thx

fluid lily
#

Can we use Linq and is it cross platform?

leaden ice
#

It can produce garbage though so not recommended for things that happen frequently.

fluid lily
#

Yeah, until we get .net6+ in unity the performance is still not great

swift falcon
#
    void CheckForTarget()
    {
        for (int i = 0; i < allEnemies.Length; i++)
        {
            print("search");
            if (Vector3.Distance(allEnemies[i].transform.position, transform.position) <= targetDist)
            {
                currentTarget = allEnemies[i].transform;
                print("tar");
                isAttacking = true;
            }
            else
            {
                print("No tar");
                currentTarget = null;
                isAttacking = false;
            }
        }

        
    }

This only detects 1 object in the array. The last one to be specific. Why is that happening?

#

Is it maybe because it loops once?

#

Even though it Prints "search" always and the loop runs in update

leaden ice
#

it can only hold one thing at a time

#

and the end of the loop, it will be pointing to the last one it saw

#

currentTarget = allEnemies[i].transform; just overwrites the previous value

#

as does currentTarget = null;

swift falcon
#

Well it ingnores all other things in the array

leaden ice
#

wdym ignores

plucky inlet
#

It overwrites, not ignores

leaden ice
#

what do you expect it to be doing

deft timber
#

You need to keep track of the distance to the enemies if you want to get the closest one

leaden ice
#

what's the end goal of this code?

deft timber
#

Right now you're looping through all enemies in a certain range and getting the last one in the array as a target

swift falcon
deft timber
#

Because you are not checking for the closest one

leaden ice
#

how are you determining that
what are you trying to accomplish

plucky inlet
#

Lets explain. If you have 3 items in your list, and 1 and 2 are inside your threshold, the loop would set currentTarget to 1, then to 2 and then check on object 3 and set it back to null, because it will never check against the last currentTarget if its closer or if its != null

swift falcon
leaden ice
deft timber
#

If that is what you want to do then yea, you need to keep track of the closest enemy

plucky inlet
#

its just checking if anyone is inside one by one and in the end use the last item everytime as return value

deft timber
#

Right now you're looping through all enemies in a certain range and getting the last one in the array as a target

leaden ice
swift falcon
#

Alright @leaden ice @deft timber @plucky inlet ill do that right now

viral marlin
#
        {
            body.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
        }
        inAir = !Physics.Raycast(transform.position, Vector3.down, groundCheck);``` this is the code that is repsonsible for making jumping work in my game but it doesn't seem to work, not really sure what could be breaking it
plucky inlet
viral marlin
plucky inlet
viral marlin
#

just had a look and inAir was being set to true for some reason

swift falcon
#

@plucky inlet @deft timber @leaden ice Finally that stupid Bot works, thank you all

velvet quartz
#

Someone understand this error please ? I have an issue with event i think

viral marlin
#

I thought it would be set to fale due to it being inverted at at the raycast

leaden ice
#

show your animation event

#

and show the code

plucky inlet
viral marlin
#

thanks for the help

velvet quartz
#

but debug log enter display.

leaden ice
velvet quartz
velvet quartz
leaden ice
velvet quartz
#

and the listener

leaden ice
#

add more logs to check when you subscribe and when you invoke the event to make sure those happen

velvet quartz
#

i don't know why that don't listener since i call it

leaden ice
#

put a log where you subscribe

#

and where you invoke

#

not just in the listener

velvet quartz
#

i don't understand you have the invoke and subcribe on the screen

leaden ice
#

You can write a nice complicated function and it's meaningless if it never runs

velvet quartz
#

which one

leaden ice
velvet quartz
#

i said to you that the enter debug log display

#

but not the one in the player script

leaden ice
#

ok that's one

#

what about the subscription part

#

and also how do we know that's the same PlayerInventory

velvet quartz
#

this is subcription ?

leaden ice
#

yes

#

Start

velvet quartz
leaden ice
#

PlayerInventory

#

same instance

velvet quartz
#

i do the same system as heal system and the event worked well

fallow abyss
velvet quartz
#

what do you mean by instance

mellow pond
#

so i'm trying to make an item list with a scroll (button based)

#

and i have an button to go up, and a buttom to go down the list

#

and since i'm going through itens in a list and stopping once it doesn't fit the screen anymore i thinked of using an while loop

#

but even with multiple breaks on the loop it still freezes the editor

leaden ice
velvet quartz
mellow pond
#

this function, its called everytime the button is pressed (the button also increases / decreases the scroll variable)

deft timber
#

just cache it ๐Ÿ˜„

mellow pond
#

i'm still prototiping

deft timber
#

still

#

why would you not cache it even for a prototype

#

no worth the time changing it later

quaint rock
#

still less work and faster to make changes

#

can just cache it locally before the loop

mellow pond
#

ok but the problem is that even after i force it to break the loop after 3 runs (a desperated attempt) it still freezes the whole editor

#

and whats worse

#

it only happens when the function is called the second time

quaint rock
#

well if it freezes it means your break condition is never hit

mellow pond
#

cause its called once the game starts just fine, but when the button triggers it again the whole editor just freezes

deft timber
#

where are you calling this codfe

mellow pond
deft timber
#

your break is most likely never hit

#

so your editor freezes

#

because of the infinite loop

#

debug.log it

quaint rock
#

would assume max anchor height never gets below zero

rain minnow
mellow pond
#

but whats the diference between calling it inside the add listner and outside?

#

its a undefined size list and i don't want to have an for just for 90% to be ignored

#

the whole idea is to break the loop once it cannot fit a new element in screen

deft timber
#

well using an infinite while loop for that isnt a good idea

mellow pond
#

but the thing is

#

its the same function, called on awake works fine

velvet quartz
#

@leaden iceOk it is a script execution order issue

#

Idk why we need a script order for subs to event

#

I invoke a event but the other script that run after didn't started to subscribe.

#

That why i need excetuon order

quaint rock
#

no you just need to make sure the event is not invoked in Start

#

or move the subcribing to Awake

velvet quartz
#

ok

#

Subscribing shouldn't be on start ?

#

Awake is for other stuff, no ?

quaint rock
#

it depends on your usecase only different between awake and start is awake fires first for all objects then start

velvet quartz
#

ok

plucky inlet
#

Awake is to setup things like static instances and what not. Subscriptions usually can be done in OnEnable and unsubscribe inside OnDisable. at least thats my workflow

quaint rock
#

awake is just before start and on enable

#

does not matter if its doing static stuff or isntance stuff

mellow pond
#

can someone explain why putting that break down there makes the while breaks but the first if statement don't? isn't i++ supposed to increase the value of i?

plucky inlet
#

But awake is being called once, while onenable and disable are being called everytime the object is active or not

#

So if you disable an object or remove it, the registered call si still there and will throw you an error

umbral palm
#

this wont stop happening bruh

deft timber
quaint rock
#

i know how on enable and disable works, just pointing out you can use Awake for anythign you need to go before the other methods and its good for setting up internal state before soemthing else might access a object

velvet quartz
#

Ok so my game work fine i don't see any bug but i have this error

mellow pond
deft timber
#

use Debug.Logs

#

and track the iterations

mellow pond
#

its what i'm doing

buoyant crane
#

pretty sure i will never get passed 2 since you always break the loop after incrementing

#

i donโ€™t see anywhere else you change i

quaint rock
#

yeah that last loop, will always break on first iteration

mellow pond
#

but thats the point

quaint rock
#

really not sure why you even have it as a while loop

#

since you got the break if i > 3

deft timber
mellow pond
#

that if has me trying to figure out why the while won't stop

#

so i try to force it to stop after 3 times to see if it would stop

deft timber
#

use a debugger

#

debug it frame by frame

#

see if i is changing, just debug it

#

honestly your function is not well written and hard to read

quaint rock
#

it was not stopping because it was not meeting your conditions, just log or break point things 1 iteration at a time

mellow pond
#

i'm gonna rewritte this whole file

#

this is what i got for trying to change from one style to another

#

of scroll view

velvet quartz
plucky inlet
velvet quartz
#

I don't see any bug with my shoot

#

so i don't know why he tell me something is wrong

#

i don't know what line is it; to what he refer

plucky inlet
velvet quartz
#

that select my player gameobject

deft timber
#

looks like an animation event issue

velvet quartz
#

well my shoot animation is playing

#

so strange

deft timber
#

thats has nothing to do with an animation event

quaint rock
#

does the compoent that plays the animation have a script with that function name

velvet quartz
deft timber
#

?

#

i was referring to your answer

velvet quartz
velvet quartz
plucky inlet
#

The problem might be, that your weapon is still having the OnShoot event registered even if the weapon does not exist anymore

velvet quartz
#

My weapon should be here or i can't shoot xD

plucky inlet
#

But the one you unequipped is gone?

deft timber
#

you need to provide more context if you want to get help

velvet quartz
#

i don't unequippe

deft timber
#

when is that happening

velvet quartz
#

it is a assault rifle i shoot and i keep it

#

WHen i shoot i have this error

deft timber
#

if you delete the Animation Event

#

from your shoot animation

#

is the error still showing

plucky inlet
#

how many times is your OnWeaponEquipped debug log being called?

velvet quartz
#

shooting play a animation that all

plucky inlet
#

If you comment out the OnShoot += line, the error is gone, right?

velvet quartz
#

lmao no and i still can shoot

#

but the animation not playing

#

so idk don't look to be the event

plucky inlet
velvet quartz
#

yes

#

i even comment it on my gun script

#

for not invoke it

#

only solution for not have the error is to remove this

#

maybe he don't like the function name ?

#

0 reference and still even write error

#

even if i don't use it

plucky inlet
#

Well you are trying to call an int?

#

is that correct?

velvet quartz
#

int ?

plucky inlet
#

SetBool() should have a string as first param, or am I wrong? You are trying to pass an int here?

#

oh can be both, my bad

#

So are you sure your animIDShooting is correct?

velvet quartz
#

yes or the animation will not play ^^

#

even withtout call it that draw a error

#

i rename it 0 error

#

so idk the function name can't be OnShoot

#

maybe saved by unity for some reason

#

haha i know why that don't work

#

OnShoot is reserved by new input system

#

maybe is that

plucky inlet
velvet quartz
#

see the error

#

you have input system

#

blabla at the end

velvet quartz
#

on my input system settings

#

Input system send message to OnShoot function on my input script

#

So he tried to send message to all function with the same name i think

plucky inlet
mellow pond
#

got it to work perfectly now, thanks everyone

opaque moon
#

Hello does anyone have a good resource so I can learn to code with C#. I have an idea of being able to move things in unity on a shelf and count the amount of liquid in the bottle i.e. a full bottle counts as 1.0, if the bottle is 75% full then it would say .75 or if it is 34% full then it would say .34. Can anyone point me the right way to learn this skill?

velvet quartz
#

Do you use event for call animation or you just call the function?

velvet quartz
#

just call a function look more easy that do another event again.

#

i discover event and overun it i think ^^

plucky inlet
#

Yeah it sounds a bit weirdly setup or tested around ๐Ÿ˜„ hard to tell tbh

velvet quartz
#

wdym

tall lagoon
#

Hey Guys so sorry if I'm interrupting but I'm trying to make a dungeon generator for my game and I'm trying to spawn rooms next to each other which work but sometimes rooms spawn over each other and idk how to stop that from happening

Help would be greatly appreciated ๐Ÿ™‚
First image is room.
Here's script and example

See how in the images the brown rom is covered in blue now? here's script https://gdl.space/izatiridap.cpp

wild vigil
#

I am struggling to load a scriptableobject into a script at runtime

cosmic rain
tall lagoon
#

i dont understand why i get it

cosmic rain
#

Share the error details

tall lagoon
#

k

tall lagoon
cosmic rain
#

What's line 43?

#

It's probably list being emptied. The index would be 0 at that point, but the last doesn't have any elements.

#

You need to check whether the list is empty and stop your invocation in this case.

tall lagoon
#

i fixed

#

we had to - 1

#

on the random.range

cosmic rain
#

No, you don't.

tall lagoon
#

BUT IK WY!

cosmic rain
#

You don't need to -1

tall lagoon
#

See the white room

#

that overlapped the brown room at the bottom

#

But the reason it did that

#

was because of the brown room to the right.allrooms have 4 sawnpoints

#

so is there a wayto checkif something is at those spawnpoints before actually spawning the object?

cosmic rain
#

Code it.๐Ÿคทโ€โ™‚๏ธ

solemn raven
#

hi ,
quick question
if I want to get random number where the results should be a either ( 2,3,4 ) how to do that ?

cosmic rain
#

Create a class representing the spawn points structure where you can mark/assign to spawn points.@tall lagoon

azure heath
#

@rigid sleet Sorry to bother you again! I'm trying to contact the Tormented Souls devs, as I've started a Discord exclusively for developers who've produced and released fixed multicam games (like Tormented Souls). Given the niche nature of the games and the unique challenges in constructing them, I thought it might be nice to have a place for Fixed Multicam devs to talk to their peers. =) If this sounds interesting to you (or if you can reach the TS devs and they're interested) let me know and I'll send you a link.

wispy wolf
#

Unity's UI system always gives me trouble. I have an Image I'm placing on a canvas. I set the RectTransform's position to <56,0,0>, which I verified by debug.log. When I press play the image is created and its position is set to <515.5178,-33.98539,54.34146>, which is definitely not accurate.

The code is this:


HPNode n = Instantiate(nodePrefab, transform);
n.transform.localScale = Vector3.one;
n.transform.position = offsetPosition;
Debug.Log(offsetPosition);
Debug.Log(n.transform.position);
nodes[i] = n;

My console prints out the correct position twice for each node. But in the inspector its all messy. What am I missing here?

hasty canopy
#

To set position

wispy wolf
#

Cool beans, thanks @hasty canopy

#

I hate ui work

hasty canopy
soft mica
#

Is there a way to preview two different avatar's animations at the same time in Unity in edit mode?

I have two avatars I need to position, and their animations are synced. My problem is that when placing them in my levels, I can't see how they are aligned relative to one another.

For example, if two avatars need to sit side by side on a bench, I can't easily tell how to rotate them to get them to sit properly on the bench depending on what angle it's at, because I can only preview one at a time, so I have to keep swapping back and forth between them to preview the animation for each which requires a bunch of clicks for every adjustment in order to finally get them in a position where they are both well aligned with the bench.

#

I've tried opening two animator tabs and locking them, but that doesn't seem to work. I can't enable preview on the second.

eternal dove
#

can anyone help?

#

this is my code

#

and this is the error

lament ocean
#

I'm trying to use the unity job system and right now the biggest time user in my code is GC.Alloc because I'm passing so much data around.

I was wondering if theres a way I can reuse "old data" instead of having to make a new native array from a basic array every time I've tried using the "persistant" allocator but it seems like it still wants me to eventually dispose of it even if I dont update it.

Any help would be greatly appreciated.

wispy wolf
# eternal dove

Your Wait5 routine isn't right. And you can't use it like that.

#

Coroutines are kind of confusing at first.

#

Read that and if it doesn't make sense ping me. I'm going to bed but I'll help you through it tomorrow.

leaden ice
tawny elkBOT
#
๐Ÿ’ก IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

โ€ข Visual Studio: https://on.unity.com/vshub (Installed via Unity Hub)
โ€ข Visual Studio: https://on.unity.com/vsmanually (Installed manually)

โ€ข VS Code* https://on.unity.com/vscode
โ€ข JetBrains Rider: https://on.unity.com/3XgkeqG
โ€ข Other/None: https://on.unity.com/3CYp2c9

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

ionic socket
#

Using Unity Netcode. I want the player to be able to drag a GameObject, but only if they have a particular resource (enough money to buy the sword, say). If I want to perform that check on the server rather than trusting the client, how can I do that within the context of the IBeginDrag handler?

leaden ice
ionic socket
leaden ice
ionic socket
#

Because I don't want the drag to even begin if they're unable.

leaden ice
#

What does "drag" actually mean in this context

#

Is this a thing that's visible to other players

ionic socket
#

literally, a drag and drop. IBeginDrag etc. It's just a UI thing, the dragging of the card isn't visible to other clients

leaden ice
#

So then why does the server need to confirm or worry about anything

#

The client knows how many resources it has

ionic socket
#

because how else can the client know if the player has enough resources except by confirming with the server?

leaden ice
#

Presumably those variables are synced regularly, no?

#

Are you not constantly displaying them somehow

ionic socket
#

they're not synced at all, everything is on the server.

leaden ice
#

The client has no idea how many resources it has?

ionic socket
#

it's a turn-based card game, fyi. yeah why would the client know anything?

leaden ice
#

Why... wouldn't the client know??

#

It's like knowing how much mana you have in hearthstone isn't it?

#

Just because the server owns the data doesn't mean the client has no knowledge of it

ionic socket
#

yeah I mean i guess I do set the value on a text field periodically with the resource count but I feel like that's a bad way to store client knowledge

leaden ice
#

You're right it shouldn't be in a text field as a source of truth

#

There should be a synced variable for it

ionic socket
#

Hmmm

potent sleet
#

unity NetworkVariable

leaden ice
#

Sorry IDK the terminology in this particular framework so I'll assume Null is correct

ionic socket
#

yeah I'm thinking on that. the system used to be entirely class based and I am learning how to make it work by passing value only.

#

yeah Netcode.

potent sleet
#

it syncs with a property for you , kind of nice . reminds me of blazor

lone hollow
#

Is there a recommended app to use to animate a background on loop or character movements?

leaden ice
#

NetworkVariable also gives you proper callback support for keeping your UI text in sync

ionic socket
#

Right now I have kind of one big struct-of-structs that contains the gamestate, and I only let the server touch that at all. can I selectively put NetworkVars in specific spots for ones I want to check?

potent sleet
#

idk what character is

#

maybe 3D? blender?

leaden ice
#

A bug struct of structs doesn't seem ideal for storing game state in general

lone hollow
#

2d

leaden ice
#

In fact "one big struct" already kinda violates the guidelines for what a struct should be

ionic socket
#

well i'm definitely still learning how to structure a game for multiplayer so I'm open to other techniques.

leaden ice
#

Game state is the kind of thing that would strongly favor a reference type, considering you'll want to reference it all over the place

ionic socket
#

well yeah but you can't pass reference types* through RPCs.

leaden ice
#

Passing the whole game state through rpcs is pretty inefficient anyway. If one tiny variable changes you resend the entire game state?

ionic socket
#

yeah actually I did move away from that but it's it's still a struct; it could become a class quite easily.

#

right now my RPC's only manipulate the game state; but there aren't any synced variables.

#

Lame. I can make an Enum a NetworkVariable<MyEnumType> but I can't have a NetworkList<MyEnumType>

orchid bane
#

Is there any asset which would give you a knife capable of slicing meshes into pieces?

potent sleet
#

not ingame tho

orchid bane
#

why not ingame

#

oh

#

yeah

potent sleet
#

its more for modeling

#

but you can cut stuff up for destroying if thats what u wanted to do

orchid bane
#

oh I wanted something for slicing limbs off

potent sleet
#

oh yeah idk of an asset, thats usually I use blender then with skinned meshes

orchid bane
#

How would you do it with skinned meshes?

#

You mean for slicing them off in predetermined places?

potent sleet
#

yeah I slice all the limbs in blender, get them into unity and spawn whichever one I need

orchid bane
#

I thought of slicing them off in arbitrary places

#

Idk, looks very difficult

#

Looks like will need to create entrails as well

#

Can start with cheese or something

icy fable
#

i seem to have stumbled into an incredibly baffling bug. one of my components seems to have gotten stuck with a particle emitter effect on it, despite no longer having any particle effect components on it.

orchid bane
icy fable
#

these blasted balls of white light refuse to go away and i have no idea why @_@

#

...nevermind i think i found where the particle system was hiding

#

no idea how a rogue particle system ended up as the child of the highlight object in the project tree but im glad i found it

cyan vector
orchid bane
#

Stop him

#

Why is he moving while others aren't

cyan vector
#

These are your troops, it's kind of a mix between 3rd Person Action and Strategy.

#

He wants to get to his position in the formation, but the big guy (player) is blocking his path.

orchid bane
#

Bruh

#

I'm sure there is a lot of info about this in the net

cyan vector
#

Not really

west sparrow
#

Both navmesh and A* pathing should work for this, provided there is a valid path

orchid bane
#

Perhaps the player is not a navmeshagent so it isn't accounted for when calculating path?

west sparrow
#

Good point

cyan vector
#

Not with Speed: 8 and Acceleration: 200.

I need them to be fast and responsive, it feels really bad when you give them an order and they slowly start walking towards their destination.

cyan vector
west lotus
#

And use the partial path. Im guessing you are just setting a destination directly

cyan vector
#

Avoidance is only handled by the NavMeshAgent itself, in its movement.

west lotus
#

Right