#archived-code-general

1 messages Β· Page 368 of 1

orchid pivot
teal carbon
#

the script is using a reference to the SceneView type, which exists in UnityEditor namespace instead of the UnityEngine namespace, in other words, the SceneView type is only availably in the editor and not in builds

#

the reason it's failing is because it is trying to compile the class to include it in the build, but ofcourse it can't, since SceneView doesn't exist in builds

orchid pivot
#

okay and hov do i fix it?

teal carbon
#

#IF UNITY_EDITOR .... #endif makes is so that all the code between is only compiled if the platform is the unity editor, else the code gets ignored

orchid pivot
#

okay thanks

edgy bough
#

Right, but then the image shown is a lot darker than the original. What could be causing this?

worn star
#

hi

swift falcon
worn star
#

if i want to instantiate a particle effect before a box gets destroyed

#

how do i do it ?

#

like cuz after the object is destroyed the particle is also destroyed with it

cosmic rain
fleet gorge
#

I suppose you're using unity's particle pack, all the particles are prefabs anyway

#

In addition to instantiating the prefab seperate from the object there's a timer script you can attach that will make the particle disappear after a few seconds

dusky tulip
#

Heyo, so I have a hit box(collider) animated aligned with the player animation for when it attacks. My player flips when going/looking to the right direction, how would I flip the hitbox animation as well when i'm looking to the right direction?

latent latch
#

animate the position of local values to the player

#

so animating the forward attack direction rotates with the player

lucid ridge
#

Is there a way to create a custom AppDomain in Unity ?
Or any solution for load / unload plugins at runtime ?

lucid ridge
knotty sun
#

nope, you cannot partially unload an app domain

lucid ridge
#

I have tried a lot of things beside the AppDomain but nothing works.. I have tried to unload all scripts references and do GC to collect and clean memory but nothing change πŸ˜‚

knotty sun
open plover
#

Whats a good RUDP project I could use?

lucid ridge
#

(If the monoscript is created in the dll and not in the game itself)

knotty sun
#

no, all Unity related stuff would have to be in the main AppDomain. But that is a design decision which can be dealt with

edgy bough
#

Is there a way to render only some objects in HDR and leave the rest in SDR? I'm working with a shader which only works properly when HDR is enabled. I have tried to render the main scene in SDR and then the objects in HDR with a separate camera, but I can't figure out how to overlay the HDR cam's output on the screen properly. Doing it with a UI RawImage (which draws a RenderTexture) works, but the objects I'm rendering have super low alpha values, so they are nearly invisible when shown on the SDR output. Maybe there's a way to somehow tonemap the HDR alpha values to SDR?

#

If I'm understanding this correctly, Unity's HDR automatically tonemaps the colors to SDR so that they can be shown on regular (SDR) displays such as mine, but the RT's alpha stays the same as the shader outputs it

steady moat
edgy bough
#

I'm using BiRP

#

Should've probably mentioned that before, sorry

steady moat
#

Oh, then you can either blit or not clear the buffer on one of the camera.

#

However, you should really consider switching to URP or HDRP if you want more intuitive support of such feature.

terse turtle
#

I have this code which makes a raid start. Each raid as the code does will spawn enemies and wait seconds for each to spawn. The thing I have now is that this won't let me have multiple raids to occur at once, and I believe it is due to the fact that the code will yield and wait. ```cs
IEnumerator SpawnRaid(Raid raid) {

yield return new WaitForSeconds(raid.startRaidTime);
DetermineRaidPathSpawnPoint(raid); // Determine spawn point for raid

foreach (EnemyType enemyType in raid.enemies) {

    yield return new WaitForSeconds(enemyType.spawnDelayForThisEnemy);

    int spawnedCount = 0;
    int activeRaid = 0;

    while (activeRaid < numberOfRaids) {
        while (spawnedCount < enemyType.enemySpawnAmount) {
            SpawnEnemy(raid.spawnPoint, enemyType, raid);
            spawnedCount++;
            yield return new WaitForSeconds(raid.spawnEnemyDelay);
            activeRaid++;

            print(raid.spawnEnemyDelay + " This is Raid Spawn Enemy Time Delay");
        }
    }
    print("Raid Ended");
}

activeRaids--;

}The issue remains here I think, but the other issue is that I am calling foreach of the raids in each wave which make it wait for each other which isn't what I want.IEnumerator SpawnWaves() {
foreach (SOWaveData wave in waves) {

    foreach (Raid raid in wave.raids) {

        StartCoroutine(SpawnRaid(raid));

    }

}```

steady moat
#

It has nothing to do with the Wait, but mostly because of your code.

#

Such as while (activeRaid < numberOfRaids).

terse turtle
#

So the issue is just how I call the Raids to start?

steady moat
#

That being said, using coroutine this way is really, really not recommanded.

steady moat
terse turtle
latent latch
#

Coroutine can work, but just creating a container for the SO data is another idea

#

but if you want to resolve your coroutine issues, consider debugging with breakpoints

steady moat
#

Ideally, you would create a class "Raid" that handle all the logic.

public class Raid 
{
    public void Execute()
    {
        if(currentWave.IsEnded || Time.time > currentWave.StartAt + delayBetweenWave)
           SpawnNext();
    }
}

public class Wave 
{
    public void Spawn() {...}
}

#

Obviously this is a really bare bone implementation

terse turtle
#

The thing is, how would I spawn enemies in that class if it isn't a monobehavior?

steady moat
#

GameObject.Instantiate

terse turtle
steady moat
#

And if it was truly an issue you could make an other script only for the spawning logic

#

No need to redefine your whole logic for a possible restriction like that

rigid island
steady moat
terse turtle
rigid island
steady moat
#

And even if it was the case, the raid could easily be a monbehaviour

#

He probably was using the Instantiate from the UnityEngine.Object class and was wondering how to instantiate an object not from a MonoBehaviour

rigid island
terse turtle
#

Is there a better way to handle the Raids when Spawning Enemies? I only used a Coroutine since they could Yield wait for seconds the specific amount I wanted.

latent latch
#
public class WaveSO : ScriptableObject
{
  [SerializeField] private int numEnemies;
  public int NumEnemies 
  { 
    get { return numEnemies; } 
  }
      
  public Wave InitWave()
  {
    return new Wave(this);
  }
}

public class Wave
{
  private WaveSO waveSO;
  public int EnemiesRemaining = 0

  public Wave(WaveSO waveSO)
  {
    this.waveSO = waveSO;
    EnemiesRemaining = waveSO.NumEnemies;
  }
}```
Usually what I like to do when creating a writable instance for the SO data
terse turtle
latent latch
#

It's to create a writable instance to append to instead of creating a coroutine and creating local variables to it

#

then the idea is that on each update() you'd read in your list of Waves

terse turtle
#
public class SOWaveData : ScriptableObject {

    public List<Raid> raids = new List<Raid>(); // List of raids in this wave

}

[System.Serializable]
public class Raid {
    public RaidPathType pathType;
    [Range(0.0f, 20.0f)] public int startRaidTime;
    [Range(2.0f, 4.0f)] public float spawnEnemyDelay;
    public float speedBoost;
    public List<EnemyType> enemies = new List<EnemyType>();
    public Transform spawnPoint;
}``` This is one script. Can't I use this and just make it work with Update instead of Coroutine?
latent latch
#

Anything you can do in a coroutine you can do in Update

terse turtle
latent latch
#

usually by managing the instances in some form of a container you would iterate over each update

latent latch
little meadow
#

and you want it to not be a coroutine because?

terse turtle
latent latch
#

Coroutines are fine too, but even what you're doing there should still be somewhat managed instead of creating them on a whim and forgetting

terse turtle
little meadow
#

I think it's more about defining your requirements well enough and writing code that matches.

#

Not that much a coroutine issue (but perhaps I am not understanding all the requirements of the system)

terse turtle
#

I haven't done a method since I don't know how to yield return and wait on them. I can't do them without a Coroutine.

little meadow
#

A coroutine is effectively an automatic state machine. In state 1 it increasese a counter by deltaTime until some time is reached, in state 2 it spawns an enemy, in state 3... etc.

#

And that's more or less how you rewrite a coroutine into... something you can call each frame, lets say

latent latch
#

I just encourage objects over coroutines because I find them easier to debug

#

otherwise like I was saying you'd probably want to start using breakpoints if you're running into issues and stepping through the code

little meadow
#

It does give you more control... the state is kinda better defined and not behind the scenes. But I'm not sure that's the issue here.

terse turtle
#

The issue is that every time the first raid ends, the second doesn't wait for the seconds it is supposed to spawn the enemies. It ignores it. So then I have the second Raid just spawning enemies in stacks. I believe it is due to this Foreach loop ```cs
IEnumerator SpawnWaves() {
foreach (SOWaveData wave in waves) {

    numberOfRaids = wave.raids.Count;
    activeRaids = numberOfRaids;


    foreach (Raid raid in wave.raids) {

       StartCoroutine(StartRaid(raid)); // This here

    }

    yield return StartCoroutine(WaitForWaveToEnd());

    yield return new WaitForSeconds(startNextWave);

}

}```

little meadow
#

+1 for breakpoints and general debug skill - helps solve every problem faster πŸ™‚

#

you're starting all raids coroutines at the same time in parallel (in a sense)

#

if you want to wait for each raid, you need to yield return the StartCoroutine

terse turtle
little meadow
#

okay, so that's what you have in the code here

terse turtle
little meadow
#

you're starting all raids in parallel... so they should all be spawning (based on the code you just posted)

terse turtle
little meadow
#
        foreach (Raid raid in wave.raids) {
           StartCoroutine(StartRaid(raid)); // This here
        }```
This will start as many raids as you got at the same time
#

It will start the coroutines anyway - they won't wait for each other

terse turtle
#

You are right. Then why do you think it cancels the delay for the spawn for the second one?

little meadow
#

Anyway... best use breakpoints or debug.logs to see what's going on and where the problem is πŸ™‚

#

Me reading and executing 5 parallel coroutines in my mind is way less efficient than you checking the actual values at runtime πŸ™‚

terse turtle
#

any tips?

little meadow
#

I guess it's something inside that StartRaid coroutine

#

some logic is off, I guess

terse turtle
#

The issue is that this variable is 0 for the second raid Spawn Enemy Delay. raid.spawnEnemyDelay Any guess where it could be getting changed or override here? ```cs
IEnumerator StartRaid(Raid raid) {

 yield return new WaitForSeconds(raid.startRaidTime);
// print("Raid Started");

 DetermineRaidPathSpawnPoint(raid); // Determine spawn point for raid

 foreach (EnemyType enemyType in raid.enemies) {

     yield return new WaitForSeconds(enemyType.spawnDelayForThisEnemy);

     int spawnedCount = 0;

     while (spawnedCount < enemyType.enemySpawnAmount) {
         SpawnEnemy(raid.spawnPoint, enemyType, raid);
         spawnedCount++;
         yield return new WaitForSeconds(raid.spawnEnemyDelay);

         print(raid.spawnEnemyDelay + " This is Raid Spawn Enemy Time Delay");
     }
 }

 activeRaids--;

}```

little meadow
#

well, right click on the variable - find all references πŸ™‚

terse turtle
#

It seems to be that there was no issue with the code at all. For some reason the Scriptable Objects were glitched and were having no delay. All I had to do was delete old Wave SO's and remake them. notlikethis

elfin tree
#

Is there a way I can make a Unity.Spline from a BezierCurve?

#

My main goal is to show something like this but in play mode (this is gizmo code)

 Vector3 position = this.transform.position;
            Quaternion rotation = this.transform.rotation;

            var opaqueColor = Color.yellow;
            // Draw bezier
            Vector3 destinationPosition = this.destinationPortal.transform.position;
            Vector3 destinationForward = this.destinationPortal.transform.forward;
            Vector3 startTangent = position + (-this.transform.forward * 10f);
            Vector3 endTangent = destinationPosition + (-destinationForward * 10f);
            UnityEditor.Handles.DrawBezier(position, destinationPosition, startTangent, endTangent, opaqueColor, null,
                2.5f);
#

Thing is with Unity.Spline I'm unable to set tangents manually it seems

#

An attempt I made but can't quite "connect the dots" πŸ₯²

#
            var startKnot = new BezierKnot(position);
            var endKnot = new BezierKnot(destinationPosition);

            var bezierCurve = new BezierCurve(startKnot, endKnot);
            bezierCurve.Tangent0 = startTangent;
            bezierCurve.Tangent1 = endTangent;

            
            _spline = new Spline(new List<BezierKnot> {
                new (bezierCurve.P0),
                new (bezierCurve.P1),
                new (bezierCurve.P2),
                new (bezierCurve.P3),
            });
            
#

This will look super square-y

#

I can also add BezierKNots directly to Unity.Spline but still, no tangent data

vagrant hollow
#

these pop when i open pro builder

#

this is the code

soft shard
# edgy bough Right, but then the image shown is a lot darker than the original. What could be...

Im not quite sure, could be related to lighting, post processing, layers or multiple things, the RenderTexture should more-or-less have the same output as your camera (depending on the settings of the render texture), you should be able to see a preview of what your camera sees from the Scene view if you select it in the hierarchy (or disable all other cameras to see it in the Game view), if its also dark in the preview, it could be due to other factors unrelated to the render texture itself

ocean hollow
#

also i think you might have to delete your library folder

#

it should regen and fix itself afterwards

dense rock
#

Hey there, I know that having raycast target enabled on images consumes some performance, so I want to disable it in a default preset. Works well for TextMeshPro as well, but when I create a button, it needs to have RaycastTarget enabled on its image. Is there a way to change how objects are created via the right click menu in the hierarchy?

vagrant hollow
vagrant hollow
ocean hollow
#

make sure your project is closed before you delete it though

#

depending on how large your project is, it might take a while for your library folder to regen upon startup, but that should fix your issue

dense edge
#

so, im trying to transfrom a image from disk into base64 so i can generate ramdom Npcs with it(monster rancher style whre you put a cd you get a new creature, but in this case is images from the pc)

#

how do i do that?

#

mostly how i can transform a image from disk into a code i can run a algority over it

open plover
#

Check google pretty sure someone else asked the same question

ivory spade
open plover
knotty sun
ivory spade
#

I absolutely hate my linux recognizes dotnet in terminal but not in vs or unity bru-

rigid island
vagrant hollow
knotty sun
vagrant hollow
#

the project one?

ocean hollow
#

what files were deleted

#

you shouldnt have deleted anything other than the library folder

vagrant hollow
#

i did?

ivory spade
ocean hollow
#

and then what happened

vagrant hollow
#

it got rid off my project files

ocean hollow
#

which ones...?

#

the library folder you mean?

dense edge
vagrant hollow
ocean hollow
#

no it didnt...

#

**you **did that

#

library doesnt do that on its own

#

what does your file explorer look like now?

#

maybe you can restore the files you deleted

vagrant hollow
#

i am

ocean hollow
#

they should be in your recycling bin

vagrant hollow
#

ok i fixed it but....errors are still present

ocean hollow
#

the same errors as before?

rigid island
ivory spade
#

Maybe I installed them as flatpak/snap?

#

Could that be the issue

rigid island
#

yes that would cause issues

#

since that isolates the apps

#

i never used those app managers, always terminal app-get or deb file. Nary a problem

vagrant hollow
dense tree
#

Hey! i'm working on a top down aerial shooting game, and i tried implementing a bomb that shoots out with a sudden burst of movement, then slows down quickly, but thats not really working. whats happening instead is the bomb just shoots out with a constant speed, any fixes?

private void Start()
{
    rb = GetComponent<Rigidbody2D>();
    mainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
    mousePos = mainCam.ScreenToWorldPoint(Input.mousePosition);
    Vector3 direction = mousePos - transform.position;
    Vector3 rotation = transform.position - mousePos;
    rb.AddForce(new Vector2(direction.x, direction.y).normalized * bombSpeed);
    float rot = Mathf.Atan2(rotation.y, rotation.x) * Mathf.Rad2Deg;
    transform.rotation = Quaternion.Euler(0, 0, rot + 90);

    DestroyObjectDelayed();
}
indigo tree
dense tree
#

yes i have yet realised that addforce isnt a literal push, how would one make it slow down? just by adding an opposite force after a timer?

dense tree
#

thank you sir, shall be tryin that

dense tree
indigo tree
#

Physics only updates in fixed update. So may as well do fixed

dense tree
#

aight

#

yay it worked

#

thanks mate

vagrant hollow
mossy snow
# vagrant hollow Im STILL trying to fix this

the code's available, debug it. Looks like something in your probuilder settings is wrong. I would just torch all those settings. It seems to use Unity's settings manager, so those might be in a json under ProjectSettings or in EditorPrefs

mossy snow
#

where is what?

vagrant hollow
#

the probuilder settings

mossy snow
#

ProjectSettings dir or in EditorPrefs. Look at the code, specifically ProBuilderEditor and ProBuilderSettings

#

you might have bad entries in ProjectSettings/Packages/com.unity.probuilder/Settings.json, or maybe ProBuilder recovered an older settings file (see ProBuilderSettings) that's incompatible

vagrant hollow
mossy snow
#

torch it all. Uninstall ProBuilder, close Unity, delete ProjectSettings/Packages/com.unity.probuilder dir, open Unity, re-install ProBuilder. Obviously make sure your project is in source control and current so you don't break anything

mossy snow
#

that is step 5 of the 5 steps I gave you yes

vagrant hollow
mossy snow
#

same errors?

vagrant hollow
#

yea

mossy snow
#

do you have a file at ProjectSettings/ProBuilderSettings.json?

mossy snow
#

repeat the steps from before, but this time delete that file too

vagrant hollow
#

i did

mossy snow
#

so you deleted two files?

vagrant hollow
#

yea

#

i deleted probuilder file

#

also something to note i haven't seen anything unusual besides the console error

mossy snow
#

then how did you have a file at ProjectSettings/ProBuilderSettings.json after reinstalling ProBuilder? Or did you mean you had one, and deleted it in addition to the other json?

vagrant hollow
mossy snow
#

are you using an ancient version of ProBuilder? that's the deprecated settings path. Maybe it'll be easier for you to create a brand new project and overwrite the json in ProjectSettings/Packages/com.unity.probuilder/Settings.json

dusky tulip
#

So I have this game build and every time I go to select an audio mixer group in my material it crashes. It's never happened before and idk what to do. Any help?

ocean hollow
#

also not a code question

#

... what am I supposed to do with this

#

This doesn't show the error log

dusky tulip
#

sorry

#

it crashes the whole software

#

so I cant show you the error

cosmic rain
tawny elkBOT
#
πŸ“ Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

lean sail
#

ah didnt know we had a command for that

ocean hollow
lean sail
#

2022.3.13f is quite old, there is now 2022.3.45

ocean hollow
#

2 years old is not "Quite old" in this case and I doubt that's the cause such a bug after such a basic operation

lean sail
#

πŸ€·β€β™‚οΈ you can doubt all you want. 2 years is an eternity in the software world.
and im not guaranteeing its the solution but its a likely one. unless they are doing some really weird editor stuff intentionally, its likely not their code thats the problem

dusky tulip
#

thx guys

ocean hollow
dusky tulip
ocean hollow
# dusky tulip most likely

I've seen an error with audio files before as a result of corrupted values so it might be worth checking their properties in file explorer

tidal galleon
#

Hey people I am writing a modular Health and Damage system and I am wondering who should handle the Damage? Should the Player check if it has collided with the Enemy, an Arrow and explosion etc or should the enemy decide that it has Damaged the Player or took damage itself? Should the explosion decide if the Player or Enemy takes the damage?

Hope my question is clear enough

soft shard
# tidal galleon Hey people I am writing a modular Health and Damage system and I am wondering wh...

I would setup an IDamagable interface (you can name it however youd like) and the thing that should cause damage (arrow, explosion, enemy melee weapon, etc) could do a TryGetComponent<IDamageable> if it returns true, you can call something like IDamagable.TakeDamage(value) and the thing implementing it (player, enemy, breakable crate, etc) can decide what to do with that value, you could even set it up in a way where if the value is above zero it can be considered a "heal" and below zero considered "damage", the thing taking damage can also decide to scale the value based on something like armor if you wanted, for example if you multiply by a decimal you can reduce the value by a percent, so if the damage was 200, and you want 50% armor, you can 200 * 0.5 and get 100 damage instead

tidal galleon
#

the enemy or the player taking the damage

soft shard
# tidal galleon so if an enemy using melee hits me who should handle that?

The damage source (melee weapon or enemy logic itself if it doesnt use physics) should check for something that can accept damage (IDamagable interface) and apply a number to that - if your player happens to implement IDamagable, they will receive damage when the melee weapon or enemy collider hits them, and the player can decide how to apply that damage to themselves

tidal galleon
#

okay i see what you saying

#

thanks

soft shard
#

Np

loud minnow
#

I want to be gameplay engineer, should I focus on unity first or math? I have prior experience with a game engine like roblox studio for 4 years, so I think maybe math might be more important to land a job rather than engine, just want advice on what I should do.

mellow sigil
#

You are more likely to get a job if you have experience in game engines than if you have experience in pure math, especially if you're planning on self studying

soft shard
swift falcon
#

Why Collision is a class? It does not even stays stable at Enter/Exit, changes.

lean sail
#

You can scroll down to near the bottom for a short list of when you should consider defining something as a struct

swift falcon
#

Hm i should test that more. I meant the collision in the exit is not the same with enter's. But i believe it has something to do with GetHashCode(). It returns always the same. Wonder if they actually use single instance for every collision atwhatcost If i had the access to their native code side this would be easier to find out damn

mossy snow
#

Project Settings -> Physics -> Reuse Collision Callbacks

swift falcon
#

I will test it oout

#

Yes evilreeper was right about this

lean sail
cosmic rain
#

Though, in this case it does seem to be related. Just remember that it's not always related.

verbal heath
#

question regarding colliders for tilemaps. i want to figure out each tile a bouncing ball hits (for a brick breaker game), however it seems that OnCollisionEnter2D only gets called on the first bounce each fixed update, furthermore each call only produces one contact point (in collision.contacts or collision.GetContacts()). is there a easy solution to this (otherwise i'l just not use a tilemap).

picture shows a example situation, it goes top left on start, and only the topmost brick collision gets its OnCollisionEnter2D

solid timber
#

I have been working on this forever and feel like I've tried everything. The goal is to have the bullet script run when battling starts, the bullets script works perfectly fine but I can get it to be triggered when battel starts. Right now I have it integrated into my CombatUnitAuthoring script but I have also tried it in the Unit Authoring script. I believe the whole code is written properly I just think I'm doing something completely wrong. If you have a minute and don't mind looking I would greatly appreciate it. https://gdl.space/xatexesuho.cs

knotty sun
solid timber
#

It works though πŸ€·β€β™‚οΈ the explosion does happen at the end. If you think the complexity of it is what's making this so hard todo I could maybe change it

knotty sun
solid timber
#

That's alright since the bullets don't require phyics for this application.

knotty sun
#

so I guess this

 isInCombat = IsInCombat();

is the problem

#

gotta say this look horribly like AI generated code

#

if that is the case then you need to be debugging this

           Collider[] hitColliders = Physics.OverlapSphere(transform.position, AttackRange);
            foreach (var hitCollider in hitColliders)
            {
                if (hitCollider.CompareTag("Enemy")) // Replace "Enemy" with your tag for enemies
                {
                    return true;
                }
            }
            return false;

to see exactly what it is doing

solid timber
solid timber
knotty sun
solid timber
#

Didn't know that, thanks

thin hollow
#

I need a function that should overwrite variables in the class using variable from another instance of that class, but only those that have non-default values. Would this be the correct way of doing it, or there's a better way?


        public void OverrideSettings(NPCSettings newSettings)
        {
            if (newSettings.scale != default (NPCSettings).scale)
                scale = newSettings.scale;

            if (newSettings.health != default (NPCSettings).health) 
                health = newSettings.health;

            if (newSettings.immortal != default (NPCSettings).immortal) 
                immortal = newSettings.immortal;
            //Ad nauseam...
        }
worthy fable
#

Hello everyone. I never really cared about my code being too spaghetti but at the same time, I was suffering from how spaghetti it is. I think I just wanted to pretend that I didn't care. Problem is, I find it extremely difficult to apply any architecture to it. (SOLID, Design patterns) Let's say I'm starting a new project. Everytime, I'm too scared by over exhausting amount of "high-level" changes that I have to learn and apply. At some point, I'm like: I should do this, I have to do this. So I open a youtube tutorial about decorator pattern to learn so that I can make my stats & effects, perfectly added into game. This only guides me to a burn out from unity. Feeling of never going to understand how code itself works.

Any suggestions would be extremely appreciated...

cosmic rain
thin hollow
cosmic rain
cosmic rain
thin hollow
cosmic rain
thin hollow
#

I think I also will have to change a couple of different parts in my code as well, since (default) doesn't work like I expected it to. =\

cosmic rain
#
public class SomeConfig
{
  static SomeConfig defaultConfig = new SomeConfig(){ a = 1f, b = true};
}
thin hollow
cosmic rain
thin hollow
cosmic rain
#
public class NPCSettings
{
  public float scale = 1.0f;
  ///....
}

If you're talking about assigning 1 here, then it's a field initializer, and it's fine.
In this case you don't need a constructor.

thin hollow
cosmic rain
#

No. As I said in the previous message, it's fine.

thin hollow
#

Then why did you say it won't equal 1.0?

#

Or it still won't be equal to 1.0?

cosmic rain
#

I don't remember saying that aside from when we were talking about default

thin hollow
#

When using (default), I mean

cosmic rain
#

No, yes. Because default is the default value for that variable type. While what you do is initialize your field(with a non default value). It's not the same.

#

You just happen to initialize it in the field initializer.

thin hollow
#

I thought default should return... well, default state of the class. One that's hardcoded into it, such as via explicitly stating that scale must be equal to 1.0f

cosmic rain
thin hollow
#

If it isn't, then... What's it is for, really? Seems entirely useless then.

cosmic rain
thin aurora
thin hollow
thin aurora
#

If you don't know what it this, you probably don't need it

cosmic rain
chilly surge
#

A class is also a type.

#

default(SomeClass) will just be null.

thin hollow
thin aurora
#

Like I said, reference types default to null

#

So this will be an NRE

cosmic rain
thin aurora
#

Class is a reference types. This code is effectively null.scale

chilly surge
#

(default)SomeClass isn't even valid code.

cosmic rain
#

Ah. yea, didn't notice the brackets, but also this code would give a null reference.

thin aurora
#

default does not mean the initially assigned value here

#

If you want to revert to the defaults, you check for the assigned value explicitly. default does not give you what you want here (it gives 0)

#

Not to mention you don't use default like this. Just use 0. default is used when a variable can be both a value type and a reference types (generic types)

#

If you have code like this, just make constants at the top of the class that define "default" here and check those instead
Do note that float is inaccurate so make sure you approximate it (Unity has a method for this)

open plover
#

So I got a script that creates a 3D prisms from 2d polygons. However, the result looks like this. What am I doing wrong? Here is the script: https://hatebin.com/mvupyvdtof

cosmic rain
#

An issue with the winding order.

thin hollow
# thin aurora If you have code like this, just make constants at the top of the class that def...

I don't really like the idea of having to have three copies of every variable in code. Having to duplicate everything to get it to be read-only (since Unity doesn't show variables with "get/set" in the Inspector) was annoying enough... This should work, right?


        private static NPCSettings _defaults;
        public static NPCSettings Template 
        { 
            get 
            { 
                if (_defaults == null) 
                    _defaults = new(); 

                return _defaults; 
            } 
        }


        public void OverrideSettings(NPCSettings newSettings)
        {
            if (newSettings.scale != NPCSettings.Template.scale)
                scale = newSettings.scale;

            if (newSettings.health != NPCSettings.Template.health) 
                health = newSettings.health;

            if (newSettings.immortal != NPCSettings.Template.immortal) 
                immortal = newSettings.immortal;

            //Ad nauseam...
       }
thin aurora
#

This is very over complicated code

cosmic rain
thin aurora
#

Why not just have blank variables and assign them with a Reset method when the class is created?

#

Then you just have a single place, plus a Reset method

cosmic rain
#
if (newSettings.scale != _defaults.scale)
  scale = newSettings.scale;
thin hollow
open plover
cosmic rain
versed loom
#

Hello, I dont know what pattern should i implement for this situation. Im thinking about mediator but idk. ( the images are 2 different visualization of the same thing ) (for the OnSelect of Button and float field, I get the current tag from the word parameter)

little meadow
versed loom
little meadow
#

Ah! Now I get it! I love examples, thanks πŸ™‚ I'll think about it, see if I come up with something πŸ‘

fleet gorge
#

this is more of a vs thing but is there a shortcut to make cases for all of these?

rigid island
#

"Add missing cases"

fleet gorge
#

Thanks!

#

This is a life saver

#

Not me, but one of my programmers in another project manually did 54 switch cases(who would eventually get his PR rejected)

rigid island
#

holy hell

little meadow
#

(But also, you could have an interface and different implementations and just call FindTarget(some params) on the instance that you get)

fleet gorge
#

I cant exactly change the inherited interface at runtime

#

This is for a tower defense game where you can choose your targeting system for your tower

little meadow
#

well you should be able to just switch the ITargetFinder instance πŸ€·β€β™‚οΈ but sure, this will also generally work πŸ™‚

fleet gorge
#

object oriented horrors beyond comprehension

little meadow
#

okay, if you say so πŸ™‚

fleet gorge
#

ah shit I made a terrible naming convention, theres now GameObject Tower.target and enum Tower.TowerSave.target

#

is there a better way of doing this

little meadow
#

you don't need the elses

frozen holly
#

How is an equipment system usually handled animation-wise? How do you make the equipment follow the player’s arm or body?

leaden ice
frozen holly
#

by "bone," do you mean creating a separate object for each body part?

rigid island
#

make sure you're child of the bones (thats what animates)

frozen holly
#

ty

leaden ice
#

You wouldn't be creating anything extra

#

They already exist if you're using a skinned mesh renderer/ animation rig

fleet gorge
#

for the first time in a long while I made a basic mistake of using ontriggerenter instead of ontriggerenter2d

rigid island
#

thats rite of passage for unity

fleet tide
#

hey ! i need help , i use UMA and i dont understand why when im in editor, i have a correct character and when i run, my character become shiny ahah ?

vagrant hollow
#

is this wrong?

#

why is it not working?

rigid island
simple egret
open plover
#

Is there any possibility that the built-in simulator does not correctly return touch positions?

leaden ice
#

sure there's a possibility. But what makes you say this

#

And which simulator do you mean

open plover
open plover
hard estuary
hard estuary
open plover
#

The x value seems kind of fine, however the y is really weird

hard estuary
#

Generally if your touch position returns (0, 0) to the bottom-left corner, and window resolution for the top-right corner, then the positions are working as intended. Then you worry about converting it to the world space.

open plover
#

I'm touching a cube at 0,0,0

#

x value of the touch positiΔ±on is 1.68

#

y value is 20.77

hard estuary
open plover
#

camera is placed at x,y axis

#

I'm using a seperate ortographic camera aside from my main perspective camera

#

To convert touch positions to world positions

hard estuary
#

I think it's better to apply conversion basing on the main camera.

open plover
#

I mean if it was an ortographic camera, why not?

#

Besides, does it make any difference if I use a seperate camera to handle touch position conversions?

hard estuary
open plover
#

Nice drawing, ty now I understand

#

Then I guess I have to use raycasts?

#

Since I don't want to make my main camera ortographic

somber nacelle
hard estuary
somber nacelle
#

you have to specify a distance with ScreenToWorldPoint or else it just returns the camera's position. and if the distance can change based on what is in the scene, that obviously wouldn't work. so the raycast would be the best option

alpine token
#

I'm trying to use Steam Input so I can address the 2 control sticks and 2 touch pads on a Steam Deck as vec2. As far as I can tell the Unity Input System does not support this because the Steam Deck only presents itself to the game as an xbox controller.

I've setup Steamworks.NET and it has successfully init'd itself. I've created a game actions file and placed it on the Steam Deck, then I loaded my game and mapped the detected actions to the various inputs on the Deck.

I'm now at the point where I'm trying to get any sort of output from Steam Input. Right now I can't get anything out of it. Does anyone have any sort of Idea what I may be doing wrong?

Here is my Update() method in my SteamManager script.

protected virtual void Update() {
        if (!m_bInitialized) {
            return;
        }

        // Run Steam client callbacks
        SteamAPI.RunCallbacks();

        InputHandle_t[] handles = new InputHandle_t[16];
        int connectedControllers = SteamInput.GetConnectedControllers(handles); //No controllers returned
        InputHandle_t inputHandle = SteamInput.GetControllerForGamepadIndex(0);
        InputActionSetHandle_t actionSetHandle = SteamInput.GetActionSetHandle("InGameControls"); //Returns 1, a valid set.
        InputDigitalActionHandle_t aButtonHandle = SteamInput.GetDigitalActionHandle("a_button"); //Returns 9, the index for this action.

        InputDigitalActionData_t aButtonResult = SteamInput.GetDigitalActionData(inputHandle, aButtonHandle);

        Debug.Log(connectedControllers + "|" + aButtonResult.bActive + "|" + aButtonResult.bState); //Shows 0|0|0. No controllers, an no presses detected
    }

In Desktop Mode on the deck, the game controllers section shows the Xbox controller. If I close steam, I see all the raw values for each discrete input device. The path for the xbox controller (before closing Steam) is /dev/input/js0. After closing Steam it switches to "Steam Deck" at the same path of /dev/input/js0.

TLDR: I want to address both sticks and both touch pads on a steam deck as Vec2s.

rigid marsh
#

Okay so I have a 3D VR game, with 3D buttons, and a 3D arcade machine. How do I make a 2D minigame for the arcade in this 3D world?

spare dome
#

make an arcade machine -> make 2d player via cube or anything else in the arcade machine -> make player controller using the buttons and make the players movement to the X and Y local axis of the screen object -> pretty much it

rare spruce
#

pls help. my solution explorer looks like this, and unity keeps reloading all the libraries. how do i fix this? tried googling but i cant find anything specific for visual studio 2022.

even if i "scope to this project", when i tab out and in, and save, it just resets.

somber nacelle
#

go into the external tools settings in unity and uncheck the types of project files you don't want it to generate csproj files for

rare spruce
#

i love this forum. is this ok? anything else you would uncheck?

#

I unchecked it all, now it looks clean. THANK YOU.

rigid island
hallow arrow
#

Anyone knows how to do this? I have this object that is basically a conveyor belt, it already moves the objects on top of it forward, but i also want to make it gradually center on the conveyor local x axis without interfering with the forward movement. (image for hopefully some better context lol)

    private void MoveControlledObjects()
    {
        Vector3 moveDirection = transform.forward * targetSpeed * transform.parent.localScale.x * Time.deltaTime;

        foreach (Rigidbody rb in controlledObjects)
        {
            if (rb != null)
            {
                rb.MovePosition(moveDirection);
            }
        }
    }
#

i have tried a few things already but nothing works :v

spare dome
#

well if you dont want the items to respect collisions you can just use thier transform

devout parrot
#

Is there anything special you need to do to get rid of slope bounce on a rigidbody character travelling on a spherical surface?

spare dome
#

well when working with rigidbodies and slopes you would usually add a down force if going up a slope to counteract the rigidbodies gravity being turned off

#

you can do the same when going down a slope as well, which is not recommended

#

but usually you would want to orientate the rigidbodies move direction with the slopes angle

lean sail
devout parrot
#

I must not have been clear when I said slope bounce. I was talking about grounded characters having 0 vertical velocity when grounded, causing the character to start skipping when walking down a slope.

hallow arrow
#

i ended up using lerp, its not the prettiest, its a bit junky, but will do the trick for now lol.

    private void MoveControlledObjects()
    {
        Vector3 moveDirection = transform.forward * targetSpeed * transform.parent.localScale.x * Time.deltaTime;

        foreach (Rigidbody rb in controlledObjects)
        {
            if (rb != null)
            {
                Vector3 currentWorldPosition = rb.position;

                Vector3 localPosition = transform.InverseTransformPoint(currentWorldPosition);

                localPosition.x = Mathf.Lerp(localPosition.x, 0, targetSpeed * Time.deltaTime * 5);

                Vector3 centeredWorldPosition = transform.TransformPoint(localPosition);

                Vector3 newPosition = centeredWorldPosition + moveDirection;
                rb.MovePosition(newPosition);
            }
        }
    }
hallow arrow
lean sail
plush bobcat
#

If I use navmesh, is there a way i can have non-cylindrical agents?

void basalt
#

you can do that with cars and write a steering behavior, for example

plush bobcat
#

but the path is determined based on the given width of the agent, no?

#

like it won't make a path that it believes it is too narrow for the given agent's width

void basalt
#

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

#

I guess you'll just have to hack something together

plush bobcat
#

i can use A* and do the same thing

#

but there's a lot of benefits of navmesh that i wanted

#

oh, well

void basalt
#

it's also important that you understand that you'll need to use rigidbody addforce or velocity changes to steer the car.
manually updating the transform won't give you the desired behavior you want for that

#

you probably already realize that, but it's a simple thing to overlook

plush bobcat
#

I just want the path

#

then i'm going to use wheelcolliders

#

I know how to figure out the steer angle of a car, there's a pretty simple formula

twilit rune
#

i'm trying to change the FOV of the main camera but Camera component doesnt have a main, or fieldOfField i can change in script, or anything for that matter

#

is this something with unity 6's preview version or am i doing something wrong?

twilit rune
#

Yes

west lotus
#

So whats the problem ?

mighty void
#

Anyone knows why this happens?

#

This is my game view

#

But in a exported version look like this

lean sail
tawdry hornet
#

Is Copilot good with Unity C# scripting?

lean sail
neat kestrel
#

hey I am getting a really weird crash which I can't for the life of me find the source of. It crashes both in editor play mode and in a build, and both the player.log and editor.log have no consistent stack trace or show any error
The only error i've seen is this one but I can't reproduce that error, however the crash happens consistently.
The instruction pointer of the currently executing method is not on the recorded stack. This is likely due to a runtime bug. The 1 frames are as follow:
I have tried to debug using Visual Studio attaching its debugger and using breakpoints. I have spread Debug statements everywhere and putting a breakpoint at the last debug statement that show up in the crash doesnt work as unity crashes and VS then just exits debug mode without any errors

    Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
    Managed Stacktrace:
=================================================================
=================================================================

This is the end of the Editor.Log

Can somebody please help me at least figure out a better way to debug crashes im desperate lol

plucky inlet
neat kestrel
#

i don't want to go through updating the whole project because im literally 2 weeks from release lol and it would take ages

#

if i cant find anything else i will try it with a copy

#

but im trying to find other ways rn

plucky inlet
#

No git repo behind your project?

neat kestrel
#

there is but git lfs for some reason replaced some files with git lfs links instead of their actual content so i mucked up that ...

plucky inlet
#

thats how git lfs is working. Its linking your repo to the actual source files that exceed the max filesize. So you could just back it up, make another branch and just go one version up to see if that help. Apart from that, restart machine, delete library. try to figure out what you did before it happened. Did you add any third party plugins?

neat kestrel
#

thats the thing, if i try to revert back to an earlier commit and i load the project, some .cs files are replaced with git lfs links which they shouldnt cuz i chjecked git attributes and there is no rule for .cs files

#

ive deleted library, restarted machine, reinstalled the same version of unity

#

its not unity related though because if i delete a certain function it doesnt crash but i still dont know where it crashes inside that function which is where my kefuffle is at

#

because it doesnt crash every time during that function, i made a trail of debug statements to let me see the last thing being executed but it doesnt really help

#

i also checked event viewer and it said something to do with ntdll.dll but that doesnt really help me either

#

i have some 3rd party libraries like LeanTween, but i dont see why they would suddenly stop working as I haven't messed with them in a while

plucky inlet
neat kestrel
#

oh yeah my bad lol wait

#
{
    Debug.Log(gameObject.name + " STARTED DYING");
    if (deathSounds.Count > 0)
    {
        AudioClip sound = deathSounds[UnityEngine.Random.Range(0, deathSounds.Count)];
        PrefabManager.instance.PlaySound(sound, transform.position, 0.25f);
    }
    Debug.Log(gameObject.name + " PASSED DEATHSOUNDS CHECK");

    CheckForEvents(EventChecker.onDeath, this, killer);
    Debug.Log(gameObject.name + " CHECKED FOR EVENTS");

    if (!(killer is PlayerEntity) && !ignoreOnKill) GameEvents.instance.OnEntityKilled(this, killer);

    if (killer is PlayerEntity && !ignoreOnKill)
    {
        GameEvents.instance.OnEntityKilledByPlayer(this, killer as PlayerEntity);
    }
    Debug.Log(gameObject.name + " AFTER ENTITY KILLED BY PLAYER");

    if (GetComponent<ReturnToPoolAtTime>() != null)
    {
        Debug.Log(gameObject.name + " STOPPED ALL COROUTINES");
        gameObject.SetActive(false);
        Debug.Log(gameObject.name + " SET INACTIVE");
    }
    else
    {
        if (score > 0)
        {
            Debug.Log(gameObject.name + " DESTROYING OBJECT RN");
        }
        Destroy(gameObject);
    }
}

This is usually the last thing that runs before my massive chain of debug statements starts running

plucky inlet
#

And did you carefully comment out one part after the other to see, what could trigger it?

neat kestrel
#

yes but its not one thing that triggers it its the whole thing i think

#

i can double check but i think i tried that yesterday

#

because even when it crashes, the last debug statement i can see is the DESTROYING OBJECT RN one before the last Destroy function call

#

so it goes through everything inside it even when it crashes

#

let me double investigate the function itself ill come back to you

plucky inlet
#

So maybe something is hooked to that gameObject you are destryoing at this point and it was not cleaned up correctly before destroying it?

neat kestrel
#

yeah okay i just commented out teh whole of the inside of that function and it still crashed :|

neat kestrel
#

maybe some coroutine is linked to it in some weird way but i dont think so?

#

the only coroutine that affects it is when enemies flash white when they get hit but ive already tried commenting that out with no effect

#
=================================================================
    Managed Stacktrace:
=================================================================
      at <unknown> <0xffffffff>
      at UnityEngine.MonoBehaviour:StartCoroutineManaged2 <0x00153>
      at UnityEngine.MonoBehaviour:StartCoroutine <0x00212>
      at ExplosiveBarrel:Die <0x00142>
      at BaseEntity:TakeDamagePureNumbers <0x00f03>
      at BaseEntity:TakeDamageWithPopup <0x0052a>
      at BaseEntity:TakeDamage <0x0055a>
      at BaseEnemy:TakeDamage <0x0029a>
      at TakeDamageInsideCollider:Update <0x009e0>
      at System.Object:runtime_invoke_void__this__ <0x00187>
=================================================================

Ok last time it crashed when i deleted that I got this at the end

#

so i think it is somehow to do with coroutines?

#

so i deleted everything inside the ExplosiveBarrel.Die function and it went back to crashing without errors

cosmic rain
#

Did you try reproducing with the debugger attached?

neat kestrel
#

yeah the debugger doesnt do anything because even with breakpoints, unity hard crashes and the VS debugger just disconnects

#

theres nothing in the output for it either apart from the disconnecting text

cosmic rain
neat kestrel
#

is that the standalone one?

cosmic rain
#

No. In your ide - debug - attach to process

neat kestrel
#

ohh right

#

it only lets me to attach to unity

#

which is what I did

#

OHH

#

wait its separate

cosmic rain
#

Never used rider, but there should be a way to attach to process instead of using the unity configured debugger.

neat kestrel
#

im in visual studio

cosmic rain
#

Oh, is it? The theme looks weird.

neat kestrel
#

its the dark one :D

cosmic rain
#

Then what I said debug - attach to process.

neat kestrel
#

ok im attached give me a second

cosmic rain
#

Though maybe it's just because it only shows one small part of the window.

neat kestrel
#

ok as soon as I attach it it breaks and says current stack not found in a loaded module?

#

unity isnt crashed at this point because if I deattach VS unity resumes

cosmic rain
neat kestrel
#

do i try to untick that break when this exception occurs?

#

lemme try that

#

ok now its fine lemme find the crash

#

ok here comes the ntdll.dll shenanigans

#

and yeah if i deattach unity breaks

cosmic rain
# neat kestrel

That might actually imply that there's an issue constantly and it only manifests as a crash sometimes.

neat kestrel
#

what the heck XD

cosmic rain
#

What process are you attaching to?

neat kestrel
#

unity.exe

#

thats a bad picture my bad

#

zoomed out picture here for both of these

cosmic rain
# neat kestrel

Are there other processes that have unity in their name or your project name?

neat kestrel
#

nope its just that

#

theres unity hub but thats different

cosmic rain
#

Okay.

#

Can you take a screenshot of the whole window? I want to see what thread it is

neat kestrel
#

yeah give me a sec

cosmic rain
#

And while you're at it, switch to the main thread and take a screenshot of the stack trace as well

neat kestrel
#

apparently it is on the main thread

#

slightly better picture maybe

cosmic rain
#

Oh,it is the main thread

#

Thia crash seems to be caused by the debugger being connect it seems.πŸ₯΄

neat kestrel
#

but even on a non dev build it crashes?

#

or is that built in to unity

cosmic rain
neat kestrel
#

ok well is there any way to change previous git LFS commits on .cs files so i could try to rollback?

#

idk if uve worked with git lfs

cosmic rain
#

Not sure about lfs, but normally you should be able to roll back previous commits.

neat kestrel
#

yeah if i try to, lfs replaces some of my .cs files with the lfs link

cosmic rain
#

What client are you using?

neat kestrel
#

just git thru command line

#

i just did a simple git checkout -b before-crash <id>

plucky inlet
#

are you in need of using gitlfs? Just curious if you could remove it entirely

neat kestrel
#

im using WWIse soundbanks

#

which go over the 100mb

plucky inlet
#

Ah, got it.

neat kestrel
#

i found online someone saying to do git lfs install?

#

would that just reimport things or something?

plucky inlet
#

It will just install git lfs again. I actually dont know the state of your lfs

neat kestrel
#

how can i check or show you?

plucky inlet
#

git lfs status

neat kestrel
#

idk why its tracking the ExplosiveBarrel.cs because it doesnt have .cs files in the git attributes file

plucky inlet
neat kestrel
#

u mean to do untrack or touch

plucky inlet
#

when you untrack you have to touch it to convert it back to a normal file

neat kestrel
#

icould do both with *.cs?

plucky inlet
#

make a backup and try it.

neat kestrel
#

ok

#

it will take a bit ill let you know when its done

plucky inlet
#

I am here now and then, so just post when you got updates. someone will be there

neat kestrel
#

so it hasnt done anything wrong im able to load the project without errors

#

now the question is, reverting back to the old commit do i do the same thing again after i checkout into a new branch based on the older commit i wanna use>

#

or does it touch the files in history too

jaunty sundial
#

Is there a way to have a particle system on a screen but whenever i click it adds a velocity to the particles to move to where i clicked on the screen or would it be easier to just do it with loads of sprites

neat kestrel
#

update on my situation

I have updated to the next LTS version which is 2021.3.4f1, I don't want to upgrade further than that because its likely to break even more things and i dont think its caused by unity itself

I tried to revert to an earlier commit and then do git lfs untrack and then touch and it didn't do anything so back at square one

knotty sun
neat kestrel
#

wouldnt 3.27 be before 3.4?

knotty sun
#

no. is 4 greater than 27 ?

neat kestrel
#

ohh thats how they do it nevermind woops

#

wait lol i just realized i downgraded cuz originally i was on 33f1 lol im stupid

past raven
#

hello, my gizmo lines disappeared when i made a serialized variable static

neat kestrel
#

oh my god i think i need to get my developers license removed LOL

#

yeah this crash makes total sense

#

this is causing an infinite loop... hence there are no errors or anything

#

yikes

#

thnak you so much for trying to help me @plucky inlet @cosmic rain but im sorry to say you wasted your time because i was just being stupid :D

past raven
#

am i not able to make static variables serializable?

neat kestrel
#

dont u need the class to be static too?

past raven
#

no..

#

why

knotty sun
past raven
#

ohhh

#

ok thx

past raven
#

i might be having a brain fart but can you not assign a new value to static variables?

#

if (other.CompareTag("Player") )
{
CameraFollows.leftLimit = 25f;

#

keeps giving me the old value in debug

cunning burrow
#

a little confused, I have my scene loaded with async

#

I click play

#

nothing happens...

#

the load scene non async didn't work either

#

nvm it was just because it wasn't on main thread ig

past raven
#

can anyone answer

vagrant blade
#

Yes you can assign values to static variables. An obvious reason why its not is because that line of code is not running.

past raven
#

ic ok

rigid island
void mango
#

Is C# Player's Guide book really good ?
PDF version is only $24 for the 5th edition

rigid island
#

getting a book for 2024 is nonsense, soo many good FREE resources online

#

it would be a waste of money IMO

#

books are not always keeping up with latest anyway

void mango
#

I'm trying to use free and paid and all I get are really bad explanations from the content creator
sometimes no explanations at all. Just copy as I do approach

void mango
#

idk what that is

rigid island
#

the creators of c# lmfao

steady moat
rigid island
#

agreed. Learning is easier by doing

rigid island
open plover
#

I have a couroutine with a WaitForSeconds. Is there any way to cancel the coroutine while it's waiting? Or should I just add an check after the WaitForSeconds

rigid island
open plover
#

Thats why I asked the question in the first place

leaden ice
#

Beginners often use it improperly, it's likely you did not use it correctly.

rigid island
leaden ice
#

Proper use example:

Coroutine c = StartCoroutine(MyCoroutine());
StopCoroutine(c);

Improper use example (doesn't work):

StartCoroutine(MyCoroutine());
StopCoroutine(MyCoroutine());

@open plover

rigid island
#

like the example above?

open plover
rigid island
#

thats not a type coroutine then

open plover
#

I'm just gonna call StopAllCoroutines

rigid island
#

or learn to do it properly? what if you have multiple coroutines in same script

open plover
#

My code was like "StopCoroutine(SpawnObject());"

leaden ice
#

yeah, which won't work

#

StopAllCoroutines will work depending on your use case - but is obviously less flexible

#

as you cannot manage individual coroutines

rigid island
open plover
open plover
#

Like one method at a time

rigid island
chilly surge
#

Ultimately you need to hold onto something, otherwise how would Unity (or anyone) know which coroutine you want to stop? Whether that something is the running coroutine itself, a signal that WaitUntil is watching, a CancellationToken for task, or whatever.

upper pilot
#

How should I handle UI on my 2d sprites?
Do I create a separate world space canvas?
What if I want UI to follow a character above its head(like a health bar), do I make a world space canvas per unit in a game?

latent latch
#

health bar can just be quads

upper pilot
#

It's text, bars, images etc

#

a tooltip

#

per character on hover

latent latch
#

I think I've seen people using UI for them, abit less performant but probably not a big deal for a handful of units

upper pilot
#

do I just calculate position in code?

latent latch
#

pretty much

upper pilot
#

if I disable/enable canvas on hover to display a tooltip, would that be good?

latent latch
#

it's just a position + offset from the unit

upper pilot
#

Then I can have 100 of canvases(1 per unit)

#

yeah the issue is that you can't easily see it in play until you run the game

latent latch
#

either way works, but if you're using anchors to keep the text boxes in the screen alwaysy then UI may be ideal

#

or just having the structure of the UI box containers

upper pilot
#

canvas is UI right? World space or not

latent latch
#

right a world space canvas

#

if it was just health id just render the quad, but if you have text then might as well use UI

upper pilot
#

Feels weird having 1 canvas per unit, but I like the idea of having it be part of an object with proper position etc

latent latch
#

yeah, it's probably not ideal over instancing them but unless you're rendering hundreds of UIs at a time prob not a big deal

upper pilot
#

I will try and see if it causes issues

#

There is like 30 maybe(canvases) each having 3 small images which show tooltip on hover

fleet flax
#

Hope this is the right place to ask...
Does anyone know how to fix the jittery movement here? The sprites seem to jitter like crazy when moving. I am using rigidbody2D velocity to move and have interpolate set on the rigidbody component. I tried to show all the camera and resolution setup in the video but happy to answer any questions

Whats really strange is that the jitteriness is actually better in this video than on my monitor in play mode too

upper pilot
#

Actually let me try 1 thing, maybe its not as bad as I think

latent latch
fleet flax
# latent latch beyond making sure you're doing the logic in physic updates, and that you are in...

Physics updates? I figured I could just update the velocity in update since the rigidbody is handling the movement. Here is the relevant code

    void Update()
    {
        // Get input axes for movement
        float x = Input.GetAxis("Horizontal");
        float y = Input.GetAxis("Vertical");

        // Create a movement vector from input
        Vector2 movement = new Vector2(x, y) * movementSpeed;

        // Set the Rigidbody2D velocity to move the player in the direction of input
        rb.velocity = movement;
    }
#

I usually dont use rigidbodies for movement this way so its a bit new to me, but wanted to use physics this time if possible

latent latch
#

in the documentation it encourages all calls to the rb component to be done in the physics update

#

input in update is fine though

#

(and more preferred)

fleet flax
#

Moving it to fixed update did slightly improve it I think? But still so much jitter

#

Wish it would come through in the video better. Wonder if the framerate is affecting the severity

latent latch
#

i'd switch that camera mode then to explicitly update in fixed or late update

oblique spoke
latent latch
#

worth a try ;p

fleet flax
#

Oh for sure. I appreciate it

fleet flax
upper pilot
#

Do I need to redo all my sizes again?

oblique spoke
#

Not sure. Pixel stuff I've played with rendered at native resolution and didn't try to have perfect pixels.

fleet flax
#

Getting rid of the pixel perfect camera stuff fixed the issue

#

So weird... guess I'l ljust do 16:9 and call it a day lol

#

Ty

oblique spoke
fleet flax
peak pivot
#

Ok, I'm trying to read the resolution and neither of the values I get from UnityEngine.Screen.width and UnityEngine.Screen.currentResolution.width match the game view.

#

This is what I get

Screen.currentResolution.height = 1440
Screen.width = 648
Screen.height = 1307```
#

Is this not the correct way to read the size of the screen?

proven plume
#

Screen is the window size, resolution is the full resolution reported by the monitor.

peak pivot
#

Yeah but shouldn't screen be the Game view size I've set it to emulate (i.e 1280,x800)

#

What I get out has a greater height than width which isn't even the case for the game view window

proven plume
#

In editor, you may get inconsistent results, especially when emulating a resolution. I expect that emulation means it is rendering to a back buffer of that size, but still displaying it at the actual resolution of the game window. My guess is that Screen ignores the backbuffer and is only reporting window size, but you may need to test that.

peak pivot
#

Resizing the game view does not impact the value I get back

#

Nor does calling SetResolution()

proven plume
#

Is this only in Editor?

peak pivot
#

I can't really test it outside yet as I haven't implemented a way to change the resolution

proven plume
#

Editor gets a bit funky with resolutions. The editor itself is running using Unity and the project runs in a subwindow, so it's not as straightforward as it would seem.

I'd test in build and, if you don't have resolution options yet, you can use command line args to change the resolution at boot. You can also open it as a resizable window.

peak pivot
#

But if it only works outside the editor it wouldn't be useful for what I'm trying to do which is repositioning objects based on resolutions

#

And having to build it out every single time to tweak a value would be.. highly annoying

#

ok, Camera.main.pixelRect does return what I expect

#

Good thing Camera.main isn't aweful these days

open plover
#

Ideally after how many sides would a prism look indistinguishable from a cylinder?

simple egret
open plover
#

Maybe not the best place to post it ur right on that

#

I checked the default β€œcylinder” mesh and it has 20 sides

knotty sun
versed loom
#

Im creating a visual element, but after my implementation i want to be able to inject other codes without modifying my current code. So if i add a button to the visual element, I want another part of the code to add to the same visual element something else. I thought about making a IBuilder interface and then just loop thru all the types in the assemblies and call it. Is this the best approach or is there a better one?

var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            foreach (var assembly in assemblies)
            {
                var types = assembly.GetTypes();

                foreach (var type in types)
                {
                    var builderType = typeof(IBuilder);
                    if (!builderType.IsAssignableFrom(type) || type.IsInterface || type.IsAbstract)
                        continue;

                    var instance = Activator.CreateInstance(type) as IBuilder;
                    instance?.Build(_root);
                }
            }```
simple egret
#

The visual element could register itself to some global list of elements when it is created

#

That way you don't need to use Reflection, just a simple foreach through the list, given that all your visual elements inherit from the same type (you'd put the registration logic in the base class constructor)

versed loom
#

i dont think it will work, because where do u instantiate the visual elements? they still need a notification after my implementation

simple egret
#

You tell us where you instantiate the elements - Unity does it for anything deriving MonoBehaviour, in this case use Awake instead of the constructor

#

There are DI frameworks compatible with Unity, so they do the heavy lifting for you

icy depot
#

Something odd's happening, apparently my scene MainMenu doesn't have any root gameobjects? So I can't do anything to root gameobjects that don't exist... Thank you very much for your time.

leaden ice
icy depot
#

same thing really

leaden ice
icy depot
#

oh

#

i wonder why

leaden ice
#

how come only MainMenu is printing?

icy depot
leaden ice
icy depot
#

oh i think i get what you mean

#

i did the search function to get the logs for each of the three scene debug.logs

leaden ice
#

why isn't it? Is your code saved?

leaden ice
icy depot
#

i should've taken a bigger screenshot, that's my bad

#

each three corresponds to the other three for clarification

leaden ice
#

turn off Collapse

#

and this screenshot still doesn't show that

icy depot
#

oh right i had it on ever since you mentioned

#

ill make better logs

#

collapse is off

#

oh i see why collapse is bad, if they repeat the order is off

leaden ice
#

exactly

#

Anyway do you have any code that is either destroying objects or moving them to different scenes, or perhaps DDOL singletons?

leaden ice
#

check the hierarchy at runtime

#

(assuming your screenshot is from edit mode)

icy depot
#

no destroying/moving or DDOL singletons, here's a screenshot in runtime

#

i'm not actually sure what a DDOL singleton is but since i don't know i'm probably not using it

#

oh, i just looked it up, DontDestroyOnLoad?

#

i don't have any of that, I'm not sure what it is either

icy depot
#

i just realized it's doing at Awake, not sure if that's bad or not, but Settings and Main properly work so this should too right...

#

but here's where it's running

#

i'll try Start for one thing

leaden ice
icy depot
#

oh

#

from Admin in Main

leaden ice
#

Ok yeah it's probably running before the other scenes are fully loaded or initialized

icy depot
#

oh

#

and the reason why it always hits MainMenu is because Unity loads scenes in some order

#

now it makes sense

#

let me try Start()

#

yep, it works

#

thank you praetor!

#

i'll be mindful of Awake() in the future

unborn fern
#

How can i check if mouse is over a specific ui element using the new input system?

rigid island
#

doesnt Event System use a raycast regardless?

#

check the component on the raycasted elements

crisp minnow
#

With 2d sprites I want the little circle that's selected to show above the bigger one that owns it. When I skew the scene view sideways the sprites show up but they're being hidden when it's the proper ortographic camera... is it the hierarchical order that's causing this? What solutions are available to me?

rigid island
unborn fern
#

does the new input ui system not have something like the old event system?

rigid island
unborn fern
rigid island
unborn fern
#

no

#

it didint work when i tried

rigid island
#

did you update the Input module already ?

unborn fern
#

yeah

rigid island
#

on event system

unborn fern
#

yeah i did

rigid island
#

it should work afaik

#

is the code before the if statement running, put log before if statement

unborn fern
rigid island
#

you put this script on the UI item ?

unborn fern
#

yeah

crisp minnow
#

With 2d sprites I want the little circle

rigid island
unborn fern
#

trust me, there is only 4 elements and they are not even close to each other

rigid island
#

well sometimes people make the rect transform huge without noticing

unborn fern
#

just checked and it doesnt look like it

rigid island
#

can you show the rect transforms / scene setup

unborn fern
#

yeah just a second

rigid island
#

your exact code

unborn fern
#

tf

#

alright ima check again

#

im literially trying right now and its not working

#

WHYYY

#

thanks for the help,
still not working but ima try to do it myself

rigid island
#

idk why i never seen your setup lol

unborn fern
#

so a single image on the ui

rigid island
#

show the hierarchy and the canvas inspector

unborn fern
unborn fern
rigid island
#

waht about Event System too why not

unborn fern
rigid island
#

well shit..

#

im at a loss here lol

unborn fern
#

THATS WHAT IM SAYINGGGG

simple egret
#

Expand the last component, it's collapsed

rigid island
#

hmm looks same as mine at least from here

#

mind boggling

simple egret
#

Looks fine to me. Do you have any actions in your Input Actions Asset that could somehow override all the "UI/*" paths here?

unborn fern
#

def not

rigid island
#

did you put the interface ? (IPointerEnterHandler) in the Script right ? cause you sent Test before and this new script

unborn fern
#

i didnt even change the ui section

rigid island
#

ok good

simple egret
#

Add logs in your script's Awake, OnEnable, OnDisable, OnDestroy. Make sure you have only the first two

somber nacelle
#

make sure you also aren't possibly hiding regular logs from the console

unborn fern
rigid island
#

are you sure they arent just hidden in that mountain of logs then ? lol

unborn fern
#

and 2 more appeared when stopping the game

simple egret
#

Yeah so this script is getting activated

unborn fern
#

yeah it def is

rigid island
# unborn fern

also always include the name of the component in your logs

unborn fern
#

right sorry

#

i just did a quick log

#

and typed anything to just check if its working

#

omfg im gonna combust internally

#

it was because my cursor was locked in the middle, even though i could move it when clicking escape

#

OPASNDP AJNSPDPAOSJND OP

#

thanks yall

#

im dumb XD

rigid island
#

lol

#

I didn't even think about asking for locked cursor because I assumed how else were you hovering/clicking it and didn't see virtual cursors πŸ₯²

simple egret
#

The editor definitely needs to change the cursor icon when it's in the "editor unlocked" mode, so it can be differentiated from the "runtime cursor lock state" mode

rigid island
#

hugee

#

even a measly dot next to the cursor or something that says Edit mode underneath, I wouldn't mind ..

golden garnet
#

Quick question: do scripts also get disabled when an object is culled by occlusion culling, and if not, can I do that manually?

somber nacelle
golden garnet
#

found out that renderer.isVisible can tell as well

#

don't know if calling that every fixed frame would be a performance boost though

leaden ice
#

the callbacks mentioned by box are your best bet

golden garnet
#

right now im simply running

    {
        if (render.isVisible)
        {
            transform.Rotate(Rotation * Time.deltaTime);
        }
    }```
#

I'm trying to see if doing this will be a performance boost, since culling and freezing rotating platforms at the same time sounds pretty good, but in testing i have not found a clear difference.

cosmic rain
golden garnet
#

Honestly not really, my game spikes sometimes to 30fps for a frame or two randomly but that almost never happens when built

#

I was just curious for the most part

leaden ice
#

You'll want to use the profiler to measure performance before and after the change

golden garnet
#

I see no big change, however I'd still like to keep what would be the more performant option.

#

Which I assume would be to stop rotations when the render.isvisible = false, is that a fair assumption to make?

#

I'm just not sure how expensive checking the render every fixed update would be

cosmic rain
#

Anyways, you should probably not waste time on something that might not make any noticeable difference. Especially if you don't have a problem in the first place.

golden garnet
#

true, I'll be running more tests on my own but I suspect there won't be much different regaredless, as the only thing within the FixedUpdate function is just transform.Rotate

leaden ice
slim trellis
#

anyone here using levelplay ad mediation and have time to help me out with some basic-level issues? i'm currently having issues with podfile generation

flint dagger
#

Does anyone have any good tutorials for getting a silhouette edge of a mesh facing towards a light source?

ornate perch
#

Wacky unity question, I love using the [Header()] function in code blocks, but is there like more things you can use to make your sections better and easer to separate. I kind of wish there were layers to headers
anyone know if this exists somehow

ornate perch
gleaming spire
ornate perch
#

omg that looks amazing

#

now how to install this plugin lol

gleaming spire
ornate perch
#

that makes it far more convinient

rancid frost
#

anyone know possible reasons for why materialpropertyblock isnt changing values?

I am trying to change the offset value via script, but its not working

leaden ice
rancid frost
#

ahh, could probably be it, let me test

chrome trail
#

Is there any way I can access a KeyPair value in a dictionary by index rather than key? Say for instance I know the KeyPair value I want in the dictionary is the 29th one, but I don't know exactly what key would unlock it.

In case someone asks why I'm even using a dictionary at all, I'm doing it because there are other parts (most of them in fact) of the code that need to look by key rather than index. It's just this one specific part that needs to look by index rather than key

leaden ice
#

so there is no "29th one"

somber nacelle
chrome trail
leaden ice
chrome trail
leaden ice
#

or that the iteration order will be stable across platforms etc

chrome trail
somber nacelle
leaden ice
#

Could you explain the use case?

chrome trail
# leaden ice Could you explain the use case?

I have a list of randomly generated rooms and an algorithm that determines where to put exits and the rooms it attaches to (basically a roguelike). I'm specifically looking for the last room made so I can make sure it is the boss room (In debug I can tell which room is supposed to be the boss room after the dungeon is generated and shut off all potential exits the room may have except for one)

leaden ice
#

Could you just keep a reference to the most recently created room always?

chrome trail
# leaden ice Is the room a class?

It was at one point. Now it's a list of direction enums and a Vector3 representing the room's location being used as a key to find that collection of exits

leaden ice
#

Well List is a class

#

So you could just hold on to a reference to that most recently created List

#

whenever you create/add one

#

You can also keep the key around

#

for the most recently added one

#

and get it from the dict

sudden lantern
#

I have a pinch detection for zooming, and I also have a two-finger camera movement. The problem is that both of them conflict with each other. That is, by pinching the camera moves, or I move the camera and the pinch action occurs. How can I protect from this?

Pinch:

public static float CalculateMobilePinchDifference()
{
    Touch touch0 = Input.GetTouch(0);
    Touch touch1 = Input.GetTouch(1);

    Vector2 touch0PrevPos = touch0.position - touch0.deltaPosition;
    Vector2 touch1PrevPos = touch1.position - touch1.deltaPosition;

    float prevMagnitude = (touch0PrevPos - touch1PrevPos).magnitude;
    float currentMagnitude = (touch0.position - touch1.position).magnitude;

    float difference = currentMagnitude - prevMagnitude;

    if (Mathf.Abs(difference) > 10f)
    {
        return difference;
    }

    return 0;
}

Two fingers move:

if (Input.touchCount == 2)
{
    Touch touchZero = Input.GetTouch(0);
    Touch touchOne = Input.GetTouch(1);

    if (touchZero.phase == TouchPhase.Moved || touchOne.phase == TouchPhase.Moved)
    {
        Vector2 touchDelta = (touchZero.deltaPosition + touchOne.deltaPosition) / 2;
        
        float moveSpeed = _parameters.speed;
        Vector3 direction = new Vector3(-touchDelta.x, 0, -touchDelta.y);
        input = direction * (moveSpeed * Time.deltaTime);
        input = Vector3.ClampMagnitude(input, 2f);
    }
}
leaden ice
#

To do the comparison you would compare the deltas with Vector2.Distance(deltaOne, deltaTwo) and check if that value is within a certain threshold.

#

also for a pinch - the two deltas should be in opposite directions.

#

or in mathematical terms - their dot product should be negative,

sudden lantern
past raven
#

am i stupid or something? this code wont change my static variable:

#

private void OnTriggerEnter2D(Collider2D other)
{
Debug.Log(CameraFollows.leftLimit);
if (other.CompareTag("Player"))
{
CameraFollows.leftLimit = 25f;
CameraFollows.rightLimit += 37f;
}
Debug.Log("leave "+CameraFollows.leftLimit);
}

knotty sun
tawny elkBOT
past raven
knotty sun
past raven
#

oh is that why

knotty sun
#

I would have thought it was obvious. If the values are not changing then the other tag is not Player

past raven
#

ah yes

#

you got it

#

it's not finding the object with the tag

#

weird tho it works fine in another script

leaden ice
#

The code is just one part of the puzzle

#

The setup of the objects in the scene is also important

past raven
#

hm that's super weird

#

other.gameObject.CompareTag doesnt work

#

other.gameObject == GameObject.FindGameObjectWithTag("Player"); doesnt work either

#

all 3 work in other scripts

leaden ice
#

And see what you're working with

#

Print the object's name while you're at it too

#

It's not working because the tag isn't Player. You should see what the tag actually is, and which object you're colliding with

past raven
#

Debug.Log(other.gameObject.tag); doesnt work

leaden ice
#

Wdym by "it doesn't work"

#

It works fine.

past raven
#

doesnt print out anything

#

should it be other.tag

leaden ice
#

You put it inside the if

#

Put it outside the if

leaden ice
#

Is it not printing at all, or is it just printing emptiness

#

Those are two different things

knotty sun
#

iirc an object with no tag prints 'UNKNOWN'

leaden ice
#

Untagged

past raven
#

o snap it says Untagged

leaden ice
#

Yeah

#

So why don't you print the name now

past raven
#

ah it's triggering the weapon in front of the player

#

weird how it doesnt then trigger the player afterward

#

can i get a fix for this plz

#

cuz technically my guy can walk backwards

#

so im fucked

#

any fixes?

#

should i make the collider bigger

pastel patio
#

Hi guys, I'm having trouble with enemies having the ability to make a decision one more time after triggering an animation- Like here below

Frame 0

  • Enemy can act, it makes a choice
  • Enemy decides to attack
    • Enemy can't act in the attack animation
  • Animator starts transitioning to attack animation state

Frame 1

  • Enemy can act, it makes a choice (again)
  • Enemy decides to attack, an extra attack gets queued
  • Animator finally applies the changes by the attack clip, enemy can no longer act

Frame 2

  • Enemy can't act
  • Attack animation is playing

Which ways are there to fix this?

#

I can currently only come up with:

  • A bool that stops them from deciding the next frame
  • An animation state machine, but it makes the variables of a clip scattered across different locations
austere iron
#

hi, in Unity 6, how do I switch from script to a specific build profile by its name ?

plucky inlet
pastel patio
#

The problem is that the animation influences everything like their movement speed, whether they can perform actions etc, but these variables are 1 frame too late in update

plucky inlet
#

You could generate a generic async task/method that waits for a passed in callback parameter before continueing/finishing and removing itself from the queue and starting the next action or just restarting the decision making process based on the new values

pastel patio
#

Sorry, thinking about the implications atm...

#

Pros/Drawbacks, yk

plucky inlet
pastel patio
#

Which might actually be cleaner than my current approach

#

Actually in one way, it could be made to act the same way as the current one, since mine is just making a single choice whenever it can

plucky inlet
#

And you can easier debug the whole cycle without guessing, what state it is currently in by just knowing, its Task 1 from the List<Task> with a count of 5 or whatever number. Only thing using tasks or async in general is to be aware of knowing threading and what is possible on background threads and what is not, depends on how you gonna implement it. You can also just have async voids and dont use tasks at all too. But thats up to you

past raven
#
 transform.position = Vector3.Lerp(startPos, new Vector3(Mathf.Clamp(endPos.x, leftLimit, rightLimit), 
            Mathf.Clamp(endPos.y, bottomLimit, topLimit), -10), percentComplete);
#

this isnt working

#

for clamping my camera

dusk apex
# past raven this isnt working

You've got a lot going on there.
What isn't working?
Do the operations separately and log each component of the equation.
For example:cs var x = Mathf.Clamp(endPos.x, leftLimit, rightLimit); var y = Mathf.Clamp(endPos.y, bottomLimit, topLimit); var endPos = new Vector3(x, y, -10f); Debug.Log($"x: {x}, y: {x}, start: {startPos}, end: {endPos}, before: {transform.position}"); transform.position = Vector3.Lerp(startPos, endPos, percentComplete); Debug.Log($"after: {transform.position}, progress: {percentComplete}");

past raven
#

whats the $ do

#

hm thats really weird

#

seems the camera uses different coordinate values than the objects

#

does anyone know anything about that

dusk apex
past raven
#

thx

neon plank
#

Any idea what could be producing this crash and how to fix it? It looks like a problem in a memory allocator, but I don't understand much.
https://pastebin.com/wLs5yhrW

cosmic rain
#

There aren't many other reasons for an allocation to fail

neon plank
#

I don't think so, I have 32 GB of RAM. Thought next time I get it will try to have openend the task manager

cosmic rain
cunning burrow
#

I keep getting Firebase.FirebaseException: Missing debug token

    #if UNITY_EDITOR
    private const string debugToken = "MEOW";
    #endif

    public void Awake()
    {
        #if UNITY_EDITOR
        DebugAppCheckProviderFactory.Instance.SetDebugToken(debugToken);
        #endif
    }```
```cs
public static void IntegrityCheck()
    {
        #if UNITY_EDITOR
        FirebaseAppCheck.SetAppCheckProviderFactory(DebugAppCheckProviderFactory.Instance);
        #elif UNITY_ANDROID
        FirebaseAppCheck.SetAppCheckProviderFactory(PlayIntegrityProviderFactory.Instance);
        #elif UNITY_IOS
        FirebaseAppCheck.SetAppCheckProviderFactory(AppAttestProviderFactory.Instance);
        #endif

        FirebaseAppCheck.DefaultInstance.GetAppCheckTokenAsync(false).ContinueWithOnMainThread(task =>
        {
            if (task.IsFaulted)
            {
                Debug.LogError("Failed to get App Check token: " + task.Exception);
            }
        });

        FirebaseAppCheck.DefaultInstance.SetTokenAutoRefreshEnabled(true);
    }
#

According to docs this is all there should be to it

leaden ice
steep herald
#

do we have access to the API unity uses in the mesh importer to merge vertices/rebuild mesh in function of a target angle for normals smoothing?

More specifically, the normals checkbox in the importer where you can choose to either import from the mesh or generate within unity

cunning burrow
# leaden ice Where and when is IntegrityCheck() running? Are you sure it's not happening befo...
public void Awake()
    {
        #if UNITY_EDITOR
        DebugAppCheckProviderFactory.Instance.SetDebugToken(debugToken);
        #endif
    }

    public void Start()
    {
        RedTTGLogin.Initialize();
//...
    }```

```cs
public static void Initialize()
    {
        IntegrityCheck();
        InitializeFirebase();
        configuration = new GoogleSignInConfiguration
        {
            WebClientId = GoogleWebClientId,
            RequestIdToken = true,
        };
        PlayGamesPlatform.Activate();
        _initialized = true;
    }```
cunning burrow
cunning burrow
#

if I skip that set of code auth fails saying permission denied, so that doesn't work idk what to do

leaden ice
#

Also wait - surely this isn't correct?

private const string debugToken = "MEOW";```
cunning burrow
cunning burrow
#

I have it with the lines as firebase console gave it to me

leaden ice
#

Meaning your code doesn't actually say "MEOW"?

cunning burrow
leaden ice
#

ok good

#

I'm not sure tbh

#

Seems ok at a cursory glance

cunning burrow
leaden ice
cunning burrow
elder marsh
#

anyone know a nice way of getting the material from either a Image renderer or Sprite Renderer and ignoring what type they are? i just want to get / set the material

leaden ice
#

Although actually Image is not a renderer afaik

elder marsh
#

nope image is not a renderer and therefore my question T_T

leaden ice
#

You could do something like:

void ExamineMaterial(Component c) {
  if (c is Renderer r) {
    mat = r.material;
  }
  else if (c is Image im) {
    mat = im.material;
  }
  else {
    // explode
  }
}```
elder marsh
#

that is something i can try. thank you

cunning burrow
# leaden ice I'm not sure tbh

well restarting unity fixed it, however there are still ```SignInAnonymouslyAsync encountered an error: System.AggregateException: One or more errors occurred. (An internal error has occurred.) ---> Firebase.FirebaseException: An internal error has occurred.
at Firebase.Auth.FirebaseAuth.SignInAnonymouslyAsync () [0x0002c] in /home/runner/work/firebase-unity-sdk/firebase-unity-sdk/linux_unity/auth/swig/Firebase.Auth_fixed.cs:3544
--- End of inner exception stack trace ---
---> (Inner Exception #0) Firebase.FirebaseException: An internal error has occurred.
at Firebase.Auth.FirebaseAuth.SignInAnonymouslyAsync () [0x0002c] in /home/runner/work/firebase-unity-sdk/firebase-unity-sdk/linux_unity/auth/swig/Firebase.Auth_fixed.cs:3544 <---

thick terrace
dawn nebula
#

The values I get from transform.localEulerAngles does not seem to match the values that appear in the inspector.

#

Inspector rotation seems to go from -180 to 180.

#

While the values from transform.localEulerAngles seem to go from 0 to 360 or 0 to -360.

knotty sun
dawn nebula
#

I would like to display the rotation of an object in that -180 to 180 range.

#

Any tips?

knotty sun
#

keep your own rotation in euler angles