#archived-code-general

1 messages · Page 290 of 1

leaden ice
#

playerrstats should probably have a way of keeping track of what is currently equipped

#

or perhaps you need a ShipStats script

#

A ScriptableObject is probably a good way to design ship stats in the editor too

fading hull
#

Hello!, with unity input system when i press "Z" in my dialogue action map, i have it configured so that it advances dialogue 1 time, evetually it finishes, and when it finishes, it opens the interaction again to the npc im talking to, so pressing Z end dialogue and inmediatly opens it up again, since opening the interaction is on the Z key too. How can i make it so that 1 key press equals 1 action? right now its triggering the action from 2 different action maps since calling it from the dialogue action map calls an event to change the action map to my walking action map (Sorry if its not explained very good, i will clarify if needed)

#

i have tried a lot of things but nothing seem to work

leaden ice
#

Another thing I never tried is perhaps unchecking the "initial state check" on the action in the menu

fading hull
leaden ice
fading hull
#

mmmm ok i will take a look at it, but no clue where the problem might be in

leaden ice
#

start with the input handling code for that stuff, as mentioned

fading hull
#

thanks for the help!

leaden ice
fading hull
grand fractal
#

Anyone know why i cant create a keystore or load one? When i click add it says make sure you put in the right password even tho i have the correct one. And when i load it just dosent do anything.

exotic aspen
#

Howdy folks. I've settled on a lookup table of shaders to encompass low end mobile, high end mobile and desktop platforms. Individually they all work well, but now I need to dynamically adjust their application across the entire game from the settings window. In the simplest case, if the user clicks "Lighting Off" I want to swap out the Sprite-Default-Lit shader for Sprite-Unlit. How should I approach this? I'd need to update all the prefabs and active objects and their materials. It is possible, just complex trying to find everything in the scene to update. I thought perhaps I'm missing some obviously easier way to accomplish this.

leaden ice
#

the example in that doc is much more complex than what you need

exotic aspen
#

Does that any overhead to the rendering?

leaden ice
#

no idea

grand fractal
# rigid island keystore ?

An Android keystore lets you store cryptographic key entries for security. Android Keystore can be used to sign your apk, sign data, store certificates, and a variety of other needs. To release your app to a marketplace, you will need to setup the keystore.

deep path
#

sorry to mention but do you got your API key ?

grand fractal
rigid island
grand fractal
latent latch
exotic aspen
#

You mean have two gameobjects for each object?

latent latch
#

yeah and keep the other inactive

exotic aspen
#

Well, I'd still need to loop through all of them and do the same thing. The difference is someObject.visible = false vs someObject.GetComponent<Renderer>().material = newMaterial

#

Keeping track of all the stuff in the scene is just my concern.

#

Having a single Lit material destroys Android performance so I'm trying to be thorough and careful.

latent latch
#

" The difference is someObject.visible = false vs someObject.GetComponent<Renderer>().material = newMaterial"
Quite a difference between caching and instantiating though

exotic aspen
#

I would think the performance hit of having all those extra game objects would be much worse than a one time pause while the setting takes effect.

#

Its a thought. Just need to think on it a bit.

latent latch
#

if they arent active then all you give up is some objects loaded into mem

exotic aspen
#

Well we are talking up to 1000 of them. So its a bit...

trail wraith
#
    public void SetButtons(int buttonCount, string[] labels, UnityEvent[] methods)
    {
        for (int i=0; i<4; i++)
        {
            buttons[i].onClick.RemoveAllListeners();

            if (i < buttonCount)
            {
                buttons[i].GetComponentInChildren<Text>().text = labels[i];

                buttons[i].onClick.AddListener(methods[i]);

                buttons[i].gameObject.SetActive(true);
            }
            else
            {
                buttons[i].gameObject.SetActive(false);
            }
        }
        buttonContainer.gameObject.SetActive(true);
    }```
can i somehow pass a UnityEvent into AddListener()?
i'm getting the error "'UnityEngine.Events.UnityEvent' to 'UnityEngine.Events.UnityAction'"
latent latch
#

which is the reason why game dev use object pools over cleaning up objects

leaden ice
#

however

trail wraith
#

oh awesome, thanks!

leaden ice
#

you'll need this though @trail wraith

int copy = i;
buttons[i].onClick.AddListener(() => methods[copy].Invoke());```
exotic aspen
#

I don't think I understand? For example if I have 1000 NPCs in the scene. I wouldn't want or need to pool them. If I had projectiles and things then yeah sure?

leaden ice
#

Otherwise you're going to run into the variable capture issue

trail wraith
#

i'll make sure to add it then

latent latch
exotic aspen
latent latch
#

pooling in this case would be reusing the npcs when you zone too far away, and apply them to others in your areas

exotic aspen
#

:nod: My game has no concept of zones or anything like that, but sure. I can see that being something to consider for other game architectures.

latent latch
#

im just poking at your comment of instantiating materials and cleaning them up every time you flip a switch

#

and it's not so much just instantiating them, it's the gc being a pain in the butt

exotic aspen
#

Oh, well I'm not instantiating new materials. Sorry if that was confusing. I basically have a List of 1000 things, and can certainly loop through and update the material of each. But there's probably a couple lists like that. And then I'll want anything new added to the scene (singletons really, nothing pooling would help with) to also have the new material applied.

#

I can handle the new added stuff in their spawn scripts easily enough. Its just a lot of code in a lot of places for something I was thinking might have a centralized "replace material" call.

#

The shader materials are all loaded at runtime anyways. So I doubt there's any performance loss from GC taking place.

latent latch
#

ah, ok I misunderstood then. Looping through them all and changing materials/shared materials probably fine then

exotic aspen
#

I actually kind of expected there to be a utility. Swapping materials for different targets seems like a no-brainer with Unity multiplatform deployment.

#

:nod:

latent latch
#

shared material updates probably as best as you'd get, but otherwise I'd just replace them all

leaden ice
#

yeah technically you can change the shader of the material on the fly

#

so if they're all using the same shared material, you can do that

#

(you'd also have to change all the variables of course)

#

to copy everything from a reference material

exotic aspen
#

Ahh interesting.

leaden ice
#

though it does say "Material's shader is not changed."

exotic aspen
#

I appreciate the ideas.

leaden ice
#

so you might have to change the shader first

#

then call CopyProperties

exotic aspen
#

Ok I'll do some testing with it.

#

I guess next on the list is how to optimize this weird MouseEvents calls I'm seeing. Its taking up 2ms of frame time as profiled on device. Deep Profiling is certainly making it a bit worse than it would normally be.... but I'm surprised to see so many raycasts off the main camera when its sitting there doing nothing.

#

PreUpdate.SendMouseEvents is the lead call. There was a lot of complaining about it back in 2011. And folks saying adding a GUILayer to the camera fixed it. Then that became deprecated and nobody really knew what to do. Not sure if this is actually needed or not.

leaden ice
exotic aspen
#

I make use of the Unity GUI which would need those events for buttons, right?

leaden ice
#

no

#

this is a separate system

exotic aspen
#

Oh. Hmm.

leaden ice
#

this is Monobehaviour.OnMouseDown etc

leaden ice
#

a totally separate thing

exotic aspen
#

Ok thats good to know. I couldn't think of a good reason why the UI would be doing raycasts every frame for its handling.

#

A grep of my code for OnMouse returns nothing.

leaden ice
# exotic aspen

if you expand this and go all the way down what is under there?

#

Although it seems to be ScreenPointToRay itself

#

which is crazy

#

that shouldn't be that expensive

exotic aspen
#

Little more detail there.

#

Seems like it varies and goes up and down at times.

#

Like pausing/unpausing the game makes it switch between modes. Certainly nothing I'm doing intentionally.

#

So that's a long one.

leaden ice
exotic aspen
arctic jackal
#

Can someone help me privately? Because something is not working for me

exotic aspen
#

So see it went from having 0.23ms of mouse events to 3ms

#

The orange band being the mouse stuff.

heady iris
arctic jackal
exotic aspen
#

Tapping in an unused spot on the screen can toggle it between 0.23ms mouseevents and 2-3ms mouseevent call durations. And it persists forever. Really kind of feels like a bug or something odd.

#

GameTime is 0 so no physics or AI or anything should be processing.

#

But the thread just kind of fizzled out. I couldn't make sense of the PlayerLoop approach to disabling unused functions they described.

unique delta
#

I don t know why but my slider value is different in build than in the editor.

rigid island
marsh abyss
#

So i have made grabbing script, works well but im trying to add more features rn but im trying to make it detach when at a distance, to stop some bugs but there is an issue. It detaches as soon as starts. This is what im doing

checking
if (Vector3.Distance(transform.position, NearbyGrabbableObjects[0].transform.position) > UnstickRange)
{
IsStuck = true;
}

to check if you can climb or not
h > 0) && !IsStuck)

detaching
Climbing = false;
IsStuck = false;

I dont know why this is happening, it looks correct to me

leaden ice
#

which seems backwards?

#

anyway these tiny little code snippets are difficult to grok without context

marsh abyss
#

Sorry, ill get more in a second

leaden ice
#

!code

tawny elkBOT
leaden ice
#

Share the code more nicely^

marsh abyss
#

Ah ok sorry

unique delta
hexed pecan
rigid island
unique delta
#

yes

hexed pecan
unique delta
rigid island
#

share whole script

#

also don't use that site it sucks

#

!code

tawny elkBOT
hexed pecan
#

Yeah show the rest of the code, especially where time comes from is important

unique delta
#

is pretty big

naive swallow
unique delta
#

the time is at line 83

hexed pecan
#

So you are incrementing time only once, in Start 🤔

#

And using that frame's deltatime as the MoveTowards speed in Update

#

It's very wonky

rigid island
#

should be in update

unique delta
#

ok

unique delta
hexed pecan
#

I think you can get rid of time and just increment it in update like thiscs slider.value = Mathf.MoveTowards(startdash, targetdash, Time.deltaTime * lerpSpeed);

#

What you currently do doesn't make much s ense

unique delta
#

i can

#

thanks

opaque forge
#

good evening, how can I create something like this dialog box where the user selects parameters?

#

(inside unity)

vivid wind
#

I am looking to produce a cut-away effect for walls in a 2d top-down game that would obscure the view. I'd like to create a 2d maze game. If the player walks behind a wall/piller. I'd like to hide the upper portion of the wall/pillar down to near the floor so the player can see what is there. I'm finding lots of tutorials on how to do the sorting layers, but not one on how to produce that cutaway effect I see in other games that have that type of top down oblique perspective. Any suggestions on where to get started would be greatly appreciated.

vivid wind
#

That pretty much covers the problem, but I'm wondering if there are any ideas on applying it to a 2d tilemap. I suppose I'll just have to create test scenario and start tooling around.

latent latch
#

Ah, well if you don't really compare zdepth then you need to compare it to something like the character itself

vivid wind
#

probably need to do some sort of filter by sorting layer and tag, and apply some sort of method of changing the tilemap to another tile or something maybe?

latent latch
#

you can probably compare by the y sorting value too probably

#

but like you probably want some smooth transitioning with the dissolve, so I'd just do dynamic comparison between characters and location probably since its 2D

#

unless you want something like the silhouette up there

#

like two ideas is like xcom where you enter a building -> remove the roof and walls completely. Or, if you just want to dissolve partial for where your character is, then that would be more rendering tricks (both render objects and the shader would work, but if you have layers to spare then I'd go with the render object approach since you don't have to apply it to every shader)

#

this is where you should start using Visual Studio's debugger tool and run through the code step by step to make sure the logic is being executed correctly

keen hollow
#

Is there anyone who codes windows forms with C# language?

naive swallow
keen hollow
naive swallow
#

Oh, it's !csharp now

tawny elkBOT
keen hollow
#

thx

buoyant scroll
#

How do Unity coding projects work?

naive swallow
#

Code goes in, game comes out

buoyant scroll
rigid island
#

there is an API

buoyant scroll
#

I'm talking about the errors where it says UnityEngine.UI doesn't exist even when the package and everything is installed

rigid island
#

then why not ask that instead

naive swallow
naive swallow
rigid island
buoyant scroll
#

Oh, one second, I'll brb

#

Okay, I will try that and then come back to see if it worked

rigid island
#

search the Project folder

spring creek
spring creek
lean sail
buoyant scroll
#

now

#

how do i do this stuff

#

Okay look here's my "basic" problem.

rigid island
buoyant scroll
#

always unity only

#

i think

rigid island
#

do you have the UI package inside package manager?

lean sail
buoyant scroll
#

one moment please

#

nvm wait hold up

#

I have DLLs like Assembly-CSharp, Rewired, all that stuff, maybe that could help reimport and fix and redefine UnityEngine.UI?

shell scarab
#

Hey guys I'm having an issue where my script is loosing a reference to an object when the scene is loaded with the scene manager, but when hitting play on that scene the reference is kept. What could be causing this?

rigid island
naive swallow
buoyant scroll
#

the problem is that the namespace does not exist. CS0234.

shell scarab
# naive swallow Is this script on a DontDestroyOnLoad object, and is it referencing something th...

The object it is referencing is a script on a prefab in the scene, the script that is referencing that object is a scene object. It has two references both to the same prefab, one is kept and one is lost. The one that is kept is a GameObject reference, the one that is lost is a script reference. Both are private fields tagged with [SerializeField], and neither are set in their own script, so nothing else can be setting it.

rigid island
naive swallow
buoyant scroll
#

lemme check

quartz folio
#

People really like to describe references in the most confusing way possible

shell scarab
#

Also I just discovered that it keeps its reference when it references the game object, but it loses the reference when it references the script. Could it be an execution order thing? Even though the one losing the reference does not have awake or start methods...

naive swallow
buoyant scroll
naive swallow
lean sail
buoyant scroll
#

here lemme explain

rigid island
buoyant scroll
#

i have a game that i literally made,

#

hairdos exams

#

(search on itch io)

lean sail
#

No one wants to read 20 3 word messages

buoyant scroll
#

okay gee
i did not have time to buy a usb drive to back up my unity project data, hence why i had to download a compiled version and decompile it

naive swallow
#

Oh, it's a decompilation problem

#

Yeah I'm not touching that with a 10-foot pole

buoyant scroll
#

it is my game on my account

#

im logged in onto the account

lean sail
#

This still all sounds like bullshit to me, but you should use version control. That's the answer there you go

rigid island
buoyant scroll
shell scarab
# naive swallow Context would help. Using actual names for things for one
public class ClickableUnit : MonoBehaviour, IClickable
    {
        [SerializeField] private UnitSelectMenu _unitMenuUI;
        [SerializeField] private GameObject _turnMenuUI;
        private bool _isOpen = false;
        public void OnClick()
        {
            if (_unitMenuUI == null || _turnMenuUI == null)
                return;

            if (_unitMenuUI.UnitMenu.activeSelf)
            {
                CloseMenu();
            }
            else
            {
                OpenMenu();
            }
        }
        public void OpenMenu()
        {
            _unitMenuUI.UnitMenu.SetActive(true);
            _turnMenuUI.SetActive(false);
            _isOpen = true;
        }

        public void CloseMenu()
        {
            _unitMenuUI.UnitMenu.SetActive(false);
            _turnMenuUI.SetActive(true);
            _isOpen = false;
        }
    }
```This is the one losing the reference. `_unitMenuUI` loses the reference while `_turnMenuUI` keeps it. Here are the screenshots:
buoyant scroll
#

my conversion is "see: shows footage"

shell scarab
#

however when that _unitMenuUI is a GameObject field, it does not lose the reference

naive swallow
shell scarab
#

when clicked:

naive swallow
shell scarab
#

the object from the hierarchy. As you can see it is a child object of the prefab so i wouldn't be able to get a reference from the prefab file.

naive swallow
shell scarab
#

the battle menu canvas does not reference turn menu

#

the script in the inspector is the "clickable unit" script which is on the selected objects in the inspector

#

like the first picture

naive swallow
shell scarab
#

correct

#

so if I just hit "Play" it keeps its reference, but if I use SceneManager.LoadScene(1) it loses the reference. This scene is the second scene in the build index, i only have 3 scenes.

quartz folio
#

I don't really understand why the original screenshot had a solid-blue prefab icon for TurnMenu, when surely it should be the same as what's in the scene view

shell scarab
naive swallow
shell scarab
#

they all reference the same object, the reference is applied in the scene

quartz folio
naive swallow
naive swallow
quartz folio
#

The only reason you'd lose a reference is:

  1. You are setting it to null
  2. The instance has been destroyed (often because the scene it was in has been unloaded)
#

I would not make assumptions about bugs and would triple check both your code, for assignments, and the scene's references

shell scarab
#

why does it not lose reference if I change it to a GameObject instead of the script?

shell scarab
#

i mean that's what I'm doing, changing it to a GameObject, but... i feel like that should not be what fixes it.

quartz folio
#

We can't really help any further, the issue seems specific to the details of your setup, or is a weird bug that nobody has seen before

#

If you record a video of the whole thing, including the references, how they relate to each other, the scenes they're in, and what changes when you reload the scene, then maybe there'd be something we spot

shell scarab
#

hmm ok

naive swallow
#

My guess is that since you have to re-assign it in the inspector after changing the type, you're probably properly referencing the one inside of this prefab (which will not be lost) instead of a specific one in the scene (which is)

foggy pasture
#

heya, I'm pretty rusty on my trig (ignore the ugliness, I've been prototyping this pretty hard for a bit)
I know enough to realize this can be turned into a usage of sin + cos or atan, but I don't know enough to know how

#

would anyone mind pointing me in the right direction

buoyant scroll
#
{
    "name": "FigurativelyGames.Main",
    "references": [
        "FigurativelyGames.Main.Tools",
        "FigurativelyGames.Main.Planes",
        "Unity.RenderPipelines.HighDefinition.Runtime"
    ],
    "includePlatforms": [],
    "excludePlatforms": [],
    "allowUnsafeCode": true,
    "overrideReferences": false,
    "precompiledReferences": [],
    "autoReferenced": true,
    "defineConstraints": [],
    "versionDefines": [
        {
            "name": "com.unity.render-pipelines.high-definition",
            "expression": "7.1.0",
            "define": "HDRP_7_1_0_OR_NEWER"
        },
        {
            "name": "com.unity.modules.particlesystem",
            "expression": "1.0.0",
            "define": "USING_PARTICLE_SYSTEM"
        }
    ],
    "noEngineReferences": false
}

will someone tell me where to put my packages? i have some packages i need to put in here

cosmic rain
foggy pasture
#

I'm attempting to find the correct rotation for this edge sprite that you see clipped all over the place

the arguments I have available are the vertices of the triangle on top and the vertices of the triangle of the wall below it

#

        Vector3 shared1 = Vector3.zero;
        Vector3 shared2 = Vector3.zero;

        if (parent1 == target1 || parent1 == target2 || parent1 == target3) shared1 = parent1;
        else if (parent2 == target1 || parent2 == target2 || parent2 == target3) shared1 = parent2;
        else if (parent3 == target1 || parent3 == target2 || parent3 == target3) shared1 = parent3;

        if (parent1 != shared1 && (parent1 == target1 || parent1 == target2 || parent1 == target3)) shared2 = parent1;
        else if (parent2 != shared1 && (parent2 == target1 || parent2 == target2 || parent2 == target3)) shared2 = parent2;
        else if (parent3 != shared1 && (parent3 == target1 || parent3 == target2 || parent3 == target3)) shared2 = parent3;

        return Mathf.Atan2(shared2.z - shared1.z, shared2.x - shared1.x);
#

this is it taking the two shared vectors (the edge) between the two faces and getting the angle of that edge, which I thought might work but clearly hasn't

#

it works exclusively along the bottom there where the angle is 0

cosmic rain
#

Can you visualize what these points are on the screenshot? And rotation(?) of what you're trying to find? Because it's not really clear from the explanation.

foggy pasture
#

sure

#

shared 1 is the red dot here, shared 2 is the blue dot

#

the returned rotation is the angle of the edge highlighted in green, which is used to rotate this south-facing sprite

#

the ugly comparators are just a sloppy way I'm using to find the shared vertices atm

cosmic rain
#

So you just need a rotation orthogonal to the edge?

#

Perpendicular

foggy pasture
#

i believe so yeah

cosmic rain
#

Does it need to be an angle? How are you using it after that?

foggy pasture
#

like so

#

it's just rotating worldspace uvs in a shadergraph

cosmic rain
#

Ok, so it's uvs for each tile..?

foggy pasture
#

oh my god

cosmic rain
#

I think there're more problems than that...

foggy pasture
#

that's it right

#

it's rotating worldspace uvs

#

so obviously it's going to be way off

#

god damn it

#

my entire problem with this so far has been trying to texture a procedurally generated marching cubes mesh

#

which exclusively uses worldspace uvs

cosmic rain
#

You could use a cross product of the edge to get a perpendicular vector, then get it's angle.

foggy pasture
#

that sounds correct, I'll try that out

#

do you know how to rotate a texture using worldspace UVs also by chance

cosmic rain
#

I don't know enough about your shader to say any more than that.

hard viper
#

is there any way to make an inheritted static function?

latent latch
#

praise be bgolus

lean sail
hard viper
#

base class has a static method, which calls on some of the abstract functions in the abstract base class

#

and I want each base class to just have their own version of the static method that operates on their overrides.

lean sail
#

do you have any actual errors with implementing this? to my knowledge this shouldnt be a problem at all. you just write the method

hard viper
#

wait you're right. I can just do that lol

#

ty

#

nvm, I can't

#

because my static method depends on an abstract method, which is itself not static

#

so if I could make that static, I would be set.

lean sail
hard viper
#

it's associated with the derived class

#

anyway, in this case, I just bit the bullet, and made a nonsensical instance, which won't cost me anything. it's just dumb.

lean sail
hard viper
#
public class NonFungibleTileDataCollection : ObjSaveDataCollection<INonFungibleTileHandler> {
    protected override IEnumerable<INonFungibleTileHandler> EnumerateDataSavers() {
        NonFungibleTileManager customDrawManager = NonFungibleTileManager.GetInstance();
        foreach (INonFungibleTileHandler logic in customDrawManager.NonFungibleTileHandlers) {
            yield return logic;
        }
    }
}
public abstract class ObjSaveDataCollection<TDataSaver> where TDataSaver : IDataSaver {
    /// <summary>Enumerate out all the IDataSavers that this data type is connected to.</summary>
    protected abstract IEnumerable<TDataSaver> EnumerateDataSavers();
    /// <summary>Load all as default</summary>
    public void LoadAllAsDefault() {
        foreach (TDataSaver saver in EnumerateDataSavers()) {
            saver.LoadDefault();
        }
    }
#

let me reduce the total info

#

ok, better. the members I have there for the ObjSaveDataCollection should both be static, in the sense that they are not really associated with an instance

#

but EnumerateDataSavers can't be both abstract and static, for LoadAllAsDefault (depends on it) can't be static either

lean sail
#

you dont use the abstract keyword when its static, but i dont really see what you mean with LoadAllAsDefault cant be static

hard viper
#

because Enumerate… can’t be both static and abstract

#

that method must be filled out by the derived class

#

making it not abstract is not an option

lean sail
# hard viper because Enumerate… can’t be both static and abstract

realistically i would be questioning why u want it static in the first place, but what i was saying was you could just make them all static (without the abstract keyword). The one in the base class could just yield return null or whatever dummy data. I guess the issue with static is you might have to redeclare LoadAllAsDefault in each child class

#

i was interpreting what you were saying as it isnt possible, which it is. Its just not ideal here

merry stream
#

could someone explain to me the differencce between defaultcapacity and maxsize in an object pool?

merry stream
#

how high should maxSize be generally? for something like a damage number system

latent latch
#

I use the vfx graph for numbers but usually like 30k

merry stream
#

what about the default capacity? like 1000?

latent latch
#

but that's usually harder to extend, but unity pool is a queue right? so probably fine to extend

#

i dont know too much about the unity pooling, but ideally you make a smart pool that extends gradually when it hits break points you set

#

at 70% extend another 100 over time

lean sail
tender finch
#

Is the Unity website down?

merry stream
#

so vfx graph is more performant?

dusky lake
#

so it differs from use-case to use-case, there is no "best" values

latent latch
#

gpu instancing is usually good for stuff like text or minor renders to be batch in single calls. (srp does provide easy access to gpu instancing which you can just flip on in the material, so something to profile. VFX graph isn't required, but it's great at set and forget stuff)

hard viper
#

if enumerate is not abstract, then how will the static LoadAllAsDefault call the right function for the derived class

tender finch
#

I am trying to publish a game for a class and for some reason, unity is being weird with me when I try to edit/publish it. It would not fully load

dusky lake
#

if that doesnt help you would need to look into the console

#

oh and also disable ad blockers 😄

hard viper
#

i fixed it by just making a nonsensical instance this time, but it is annoying that I can’t make abstract static methods

lean sail
dusky lake
#

worked?

tender finch
#

It worked : )

hasty haven
#

Is there a better way to grab a reference to the current gameObject's PhysicsScene when it moves between subscenes?
Preferably outside of Update()

private string lastScene;
private PhysicsScene physicsScene;

void Update() {
    if(gameObject.scene.name != lastScene) {
        lastScene = gameObject.scene.name;
        physicsScene = gameObject.scene.GetPhysicsScene();
    }
}
heady iris
#

You mean to a different scene? "Subscenes" are an ECS thing.

#

I don't think there's a message sent when an object moves between scenes, unfortunately

hasty haven
#

Yeah i didnt see anything at the object level, just when the main scene changes on scenemanager

rocky osprey
# hard viper i fixed it by just making a nonsensical instance this time, but it is annoying t...

If I'm understanding correctly, something like this (https://stackoverflow.com/a/66927384/882973) might help if you use it with your NonFungibleTileManager to get the instance. You would need to pass in an additional type parameter to EnumerateDataSavers to reference the tile manager type. This would make the entire EnumerateDataSavers function general purpose and thus could be static without needing to be abstract.

hasty haven
#

This seems to do its job, its not hurting performance and works fine

vale bridge
#

I'm trying to implement gadgets that damage/heal players on interact and was wondering if the best way to do it was to inherit from an interactables class I wrote and overriding the behaviors in functions? Does this seem like a scalable approach

latent latch
#

sure, but you're not stuck strictly to a single interface. Could consider dividing it down into behaviours like Use(EntityTarget)

#

but otherwise, yeah you can do a lot with one of these behavioral classes/interfaces if you embrace those polymorphic method calls

vale bridge
#

By dividing down do you mean creating more template interfaces?

#

for example all objects dealing damage inherit from x and such

latent latch
#

Yeah, I primarily use interact for interacting in the environment if I use it, but for stuff like items I have Use(), Equip(), Trigger(), Throw()

vale bridge
#

Thanks!

latent latch
#

Usually with a parameter specifically for targeting

vale bridge
latent latch
#

Well, if you make it parameterless then you could assume the object that has the behaviour will use it for themself, but if you supply a specific targeting parameter you can specify how and where to use it, like say you have an effect class that adds poison to the target, so you'd have something like Apply(), but you don't want to apply it to yourself so you'd add something like Apply(target)... but you can also still apply it to yourself if you decide to target yourself ;)

vale bridge
#

Gotcha

latent latch
#

the target itself could be an interface too like say an IEntity which contains an implementation of Stats class where you can deduct health from

#

or an abstract class. Either or honestly

normal niche
#

Somebody mind helping me out with a collider issue i am having a hard time on how to fix?

#

I get stuck like this when i jump between objects, I move my character with force (guessing that is why it happens as it has a physics material with no friction)

craggy veldt
modest kayak
#

This imported asset has a copy of every mesh and material for each animation

#

is this normal, and will it affect build times / run time / storage??

latent latch
#

where the coding question at

modest kayak
#

... that is a good question oops

#

i thought this was for general questions

thin aurora
#

It sounds like overcomplication if you want to do this. For what it's worth, newer C# versions support static interface methods which do something that's close to what you want, but instead in a more logical way

crisp flower
#

Hey I added this script to my project: https://diegogiacomelli.com.br/unitytips-scene-selection-toolbar/

To add a scene select menu to my editor. However I can't see where it saves the data is uses, and I want to push it into git. It uses setpref, I assume this thing: https://docs.unity3d.com/ScriptReference/PlayerPrefs.html

How can I share this over git and will it update when we change build numbers etc?

Using Unity Toolbar Extender by Marijn Zwemmer’s and Ondrej Petrzilka’s you can easily add buttons side by side of play/pause/step buttons on the Unity editor toolbar.

knotty sun
lean sail
crisp flower
#

Ok thanks, I was looking in playerprefs not editorprefs, I don't see any pref beginning: "SceneSelectionToolbar.Scenes" tho thinksmart

edit to above, yeah I figure, I wouldn't be super opposed to sharing a .reg that trusting people can add on the side

knotty sun
lean sail
knotty sun
#

so sharing wont work if the project name is not exactly the same

crisp flower
#

yeah and we increment build numbers a lot as well which would break this, first I'll try changing that to a static hardcoded string (you can prob tell I'm less a dev, more a tech artist)

knotty sun
jagged snow
#

Very strange bug I'm experiencing at the moment that I've never ran into before.
Each frame I check for inputs from a static class and it works fine until I reload the scene.

{
    public static PlayerInputs GetInputs()
    {
        var inputs = new PlayerInputs();
        inputs.MoveInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        Debug.Log(new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")));```
The debug log is being called however, after reloading the scene it's no longer registering the input axis and alwasy returning 0,0

The reloading scene coroutine:
```    private IEnumerator HandleReset(float duration)
    {
        yield return new WaitForSecondsRealtime(duration);
        string currentSceneName = SceneManager.GetActiveScene().name;
        Debug.Log("RELOAD");
        SceneManager.LoadScene(currentSceneName);

    }```
cosmic rain
jagged snow
jagged snow
#

yep

knotty sun
cosmic rain
#

Are you setting time scale to 0 perhaps?

jagged snow
jagged snow
# knotty sun can you share the code for PlayerInputs
    {
        var inputs = new PlayerInputs();
        inputs.MoveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        Debug.Log(new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")));
       // Debug.Log(Input.GetKey(KeyCode.Space));
        inputs.LookInput = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
        inputs.PrimaryDown = Input.GetKey(KeyCode.Mouse0);
        inputs.SecondaryDown = Input.GetKey(KeyCode.Mouse1);
        inputs.InteractDown = Input.GetKeyUp(KeyCode.F);
        inputs.ReloadDown = Input.GetKeyUp(KeyCode.R);
        inputs.AbilityDown1 = Input.GetKeyUp(KeyCode.Q);
        inputs.AbilityDown2 = Input.GetKeyUp(KeyCode.E);
        inputs.MeleeDown = Input.GetKeyUp(KeyCode.LeftShift);
        inputs.ScrollInput = Input.GetAxis("Mouse ScrollWheel") < 0f || Input.GetAxis("Mouse ScrollWheel") > 0f ? 1 : 0;
        inputs.JumpDown = Input.GetKeyDown(KeyCode.Space);
        return inputs;
    }```
cosmic rain
jagged snow
# cosmic rain It is. Had no idea it affects get axis though
    {
        if (state == GameState.Default)
        {
            Time.timeScale = 1;
            _gameState = GameState.Default;
            _playerMaster.SetState(PlayerMaster.State.Default);
        }
        else
        {
            Time.timeScale = 0;
            _gameState = GameState.Default;
            _playerMaster.SetState(PlayerMaster.State.Disabled);
        }

    }```
knotty sun
#

I meant the class

jagged snow
# knotty sun I meant the class
{
    public Vector2 MoveInput;
    public Vector2 LookInput;
    public Quaternion CameraRot;
    public bool PrimaryDown;
    public bool SecondaryDown;
    public bool ReloadDown;
    public bool MeleeDown;
    public bool AbilityDown1;
    public bool AbilityDown2;
    public bool InteractDown;
    public int ScrollInput;
    public bool JumpDown;
}```
#

Ok so I found the culprit here. I'm currently in a different scene and entergamestate default isnt being called which is why the time scale isn't being set back to 1 thank you

knotty sun
#

that is very odd. That timeScale would affect GetAxis but not GetAxisRaw. I would definitely report that as a bug

cosmic rain
knotty sun
#

timeScale should not affect either, mouse movement should be independant of timeScale

cosmic rain
#

This is not mouse movement. I wonder if it affects the axis set up as mouse though.

jagged snow
#

ok I reported the bug

knotty sun
cosmic rain
knotty sun
#

iffy, is it a bug or is it a feature?

#

definitely an edge case

#

@jagged snow Well spotted. If I was you I would flag a change to the GetAxis doc page and ask them to add this information

crisp flower
#

on the above conversion to assets folder json from editorprefs you'll be pleased to know chatgpt did it for me

#

thanks for pointing me in the right direction

knotty sun
crisp flower
#

that ws tongue in cheek. I'm sure we are all displeased with "AI" for many reasons, however you gave me enough to leverage it to solve my issue, so thanks 🙏

knotty sun
crisp flower
#

I guess I'm not many people, however knowing that and knowing how to specify code and debug it and see where it's falling down it's been a hugely helpful tool for me and my team, anyway getting out of scope of my "thank you"

fresh ingot
#

why is my navmesh agent so clumsy lmfao

nocturne wyvern
#

How to fix this rectangle? I think that unity cannot convert m_text: "\u2615\uFE0F \U0001F375" to right emoji

fresh ingot
#

hes like walking into walls and unable to enter doors sometimes LOL

thin aurora
fresh ingot
#

oh i see ty

rustic arch
#

Hi everyone! I'm experiencing some issues with the optimization of my game. I went into settings and set the LOD Bias to 0.1 and saw that even without almost anything on my screen I have 3.0M tris. Is this how it should be or something that I'm not aware of is happening?

thick terrace
#

how many triangles are you expecting to see from the assets you're showing in the viewport there?

rustic arch
#

i want to lower it down but idk where to start from

thick terrace
#

i mean like, we don't know your assets and the scene is super dark, give us an idea of what's on screen there

#

we don't know that tree in the background isn't 1 million tris haha

thick terrace
#

ok, but how many triangles are in those meshes?

rustic arch
thick terrace
#

click on the mesh asset and look at the inspector

#

it's in the preview pane

rustic arch
#

oh dayum

#

a lot

#

50k each

#

even one box, why does one box have 50k

thick terrace
#

time to delete some verts 😄

rustic arch
#

is it possible to do this from unity?

#

or do i need other program

thick terrace
#

i think there's some third party tools to auto generate lower detail LODs in unity, otherwise you can make them in blender or something

rustic arch
fading hull
#

i have my inventory system with inventory items as scriptable objects, should i change them to be classes with [System.Serializable] for a easy way to save/load them or its fine to have them as scriptable objects? will saving/loading be way more complicated with scriptable objects or its no big deal?

#

just thinking long term for a project with a lot of different type of items

heady iris
#

Use scriptable objects to store item definitions

#

Use plain-old classes to store item instances (or your entire inventory)

#

so you'll have a scriptable object that defines what iron ore is

#

you will use this to store its name, its icon, its 3D model, etc.

#

then you'll have an inventory object that tells you how many of each kind of item you have

#

If items need additional data (maybe you can upgrade your sword into a +3 flaming sword), you should store that in a normal class as well

#
public class WeaponItem {
  public WeaponDefinition definition;
  public List<Enchantment> enchantments;
}
fading hull
#

ok so this WeaponItem would have [System.Serializable] and my inventory will consist of a list of items that have [System.Serializable] right? instead of having a list of scriptableobjects in my inventory directly, instead i have a class that is serializable and inside i have the scriptable object

#

no?

#

so in your case WeaponDefinition is a scriptable object and WeaponItem is a class with [System.Serializable]

rustic arch
# thick terrace time to delete some verts 😄

so I found something. I think I've done something wrong when I was creating the house. One box has 30 tris and one 50k. I clicked the one with 50k and it has a combined mesh and after clicking the combined mesh it looks like this

#

I've seen this is on plenty of my items

#

I surely did something wrong when I was creating the map

#

Have you seen anything like this before?

thick terrace
#

i think that's just static batching doing its job

rustic arch
#

Nvm this is static batching inside player options

#

Yeah.. It's no problem

heady iris
#

The only catch here is that you need a way to actually serialize that weapon definition.

#

You aren't going to serialize the contents of the definition. You'll need to save an identifier you can use to look the definition back up later.

#

I've done this copying the GUID of each asset into a field on itself. So, the item definition looks a bit like this

#
public class ItemDefinition : ScriptableObject {
  public Guid guid;
  public string label;
  public float cost;
  public int florps;
}
#

I use Json.NET. I wrote a custom converter so that, when I try to serialize an ItemDefinition, it just writes the guid.

heady iris
#

I used this to figure everything out.

heady iris
buoyant scroll
#

Would anyone mind?

heady iris
buoyant scroll
#

It's not clearing.

heady iris
#

Every instance of that item in an inventory shares the same ItemDefinition.

heady iris
fading hull
#

but in your custom way to save guids

heady iris
#

The name of the item might work, but I avoided that because I might want to rename my items

#

I use this pattern for my settings system. So my saved settings look like this:

#
{
    "choiceSettingValues": [
        {
            "setting": "828733BD80E3745DCBA6E5F4E67AD4CE",
            "value": "F1D8CC763672F48839D944402699EE23"
        },
        {
            "setting": "F1E50A54133E14D3C85226948900A3AF",
            "value": "D6FB5C2D145C1457F8F1CBB1D9F0791A"
        },
...
#

choice settings are for things like picking an anti-aliasing mode

#

both the setting itself and each choice are assets

fading hull
heady iris
#

from an older game where I initially figured out saving and loading an inventory:

#
{
    "lastUplink": "32E2281B4657447BCB710B50D6470FB9",
    "uplinks": [
        "32E2281B4657447BCB710B50D6470FB9"
    ],
    "items": [
        {
            "$type": "InventoryRangedWeapon, Assembly-CSharp",
            "spec": "20AFB2D518C6B4CB0A26D744C1EEF498"
        },
        {
            "$type": "InventoryMeleeWeapon, Assembly-CSharp",
            "spec": "BAAE6BDFA0F554EDB8BD467BAFF0A73C"
        }
    ],
    "wallet": {
        "currencies": [
            {
                "currency": "8582C22BF7E3E4299948738362554384",
                "amount": 100
            }
        ]
    },
    "playerProgression": {
        "levelUps": []
    }
}
fading hull
#

well thanks a lot i will take a look at all of this and change my system

heady iris
#

"uplinks" are save points

buoyant scroll
heady iris
#

try scrolling down in the lower area

buoyant scroll
#

wdym

#

here

#

OH COME ON

fading hull
heady iris
#

note that discussion of reverse-engineering isn't permitted in this server, which it looks like you're trying to do here

heady iris
# fading hull thanks a lot!

Using GUIDs means that you can rename and modify your assets without breaking existing save data. Just don't delete and recreate them 😉

buoyant scroll
heady iris
#

I do a little bit of both

#

for settings, I need a hierarchy anyway to organize them in the settings menu

#

so I have a hierarchy of SettingCategory assets that reference all of the individual settings

fading hull
#

with a list of scriptable object i imagine the script for saving would be very complex

heady iris
#

i.e. you don't have "stacks" of items

#

You still have to figure out how to save and load which items you have either way

heady iris
fading hull
#

ok i see, thanks a lot ❤️

glad plinth
#

Hey,
I have a JS App that has data I require in the game
How would be the best way to transfer that data to the game ?

fervent furnace
#

http post i guess

heady iris
#

UnityWebRequest can be used to make HTTP requests.

fervent furnace
#

i think they want to receive the data in game
it requires a server listen to some port running on other thread

#

making a post request from browser and send that to your game

knotty sun
#

what? That makes no sense

fervent furnace
#

i have no idea why there is a js front end (probably) and unity running at same time

knotty sun
#

no such thing as a JS backend, I'm guessing it's Node.js and a UnityWebRequest GET should do the job

past barn
#

👀

south hawk
#

Not sure where to ask this but I have a problem:
I have a Player Prefab containing a few different things:

  1. a Character from Mixamo
  2. a Player POV Gameobject containing an AudioListener and a Camera
  3. a GroundCheck object.

my current problem is the mouse look script that is attached to the Prefab itself, doesn't move the actual head / arms of the player like it should.
the camera itself moves but once I look down my hands are still looking forward

leaden ice
glad plinth
leaden ice
south hawk
glad plinth
#

i think im doing both correctlyu

south hawk
#

This is the whole rig

south hawk
leaden ice
#

This is part of a skinned mesh? I guess you'd use IK then

#

animation layers etc.

south hawk
#

so I have to put my question there? isn't it just a code problem of telling the head to rotate?

leaden ice
#

No because you're dealing with an animator and a skinned mesh

#

and trying to override part of the animation

#

that's aim constraints and inverse kinematics

south hawk
#

Ah okay so I will ask my question there, hopefully someone can help me

gilded vapor
#

i think need fix problem script

leaden ice
#

without seeing the code, that's all we can say

buoyant scroll
#
if (Vector3.Magnitude(GetVector33(i)) <= collider.radius)
            {
                Vector3 vector33 = GetVector33(i);

                Vector3 vector32 = entities[i].transform.position - transform.position;
                (int, int, int) p = (0, 0, 0);
                Vector3 vector31 = Quaternion.Euler(spin)
                    * p;
                Vector3 vector2 = vector31;
                (int, int, int) p1 = (0, 0, 0);
                modifiers[i].movementAddend = (vector2 - p1 / Time.deltaTime);
            }
            else
            {
                modifiers[i].movementAddend = Vector3.zero;
            }

I'm trying to figure out how to multiply Vector3s by p and divide by p.
How can I do this?

leaden ice
#

what is the goal of this code?

gilded vapor
leaden ice
#

Juice bottles? What?

gilded vapor
#

this Juice bottles

leaden ice
#

Ok what relevance does that have to your compile error?

#

You can only use variables that exist in C#

#

You can't use things that don't exist.

#

You don't have a variable named slb, so you can't use it.

buoyant scroll
spring creek
gilded vapor
spring creek
buoyant scroll
leaden ice
leaden ice
leaden ice
gilded vapor
#

ah okay

buoyant scroll
#

i can try to explain in my best manners but it may be hard to do so

glad plinth
#

Hey, Really stupid person question but

            string receivedData = "";
            using (System.IO.Stream body = context.Request.InputStream) // auto-disposes
            {
                using (System.IO.StreamReader reader = new System.IO.StreamReader(body, context.Request.ContentEncoding))
                {
                    receivedData = reader.ReadToEnd();
                }
            }

            Debug.Log("Received POST data: " + receivedData);

            responseContent = !string.IsNullOrEmpty(receivedData) ? receivedData : "No data received";
            PastData = responseContent;```

How can i make "PastData" a actual Json / JObject so i can traverse it properly 🙂 

Sorry
buoyant scroll
#

i'm using int int int because ctrl+ . is my only choice out to do so

leaden ice
leaden ice
#

You should not limit your code to whatever this "ctrl + ." does

fervent furnace
#

quick fix in vscode, and they should learn to use vec3

buoyant scroll
heady iris
#

I'm guessing you used the "Introduce Local" quick action.

#

This fixed the compile error by creating a variable that's compatible with (0, 0, 0), but this is..not correct

leaden ice
# buoyant scroll go inside visual studio

If you want to multiply a vector by a number you can just do it. There's no need for (int, int int).
For example:

Vector3 test = new Vector3(1, 1, 1);
Vector3 result = test * 3;
print(result); // prints (3, 3, 3)```
heady iris
#

You asked the compiler to do something to make your code compile. That something is wrong.

#

(1, 2, 3) is a tuple of three integers

#

It has nothing do whatsoever with a Vector3

glad plinth
# leaden ice parse it with a json parser

i meant more like how?
Like newtonsoft? or is there a better one as i kind of hate the PastData[Match][Example]

its just awkward compard to PastData.Match.Example

leaden ice
buoyant scroll
leaden ice
#

JsonConvert can convert it to a regular C# class with the appropriate structure

#

there's also the JObject API which you specifically asked about

buoyant scroll
#

I have another problem though.

leaden ice
#

There's also JsonUtility from Unity @glad plinth

glad plinth
#

ohh i never knew that
i thought Newton soft = JObject way

thin aurora
buoyant scroll
#

It says something about a call being ambegious or how do you spell this

leaden ice
buoyant scroll
#
private Vector3 GetVector33(int i) => entities[i].transform.position.ZeroOutY();
leaden ice
thin aurora
glad plinth
#

Dynamics definetly sound best as then it is still using . to change levels unsure if the others do

buoyant scroll
#

Severity Code Description Project File Line Suppression State
Error CS0121 The call is ambiguous between the following methods or properties: 'Vector3Extensions.ZeroOutY(UnityEngine.Vector3)' and 'Vector3Extensions.ZeroOutY(UnityEngine.Vector3)'

leaden ice
#

delete one of the copies

#

You might have duplicated the whole class

buoyant scroll
#

Now it says it doesn't exist.

thin aurora
#

If you don't know where you did it might be worth checking for stray files in the explorer

#

Perhaps there is a duplicate file with the same code, causing this.

spring creek
rustic arch
#

anyone knows what could cause this WaitOnSwapChain? I also have it even with Vsync enable or disabled

buoyant scroll
#

Could someone help? Severity Code Description Project File Line Suppression State
Error CS0121 The call is ambiguous between the following methods or properties: 'Vector3Extensions.ZeroOutY(UnityEngine.Vector3)' and 'Vector3Extensions.ZeroOutY(UnityEngine.Vector3)'

cosmic rain
cosmic rain
buoyant scroll
#

I tried cleaning the binaries.

#

About to try cleaning the solution.

cosmic rain
#

I don't think cleaning stuff is gonna help. The issue is with your code.

thick terrace
buoyant scroll
thick terrace
#

given that the unity project doesn't really use those solution files at all, i have no idea how you managed that 😅

cosmic rain
#

What do you mean by "collapsed" anyway?

buoyant scroll
cosmic rain
#

In the unity console?

buoyant scroll
spring creek
#

That is not collapsing, that is working

cosmic rain
buoyant scroll
#

Yup

cosmic rain
#

Start from fixing the errors that appear in unity console.

buoyant scroll
#

2 syntax errors

buoyant scroll
#

Those errors are not related to the errors I need to mainly fix

cosmic rain
#

..?

#

You would need to fix syntax errors anyways, if you want your project to run.

spring creek
buoyant scroll
#

I'll fix them after.

spring creek
buoyant scroll
#

Here are the errors though if you want to see them:

buoyant scroll
#
{
                if (text.ToLower().StartsWith("file://") || text.ToLower().StartsWith("http://") || text.ToLower().StartsWith("https://"))
                {
                    MidiSynth[] synths = UnityEngine.Object.FindObjectsOfType<MidiSynth>();
                    Routine.RunCoroutine(ImSoundFont.LoadLiveSF(text, ImSoundFont.GetDicAudioClip(),DicAudioWave dicAudioWave,
             DicAudioClip dicAudioClip, defaultBank, drumBank, synths, restartPlayer), Segment.RealtimeUpdate);
                    return true;
                }
                UnityEngine.Debug.LogWarning("MPTK_LoadLiveSF: path to SoundFont must start with file:// or http:// or https:// - found: '" + text + "'");
            }
cosmic rain
#

These are not errors...

buoyant scroll
#

Well in general Idk how to fix them.

cosmic rain
#

I only see a code snippet

spring creek
buoyant scroll
#

In the snippet, are the errors

spring creek
#

Without seeing the errors we can not help of course

buoyant scroll
#

Oh, right

#

sorry about that

cosmic rain
buoyant scroll
cosmic rain
#

Now share the line that throws the error.

buoyant scroll
#
Routine.RunCoroutine(ImSoundFont.LoadLiveSF(text, ImSoundFont.GetDicAudioClip(),DicAudioWave dicAudioWave,```
cosmic rain
#

You'll need to start sharing code properly...
!code

tawny elkBOT
buoyant scroll
#
DicAudioClip dicAudioClip, defaultBank, drumBank, synths, restartPlayer), Segment.RealtimeUpdate);```
cosmic rain
#

Just share the whole script...

cosmic rain
#

But I guess the issue is DicAudioClip dicAudioClip

buoyant scroll
spring creek
cosmic rain
#

What exactly are you trying to do there?

buoyant scroll
#

aw

cosmic rain
#

Whatever you're trying to do, I suggest you stop right there, and go learn the C# basics.
!learn

tawny elkBOT
#

:teacher: Unity Learn ↗

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

buoyant scroll
cosmic rain
#

Wdym?

buoyant scroll
#

WPF

cosmic rain
#

It's totally the same C#.

spring creek
cosmic rain
#

The C# is the same. Syntax errors like the one you get would be fixed exactly the same way in WPF.

buoyant scroll
#

Now I'm stuck with the syntax errors

#

What do I do there?

cosmic rain
spring creek
buoyant scroll
#

nevermind

cosmic rain
#

You can't have a declaration right in the method params like that.

buoyant scroll
#

Thanks for your guys' help

#

You helped a lot, and I'll definetly check out the Unity Learn thing! 😄

cosmic rain
#

Might want to go through the C# manual too, since the issue is less related to unity.

rustic arch
cosmic rain
rustic arch
cosmic rain
rustic arch
#

I'm just moving around

cosmic rain
#

What does your scene look like? Are you using GPU heavy stuff like a lot of post processing effects? What's your screen resolution? Are you using compute shaders? Are you using custom shaders other than that? Is your gou doing any other work than rendering the game?

rustic arch
#

Game looks like this. around 3.5M tris

#

pp only bloom vignette and chromatic aberration

#

1080p screen res

cosmic rain
#

Check the GPU profiler to make sure these spike coincide with high GPU time.

nocturne wyvern
#

Hi. How to check internet connection correctly?

cosmic rain
rustic arch
#

I've been running around for the past couple of minutes and no freezes anymore

#

I also have a script that does this: QualitySettings.maxQueuedFrames = 2 as I've read in a unity forum it helps

#

but as far as I know this is also the default option?

nocturne wyvern
#
 protected override async UniTask AsyncRunInternal(CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                IsConnected = Application.internetReachability != NetworkReachability.NotReachable;
                
                if (!IsConnected)
                {
                    IsConnected = false;
                    _provider.Popup.Show();
                    await _provider.Popup.TryAgainBtn.AsyncWaitForClick(CancellationToken);
                    _provider.Popup.Hide();
                }

                await UniTask.Delay(TimeSpan.FromSeconds(0.2f), cancellationToken: token);
            }
        }

I check this way, but as I understand it, this is an unreliable method. As the Unity writes "Note: Do not use this property to determine the actual connectivity. For example, the device can be connected to a hot spot, but not have the actual route to the network."

heady iris
#

Yeah, this method is for testing what kind of connection you appear to have

#

The only real way to decide if you're online is to check if you can reach the service you need.

heady iris
nocturne wyvern
#

which services are best to check in order to cover most countries of the world? Maybe someone has a small example on this topic? Thank you

heady iris
#

Why do you need internet access?

nocturne wyvern
heady iris
#

Try to talk to your server, then!

#

note that Application.internetReachability can reliably tell you that you don't have internet access. So you can check that first before trying anything else

delicate flax
heady iris
#

It just can't reliably tell you that you can actually talk to your server

hard viper
#

!code

tawny elkBOT
hard viper
nocturne wyvern
rustic arch
heady iris
#

That will be more useful (and make slightly less spam aimed at Google)

nocturne wyvern
hard viper
#

there is a lot of code. what you need to do is:

  1. Add these methods to a class, and call PhysicsMethodBenchmarking(); in Awake
  2. A lot of the stuff in the actual physics benchmark method is custom. Edit as needed. The main methods you need to run MeasureBenchmark( on are: 1) TestMovement, because this is time cost that is not associated with benchmark that you should ignore. 2) TestColDist(, which tests Distance, and 3) TestOverlapBasic(, because that tests OverlapCollider
heady iris
#

I don't know how Ping works and I'm unfamiliar with UniTask, so I can't say much

hard viper
#

you do not need all the other methods. and you should be able to infer more or less what you need, for all of the classes unique to my code

latent latch
#

stopwatch pretty accurate?

hard viper
#

yeah. it goes off system time

#

also, MeasureBenchmark on TestMovement gives you a baseline

#

I added in comments the result of the test

#

but that is for like, all of my stuff

#

it should give you an idea of what it should look like

latent latch
#

aight, probably worth making a test script for this stuff as it's gotten to that point now

#

tyty

hard viper
#

glhf

delicate flax
hard viper
#

my style here is kind of messy (hence the 200 LoC function), since it is like a one-off experiment

#

so sorry about that lol

willow hollow
#

Hi

#

having some issues in Python. Can anyone assist?

#

trying to get screenheight & width to be 4/2

#

not sure where I am going wrong in my code.

somber nacelle
crisp bronze
#

Hi, I'm trying to create a level generator script that will generate prefabs based on their given entry points and to try and prevent overlapping. Here are the two scripts so far:
https://paste.myst.rs/oyfceedq

However, I'm running into an issue with freezing during my while loop and can't figure out why

willow hollow
thick terrace
#

also, you're picking random segments until you find one which is valid, which i guess could take a long time if you have lots of segments and only a few of them are valid... why not make a list of valid ones first and then pick one of those at random?

swift falcon
#

In unity I am trying to make ice, the friction thing works but the object on it stops pretty quickly, I want it to slowly keep sliding a bit (even at low speeds). How do I have control over that?

heady iris
#

it gets increasingly unlikely that you'll hit a valid space as time goes on

somber nacelle
swift falcon
somber nacelle
#

and does the rigidbody have linear drag applied to it?

swift falcon
#

Not sure, do you mind me sending you the current movement script?

somber nacelle
#

share it here !code
and also show your rigidbody's inspector

tawny elkBOT
swift falcon
#
    private void Update()
    {
        // Movement
        float xDirection = Input.GetAxis("Horizontal");
        float zDirection = Input.GetAxis("Vertical");
        Vector3 moveDirection = transform.forward * zDirection * speed;
        rigid.AddForce(moveDirection);

        // Rotation
        float rotationInput = Input.GetAxis("Horizontal");
        float rotationAmount = rotationInput * rotationSpeed * Time.deltaTime;
        transform.Rotate(0f, rotationAmount, 0f);
    }
swift falcon
somber nacelle
#

don't add force in Update. you should be doing that in FixedUpdate. also why are you getting the horizontal axis twice instead of using the value you got the first time that you didn't even bother doing anything with?

swift falcon
#

I wasn't yet working on the rotation part, I'll try to add it in fixedupdate, maybe that works.

dusk apex
#

Unless it's impulse but yeah.

swift falcon
somber nacelle
#

in what way does it not work

swift falcon
#

It still rotates but it doesn't go forward

leaden ice
spring creek
somber nacelle
#

what is the value of speed and you still haven't bothered showing the rigidbody's inspector like i'd asked

swift falcon
leaden ice
#

5 newtons isn't much force

#

that's about 1 pound of force

leaden ice
#

1 lb of force is really not going to move a 1kg object much when you consider friction is a factor too

swift falcon
#

Now it can move again by the way

somber nacelle
#

you increase drag and/or friction to allow the object to come to a stop

leaden ice
#

Or use a material with more friction

#

or apply a braking force yourself

swift falcon
#

The friction is already at 0

#

Even with 0 drag and 0 friction it still stops

somber nacelle
#

then your object will continue sliding forever until it hits something

#

unless you are doing something elsewhere that stops it

leaden ice
swift falcon
leaden ice
#

this material would need to be on both objects

swift falcon
#

oh, I'll try it like that thanks

#

Perfect, now it doesn't stop which is what I wanted! Thank you both

#

I'll add drag to make it stop

worldly ruin
#

Hi i get an error when i try to compile my game in Unity, and idk what could be wrong because i never changed the date on my pc

Product: ARM Compiler 5.04 for Nintendo
Component: ARM Compiler 5.04 update 5 Extended Maintenance (build 231)
Tool: armcc [4ce830]armcc : error C9555:  License checkout for feature bsp_compiler5 with version 5.0201509 has been denied by Flex back-end. Error code: -88
System clock has been set back.
Feature:       bsp_compiler5
License path:  C:\Program Files (x86)\ARMCC_Nintendo_5\sw\info\nintendo-anyhost.lic;c:\program files\arm\licenses\license.dat;
FlexNet Licensing error:-88,309.  System Error: 2 ""
For further information, refer to the FlexNet Licensing documentation,
available at "www.flexerasoftware.com".```
rigid island
somber nacelle
#

that looks like something you should be asking about in the nintendo developer forums

worldly ruin
worldly ruin
#

that's why i'm asking here but if you can't help i understand

rigid island
#

shit outta luck

somber nacelle
#

they sure don't. but if you don't even have access to those forums then you shouldn't be using that sdk in the first place because that's piracy

gloomy crag
#

Hey everyone. Dealing with a lots of world space canvases and i needed to disable backface culling.
Found a shader in the forums to do that.
It works great, but those elements can only be seen on the left eye in VR.

I'm a complete beginner when it comes to shaders though.
Could someone help me adjust this code so it works in VR on both eyes? I dont want to change Stereo Rendering Mode for Oculus since it works with default UI shaders too.

If possible (but not as urgent), i'd also like to be able to Mask the Ui Images that use Material of this shader.

I appreciate any help.

The code for the shader i used is too long to post here: https://pastebin.com/YLiAieh8
Source: https://forum.unity.com/threads/worldspace-canvas-backface-culling.310857/

worldly ruin
glad plinth
#

Hey,
cant tell if this is "code" i mean it IS but still

How could i make this UI using HTML instead?

rigid island
#

if you want html-like you need new UIToolkit

golden vessel
#

Anyone can help me out with my problem please? I'm adding a value to an object in a canvas to set its height but it doesn't work at a different resolution.

glad plinth
rigid island
somber nacelle
glad plinth
rigid island
somber nacelle
#

i don't think uitk supports world space UI out of the box yet btw

rigid island
#

ahh thats fkt

glad plinth
somber nacelle
#

if you are really deadset on html/css you can probably find a webview asset

rigid island
#

^this . Or also learn Unity UI which is not horrible to get some decent results

glad plinth
#

im not deadset no
i was just wondering as that ofc would have been the go too

glad plinth
chilly surge
#

For anything that is not extremely complex, UGUI is still a good enough solution.

rigid island
#

yeah agreed

#

9-slice sprites will be your best friend

#

holy shit... big bucks in unity web browser huh..

chilly surge
glad plinth
#

ahhhh yea just a chill 360$

#

😭

chilly surge
#

Free and IIRC actively maintained.

sage latch
#

honestly just use uGUI

chilly surge
#

But honestly just use UGUI.

sage latch
#

lol

rigid island
#

NOTE: This plugin overlays native WebView/WKWebView views over unity's rendering view and doesn't support those views in 3D.

#

So i guess no worldspace ?

glad plinth
glad plinth
rigid island
glad plinth
#

ahhh

rigid island
#

I wouldnt be surpised if it used UGUI internally lol

sage latch
#

The main issues with uGUI (at least for me) is the layout system and global styling

#

and performance ig

rigid island
#

takes a decent amount of patience to get decent results yea

chilly surge
rigid island
#

oh meant the assetstore one

chilly surge
#

I've briefly looked into lots of UI solutions because the project in working on is very UI heavy (it's practically an app more than a game) and there's really not anything that's remotely close to modern frontend. WebView + web tech for frontend was one option but performance really tanks on mobile. I ended up building my own frontend framework on top of UGUI.

prime cosmos
#

Hey has anyone run into this problem before? I am making an isometric tilemap with these blocks and as soon as i start using a new block it starts overlapping instead of falling in line like the grass blocks did. Any ideas why, i feel like im missing something obvious

ashen yoke
#

make sure they are sorted by pivot point and pivot is correctly placed

#

those are sprites right?

prime cosmos
#

yes

simple egret
#

Looks like the stone "block" is up in the air compared to the others, the top-right edge does not align with the grass "blocks" ones

prime cosmos
#

Ok i figured something out

#

this is my tile pallette

#

Everything to the left of the grass block goes above it but everything to the right goes below it

#

Im new to tilemapping so im not entirely sure how i would fix that

simple egret
#

(Zoomed in view) Notice how the topmost corner doesn't align with the others

rigid island
#

I would check the pivot sorting

simple egret
prime cosmos
#

👍 thanks for the help

tired prairie
#

hey, what did we use for sending big codes in here ?

somber nacelle
#

!code

tawny elkBOT
tired prairie
#

https://gdl.space/zegidedoje.cs
hey i have this code for saving player data locally, it works normally on both android and the normal windows builds. but it doesnt work in the universal windows platform build that i made and published on microsoft store.
neither the load or the save functions work. does anyone know why ?

ashen yoke
#

any errors?

simple egret
#

If I remember correctly, UWP apps do not use the stuff in System.IO to access the file system, they have their own methods.
Also BinaryFormatter is unsafe and should not be used.

ashen yoke
#

i would imagine UWP would not allow binaryformatter to work

tired prairie
#

or do i have to just stick to only saving on my server ?

simple egret
#

Regular apps not made with Unity use stuff like StorageFile, FileIO but this is only available in the Windows.Storage namespace, which Unity probably doesn't have by default

#

Each app has its own isolated storage space

swift falcon
#

hi

#

my unity inspector window doesnt have instance ids

#

i want to die please help

rigid island
somber nacelle
#

this is a code channel. but you need to put the inspector into debug mode to view those

swift falcon
#

i wanst sure where to ask about this sorry

#

how to put inspector to debug mode?

somber nacelle
#

expand the 3 dot menu in the upper right of the inspector window

swift falcon
#

i got it

#

thanks for super qik response

somber nacelle
#

is there a particular reason you need the instance id though? 🤔

swift falcon
#

my scripts dont work

#

my button doesnt work

somber nacelle
#

that shouldn't be related to the instance id unless you are doing some weird stuff

swift falcon
#

level manager persist script

somber nacelle
#

huh?

#

you should take a look at #854851968446365696 for what you should include when asking for help
but again, instance ids should be entirely irrelevant

mellow root
#

Hi, I have a question about transform.LookAt. When I apply it to a plane it rotates it weirdly.
The first picture is how it should be (it is rotated like that in the editor), the second is how it is in play mode (it rotates it to the 0).
I'm trying to achieve the rotating sprites, think the original Doom objects

merry stream
#

anyone know why my events aren't working with enemies spawned by an object pool? it seems like the enemy subscribes but does not call the function properly

#

where as my character who derives from the same class which setups up the event does work properly

somber nacelle
somber nacelle
mellow root
leaden ice
#

Quad is set up for this, Plane is not

merry stream
somber nacelle
#

no, your code is the issue

sharp marsh
#

Hello, for a university workshop I need to solve the following problem: Given a PLY file, using Matlab, obtain its vertices and faces in separate text files. Then, create a script in Unity that reads these text files and creates a mesh. I am aware that there are applications like Blender that can take a PLY file and convert it into an OBJ file which Unity can read. However, my professor wants the process as I mentioned. I have already written the script, but I do not know what the error is that prevents the mesh from being displayed correctly. The PLY file is a dental model. I am attaching a photo of the file, as well as the script code and what it looks like in Unity. I appreciate any help in advance.

https://paste.ofcode.org/NrBe5E7BkYtKfWZZfGs4Vs

leaden ice
mellow root
merry stream
leaden ice
#

use quad instead

merry stream
#

since my code does infact work with the player

#

ill post it one sec

somber nacelle
#

object pools don't do anything at all except pool objects. they have literally nothing to do with events or unity messages. your code is the issue.

merry stream
#

how does it work in one case and not the other?

mellow root
merry stream
#

enemy is not calling the StatChange function correctly

leaden ice
merry stream
#

i sent the wrong second link, fixed it

leaden ice
sharp marsh
leaden ice
#

I see

somber nacelle
mossy snow
# sharp marsh

mesh needs a 32 bit index buffer, you've apparently got 163k verts. There may be other problems but start with that one

merry stream
somber nacelle
#

i doubt that. unless you are subscribing to the event after the new instance is created on the player

merry stream
#

heres the player

somber nacelle
#

it seems like you are just manually calling the StatChange method on the player

merry stream
#

I just tested it

somber nacelle
#

after you have called ResetToBase it cannot react to the events unless you are still referencing the old instance of the Stats object somewhere

#

the new one does not have anything subscribed to it

merry stream
#

ah i see

#

wait nope, still works for the player

somber nacelle
#

prove it

merry stream
#

reacting to health going down

somber nacelle
#

is this after ResetToBase has been called during this play session?

merry stream
#

yes

#

it is called immediately

somber nacelle
#

and what exactly am i seeing in that screenshot? because that doesn't show where any of this is happening in code

merry stream
merry stream
somber nacelle
#

this still does not show that it is reacting to the change after ResetToBase has been called

merry stream
#

resest to base is called when the player is spawned

somber nacelle
#

do you mean in Awake? because Awake is before OnEnable

#

I am referring to the event being cleared after OnEnable has been called. because that is what is happening with your enemy

merry stream
#

look at time

somber nacelle
#

do you just not read anything being said to you?

merry stream
#

i was responding to your first comment but okay

somber nacelle
#

and this whole fucking time i've been talking about what happens when you create a new Stats object after you had already subscribed to the event. not before. that was the entire god damn point\

merry stream
#

dont lose your temper man

somber nacelle
#

then learn to read

glad plinth
#
Operator icon not found for: JACKAL at path: Assets/Siege/Operators/Icons/JACKAL
UnityEngine.Debug:LogWarning (object)
Watch:LoadOperatorIcon (string) (at Assets/Watch.cs:219)
Watch:AssignOperatorImages () (at Assets/Watch.cs:189)
Watch:Update () (at Assets/Watch.cs:93)
private Sprite LoadOperatorIcon(string operatorName)
{
    string path = $"Assets/Siege/Operators/Icons/{operatorName}";
    Sprite opIcon = Resources.Load<Sprite>(path);
    if (opIcon == null)
    {
        Debug.LogWarning($"Operator icon not found for: {operatorName} at path: {path}");
    }
    return opIcon;
}

How can i load Images from that path as the Icon Exists there

somber nacelle
glad plinth
#

OHHH

#

its resources folder

#

That makes senes

#

sense

latent latch
#

Anyone some good ideas for implementing "furthest along the track" logic in a tower defense game? Since units can be displaced via knockback and slowing effects, I can't simply order them as the units are spawned onto the track. At the moment I'm just grabbing targets via overlap sphere which are in the tower radius and choosing the closest/furthest to the tower, so having more options would be nice.

#

I mean, I do have an idea what I need and it's taking the path they walk on and expanding it out into a linear distance and im not sure what tools I would go about that with

#

Ah, maybe sampling the navmesh a bit more

#

Yeah, I don't know. That seems quite expensive...

somber nacelle
#

could you just check the navmeshagent's remainingDistance?

latent latch
#

oh, huh that's distance of the path and not the point?

#

"NavMeshAgent.GetPathRemainingDistance(). Be aware though this can be performance expensive depending the situation, so have that in mind when using it."

#

I assume it does the same corner/face calculations

somber nacelle
latent latch
#

Reading some stackoverflow post, but it's a little outdated

#

oh, it's their own custom method, ok yeah they do similar to another post

#

Let me try it out though and see how it goes, otherwise maybe I can segment the levels out instead and compare by that.

#

it's more that I have like 100+ enemies bunched up at times with quite a few towers pelting them

lean sail
latent latch
#

pretty sure even the earlier versions had it. Freaking flash games mastered it

#

probably not expensive as I'm probably thinking, but I do also spawn like 500 projectiles everywhere too

#

and I know btd6 does frame drop like crazy eventually

lean sail
#

Yea it is, but btd6 also let's you get way further than previous games like btd5

#

Super late game isnt playable, to the point where people remove towers that shoot a lot just to play faster. It lags so badly that the extra dps makes it play slower

latent latch
#

haha, gotta keep that original experience as if you were playing in flash

#

webgl pretty impressive though and that's kinda what I'm trying to get working

calm echo
# latent latch Anyone some good ideas for implementing "furthest along the track" logic in a to...

Some quick thoughts of different approaches
Create a path that they follow and track percentage complete.. This might be handy for picking the best in a group. But dont loop through every balloon

split the tracks into pieces and order the pieces in distance along the track, grab the one that is occupied and farthest. Then you can determine actuall target from all balloons inside that section. Basically Spatial Partitioning

latent latch
# calm echo Some quick thoughts of different approaches Create a path that they follow and t...

Yeah, the percentage idea is what I'm thinking here and trying to figure out if I can just grab that info directly from the navmesh. But, I don't think I can go about not recalculating a new path every time a unit gets displaced, so comparing back the waypoints generated probably isn't possible. Sooo, I need to kinda make my own fixed waypoints that each unit needs to compare to.

calm echo
#

If it’s like bloons you don’t need a navmesh, they are all just following a line

latent latch
#

Right, mines a bit more 3D-ish instead of the typical on-rails

latent latch
#

Yeah, I think that's the idea, segment the track into way points and calculate the distance from the unit to the waypoint and compare against that.

hard viper
#

you do that benchmarking, mao?

#

mostly want to know if I can just take down that file yet, to keep my repo tidy

latent latch
#

yeah kinda, need to chop a lot more physic calls down and merge them into distance calls

hard viper
#

any feedback?

latent latch
#

Why'd take the repos down? I cram as much as possible in mine just so it looks like I've some interesting stuff going on lmao

hard viper
#

it's not even functional code by itself lmao

#

I just threw up some functions from a gigantic, dirty class that won't be useful to anyone in a public repo

#

depends on a ton of crap not in the repo

twilit scaffold
#

Anyone know of any videos about the actual function of "Unity Code Assist Lite" Extension for VS?

twilit scaffold
hard viper
#

the repo I just linked is fully functional

tranquil patio
#

hello, does anyone know if we can use photon engine with unity visual scripting or it's only in c# ?

twilit scaffold
#

Ah. thanks for the clarification

twilit scaffold
#

So, since Visual Scripting is what used to be called Bolt, it should work, right?

tranquil patio
#

ty i'm stupide i was chearching in frensh ty :D