#archived-code-general

1 messages ยท Page 267 of 1

dusk apex
#

Or show you where in code.

frail dust
#

Nope, Nothing happens. The only thing is if I double click the log, it opens the script. Otherwise nothing is really highlighted

#

shall i send a video

dusk apex
dusk apex
#

Pause the editor during runtime and click the log.

#

I'm assuming you're instantiating objects during runtime and that they do not exist outside of playing the application.

frail dust
rigid island
#

use /* to start commenting out script with error, and */ to end comment.
this way the editor can compile and you can configure your IDE properly .

Also this belongs in #๐Ÿ’ปโ”ƒcode-beginner as you seem to be missing c# fundamenetals

frail dust
dusk apex
#

If the object hasn't been destroyed, it should be highlighted yellow in the scene when the log is selected.

#

Or a prefab would be highlighted yellow if the script was called from a prefab.

frail dust
dusk apex
#

So you're referring to two different objects then.

frail dust
dusk apex
#

I'm going to assume that your bool is from two different objects and that the one you're setting to true isn't the one being checked.

#

Otherwise, you've set it back to false sometime before checking the value.

frail dust
#

there are 5-6 objects using my same script. Out of which some are just Road/lanes itself. The Other one is the PickupObject, and the Spawner GameObject in the heirarchy

shell scarab
#

how do I check static flags of a gameobject? There seems to be only this bool, but there are multiple flags, I expected an enum.

dusk apex
shell scarab
quartz folio
#

Note that they're editor-only

dusk apex
frail dust
dusk apex
#

But ultimately, I was trying to figure out if the bool you're checking is the same as the one you've set to true.

frail dust
dusk apex
#

And they aren't because both components aren't in the scene anymore.

dusk apex
frail dust
#

so what should I approach now

dusk apex
#

If you create 3 lanes, each lane will have their own component scripts that are attached to themselves.

frail dust
#

yes

dusk apex
#

Have someone else manage the data ๐Ÿคทโ€โ™‚๏ธ

frail dust
#

as in?

#

im solo bro haha

dusk apex
#

When you instantiate them, you can provide them the reference to that other objectcs var lane = Instantiate(...); lane.manager = manager;``````cs if(manager.laneCount > 1) { ... }``````cs if(manager.laneIsMoving) { ... }They would all be referring to the manager's data (assuming lane count and lane is moving should be managed as one instance only)

dusk apex
frail dust
frail dust
#

In the beginning:
public LaneManager lane;
void Start()
{
lane = GetComponent<LaneManager>();
}

dusk apex
#

Post inline code using backticks (```) before and after the lines of code or use one of the links below (copy/paste !code to site, save and then post the URL here)

tawny elkBOT
quartz folio
#

Are you kidding

#

!screenshots

tawny elkBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

frail dust
#

okay got it

spring creek
#

Dalphat explained how to do it, and the bot did too. Why screenshot? Just interested in how that decision was made

frail dust
#

imma send u inline

#

public class PickupManager : MonoBehaviour
{
    public LaneManager lane;
    void Start()
    {
        lane = GetComponent<LaneManager>();
    }


    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {


            if (gameObject.tag == "LanePlus")
            {
                if (lane.LaneCount < 6)
                {
                    lane.LaneIncrease();
                    Destroy(gameObject);
                }
                else
                {
                    Debug.Log("Lane Count Exceeded");
                    Destroy(gameObject);
                    return;
                }
            }

            if (gameObject.tag == "LaneMinus")
            {
                if (lane.LaneCount > 2)
                {
                    lane.LaneDecrease();
                    Destroy(gameObject);
                }
                else
                {
                    Debug.Log("Lane Count Minimum");
                    Destroy(gameObject);
                    return;
                }
            }
        }
    }

}
dusk apex
rare turtle
#

I'm hanging during build on this. how do you check what it was doing when it stopped?

frail dust
dusk apex
#

This implies that every object has their own "manager" and that none of these "manager"s are likely referring to each other.

dusk apex
#

So if object A sets his managers bool to true and object B asks his manager if they've set the bool to true, the answer would be no (false) because they've both got different managers.

dusk apex
#

GetComponent implies that this manager is on this object - the object that has been destroyed.

frail dust
#

yes

dusk apex
#

Consider having the manager elsewhere and assigning this object's reference to the manager when it's instantiatedcs var consumable = Instantiate(...) consumable.manager = manager;

frail dust
#

Like attaching it to a gameObject in hierarchy right?

dusk apex
frail dust
#

it already is

dusk apex
#

When the objects are spawned, tell the object who the manager is.

frail dust
#

how do i tell them that which reference is the actual manager

dusk apex
frail dust
#

its on both

#

the object which is destroyed is a prefab

dusk apex
# frail dust its on both

It shouldn't be on the object that's destroyed. And they're instances of a prefab, not the actual prefab.

frail dust
#

i see

dusk apex
frail dust
frail dust
dusk apex
frail dust
#

yeah

dusk apex
#

In your case, I'm assuming you're wanting to share the bool between the lanes.

frail dust
#

yes

#

so they know if they can move

#

only after instantiating

dusk apex
#

Yeah, so have the component/script that's holding the bool not be on them but be shared to them.

frail dust
#

My coding is very redundant

dusk apex
frail dust
#

reference should be included in the Object's script or the LaneManager

dusk apex
#

I think you've already got a lane variable in pickup manager.

frail dust
#

Yes thats the reference

#

of LaneManager

dusk apex
#

You just need to assign the manager to that when you spawn the object with the pickup manager component.

dusk apex
frail dust
#

oh

#

so instead of putting the reference in the start

#

i should reference it the line where it instantiates?

dusk apex
#

The component isn't the same component that all the other pickup managers have.

frail dust
#

I see

#

I have another script

#

PickupSpawner

#

Which only instantiates them

#

doesnt manage collision

dusk apex
#
        if (colliders.Length == 0)
        {
            int randomObject = Random.Range(0, pickupPrefab.Length);
            var pickup = Instantiate(pickupPrefab[randomObject], spawnPosition, Quaternion.identity);
            pickup.lane = laneComponentThatShouldBeOnThisObjectOrAnother;
        }```
#

Where you'd remove the lane assignment in the Start method of the pickup manager (it's not really a manager of all pickups but just one single pickup instance)

#

Where laneComponentThatShouldBeOnThisObjectOrAnother would be a component on this object or some other object that persists.

#

That would be shared by reference to each and every instantiated new object with the pickup component.

#

You'd only be able to access pickupPrefab's lane field if you've referenced the game object by it's component.cs public PickupManager[] pickupPrefab;

#

The reference laneComponentThatShouldBeOnThisObjectOrAnother would be either assigned through the inspector, get component or given to it like how it's passing the data to the instantiated objects - referencing through the inspector is preferred.

wheat cargo
#

Is it technically possible to run .NET 8 code by compiling it into a NativeAOT library and then P/Invoke into the library?

cosmic rain
#

If it's a native library, what's the point? It's probably gonna get compiled into the same thing anyway

wheat cargo
cosmic rain
#

But it's all just syntactic sugar. Are you going to write the whole project as a library or something?

wheat cargo
#

And it's not just syntactic sugar right? .NET 8 code will run faster, since the .NET team has been heavily focused on performance the past several years

#

The only downside I see, is that it has to be compiled for every architecture and most likely won't work on every platform

#

I think it should work on Windows though

cosmic rain
wheat cargo
jagged snow
#

Is there a way I can make a variable but allow it to be modified by sources outside of its class?

knotty sun
#

make it public

jagged snow
#

i dont want the class its in to be able to modify it

knotty sun
cosmic rain
wheat cargo
jagged snow
#

basically I have an inventory class that holds the information about it but these classes are in two different assemblies

knotty sun
#

no, a class will always have read/write access to it's variables

wheat cargo
jagged snow
cosmic rain
thin aurora
#

Init doesn't work in Unity afaik, unless the newer version supports it

#

.NET 6+ only feature, not .NET Standard

jagged snow
wheat cargo
shell jacinth
#

i need help making a mesh for a procedural generation map i am making

#

my brain melts

wheat cargo
shell jacinth
#

so this is what i need to make mesh out of

#

this part is where i am struggling

cosmic rain
thin aurora
cosmic rain
wheat cargo
#

It won't compile the whole runtime, it trims what it does not use

#

It even will have its own garbage collector

#

To Unity, it has no idea it is even calling "C# code"

dusk apex
# frail dust whats the `lane` field

Your field that would increase count and whatnot. You wouldn't want it to be destroyed with the spawned object so have it on a different object and just pass/assign a reference to it when you spawn the objects that can be destroyed.

cosmic rain
wheat cargo
cosmic rain
#

Also, as I said previous it does actually impose many limitations. It doesn't create a runtime environment, it compiles to native code.

Native AOT apps have the following limitations:

No dynamic loading, for example, Assembly.LoadFile.
No run-time code generation, for example, System.Reflection.Emit.
No C++/CLI.
Windows: No built-in COM.
Requires trimming, which has limitations.
Implies compilation into a single file, which has known incompatibilities.
Apps include required runtime libraries (just like self-contained apps, increasing their size as compared to framework-dependent apps).
System.Linq.Expressions always use their interpreted form, which is slower than run-time generated compiled code.
Not all the runtime libraries are fully annotated to be Native AOT compatible. That is, some warnings in the runtime libraries aren't actionable by end developers.

https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=net8plus%2Cwindows#limitations-of-native-aot-deployment

wheat cargo
knotty sun
#

This is the kicker
'Windows: No built-in COM.'

jagged snow
#

This is what I have atm

                            _inventory.ModifyInventory(ItemType.Ammo, interactable.GetValue());
                            _gunHandler.TotalAmmo = _inventory.Ammo;
                            break;```
wheat cargo
knotty sun
#

class ??

wheat cargo
#

Sorry lmao

jagged snow
wheat cargo
jagged snow
cosmic rain
jagged snow
wheat cargo
#

You also don't need the lambda that wraps the method. This works:

_gunHandler.OnTakeAmmo += _inventory.TakeAmmo;
cosmic rain
jagged snow
#

PlayerMaster

cosmic rain
#

So a third assembly?

jagged snow
cosmic rain
#

Just curious, but what are you trying to achieve by splitting your code base into so many assemblies?

jagged snow
#

The thing is it's not a one way variable. When the gunHandler reloads it needs to modify the AmmoCount too

jagged snow
wheat cargo
cosmic rain
wheat cargo
#

Yeah unless your project starts to get large, splitting into assemblies isn't really worth it

jagged snow
cosmic rain
#

I see

jagged snow
#

I think what I need to do is actually create a struct containing the data, and as the values get modified

#

Both sides know the value

#

Maybe a class

#

No events will be needed this way

cosmic rain
#

You'd need some commonality between the assemblies. If each define their own data structure, I feel like they're gonna collide.

jagged snow
#

The concern is that if I go with the common class PlayerStats

#

theres alot of info on there that GunHandler doesnt need such as Health,Movespeed etc

#

should I be concerned about that?

#

Its a cheap way to sharea variable without having to set up events though

cosmic rain
#

Like GunInfo

jagged snow
#

Should I make it a struct?

wheat cargo
#

Probably makes more sense to be a class tbh

jagged snow
#

ill give it a shot thanks

wheat cargo
# cosmic rain Also, as I said previous it does actually impose many limitations. It doesn't cr...

Sorry I missed this message earlier. Yes it does impose many limitations, but it could be beneficial for use cases inside of those limitations.

I could be wrong with how I was wording it, but what I meant is this:

Let's say there have been substantial improvements with http requests and the List class since .NET Standard 2.1

And I have a method that makes a HTTP request and processes the data. If I move that code into a .NET 8 NativeAOT library, then when Unity calls the method natively, it benefits from all the improvements made to http requests and the List class since .NET Standard 2.1.

dense swan
#

Hello, in NavMesh.CalculatePath() and NavMesh.SamplePosition() there are area bitmask parameter. What is that?
The example use NavMesh.AllAreas but what does that mean? I can't find info about this.

I'm using NavMeshSurface to generate my navmesh, is there a way to use specific NavMeshSurface?

wheat cargo
#

Also I don't know what's up with the docs with that page, some versions have it, some don't

#

Like its missing from 2022.3 docs, but is in 2023.1 docs

#

And then missing again for 2023.2 and after

dense swan
#

Ah thank you. looks like it's not what I think it is.

tropic kiln
#

Heya, so I'm trying to implement dynamic LOD for GPU instanciated objects (grass blades). I opened my original lod0 grass blade and just removed a few vertices for each of them in blender (Note by all means I am useless at blender). I imported them and set em all up but I'm having this weird issue during my shader animation. Bit counter intuitive but left to right is lod5 -> lod0. Thanks very much all!

late lion
steady sand
#

Hi all. I'm implementing a custom render pass, drawing objects to a seperate render texture using an orthographic box around the camera, however, there seems to be some issues with the ortho matrix where it seems the near plane is set at a distance of zero from the camera, rather than extending backwards like I want. I'm sure unity allows a negative near plane for ortho matrices, but for some reason it seems to either be clamped at zero for me. Heres a code snippet where the view/projection mats are created alongside the culling if that helps: ```//Create view and projection matricies
float size = voxelSceneSize * 0.5f;
Matrix4x4 viewScene = Matrix4x4.Translate(camData.camera.transform.position);
Matrix4x4 projectionScene = Matrix4x4.Ortho(-size, size, -size, size, -size, size);

        ScriptableCullingParameters cullParams;
        if (camData.camera.TryGetCullingParameters(out cullParams))
        {
            cullParams.cullingMatrix = projectionScene * viewScene;
            cullParams.isOrthographic = true;
            cullParams.cullingOptions = CullingOptions.None;

            //Set culling planes
            Plane[] planes = GeometryUtility.CalculateFrustumPlanes(cullParams.cullingMatrix);
            for (int i = 0; i < 6; i++)
            {
                cullParams.SetCullingPlane(i, planes[i]);
            }
            
            CullingResults cullResults = context.Cull(ref cullParams);```
#

Additionally, heres a short clip. The green box around the camera shows the desired ortho box, but in the output texture its clear that the cubes are clipping right at the camera rather than the back of the box:

#

I'm setting the near plane to -size in: Matrix4x4.Ortho(-size, size, -size, size, -size, size) but it behaves as if its set to zero

#

Thanks in advance

tropic kiln
late lion
tropic kiln
#

Only thing is I didn't change the height of it so using the G channel should be fine tho no?

neon plank
#

How can I draw a rectangle from a point and normal?
As you can see in the image, the following code doesn't create the rectangle with the correct orientation ๐Ÿ˜ฆ

Quaternion quaternion = Quaternion.LookRotation(new Vector3(0.0f, 0.0f, 1.0f), normal);
Vector3 right = quaternion * new Vector3(size, 0.0f, 0.0f);
Vector3 forward = quaternion * new Vector3(0.0f, 0.0f, size);

Vector3 a = right * 0.5f;
Vector3 b = forward * 0.5f;

Vector3 upRight = point + a + b;
Vector3 upLeft = point - a + b;
Vector3 downLeft = point - a - b;
Vector3 downRight = point + a - b;
eager fulcrum
#
WalkableTexture.Release();
WalkableTexture.width = _worldGrid.GridSize.x;
WalkableTexture.height = _worldGrid.GridSize.y;
WalkableTexture.Create();
Texture2D tex = new(_worldGrid.GridSize.x, _worldGrid.GridSize.y);

foreach (var tile in _worldGrid.nodes)
{
    tex.SetPixel(tile.gridPosition.x, tile.gridPosition.y, tile.Walkable ? Color.black : Color.white);
}
Graphics.Blit(tex, WalkableTexture);

Hey, so I'm doing something like this

#

i basically want to make a black/white texutre that represents walkable tiles

#

but for some reason, generated RenderTexture looks like this:

knotty sun
#

tex.Apply() ????????

eager fulcrum
#

thanks !!!!!!!!!!

late lion
late lion
late lion
steady sand
rustic ember
#

I am trying to get the tiles in the tileset. How do I use Resources.Load() to do this?

#

This returns null

#

This is my code cs Sprite loadedSprite = Resources.Load($"{spritesheetPath}_{i}") as Sprite;

knotty sun
#

Put them in a Resources folder

rustic ember
#

The "Sprites" folder?

knotty sun
#

yes, It might help if you went and read the Resources.Load docs

rustic ember
#

Sorry sadok

night remnant
#

Hey, I'm doing a 3D golf game, and I'm trying to recreate the curved ball effect when hit by the club. I pretty much have everything set up, I hit the ball, the ball flies, spins, and curves based on the spin strength. Nice. What I am missing is how to detect if the ball was hit inside-out or outside-in, so I know if it should spin clockwise or counter-clockwise.

#

I need to check the angle between what, direction of the club movement, and...? The ball is stationary so I can't use its position

#

and I can stand anywhere around the ball, even shoot backwards

pliant sapphire
#

Hello everyone, I have a code that when I collide with player that is driver and he drives a car, the other player will be transported on top of that car and he will ride on it and when he wants to get down, he clicks "I" and get teleported down but for some reason when I press "I" it doesnt do anything. Can anyone help? This is happening on line 64-69. This is script: https://hastebin.com/share/mikayugiga.csharp

fervent furnace
#
 private void Update(){
    // Check if the player is on the car
    if (isOnCar){
        // Disable movement and rotation controls while on the car
        return;
    }
pliant sapphire
#

but wont that just make it that he cant move while on carP

#

?*

fervent furnace
#

btw i dont use early return, usually goto the end (if the language supports goto) to prevent missing computation.

private void Update(){
  // Check if the player is on the car
  if (isOnCar){
    // Disable movement and rotation controls while on the car
    return;
  }
  some codes
  if (isHolding && Input.GetKeyDown(KeyCode.I)){
    Debug.Log("Down");
    // If "I" key is pressed while holding, transform the player down
    TransformPlayerDown();
  }
}
proud hare
fervent furnace
#

your code even not running at all

pliant sapphire
#

I changed it, works now. Also does anyone know why my car when he is driving or player when is walking and collides with something like a tree or house he can get trought it even tho everything has box colliders correctly set

knotty sun
#

rigidbodies?

pliant sapphire
#

yes car and player and tree have rigidbodies

knotty sun
#

show inspector of objects

pliant sapphire
knotty sun
#

All your movement and rotation is done via transform which does not respect physics. Switch to Rigidbody only

pliant sapphire
#

so my player and car script needs to change to rigidbody

#

movement

knotty sun
#

yep, if you want physics collisions

hard viper
#

moving transform is a hard teleport. It will go there if you tell it to, even if that puts a box in a wall.

#

and the box will only realize it needs to move during physics simulation step, which can produce strange results.

astral nexus
#

if I load all SceneAssets (only them, not Scene object themselves) into some sort of LevelManager at initialization stage of the game and after that I'll load them as Scene object by some key or so (to avoid strings or ints to load them) - is it bad idea to do it that way?
I'm loading them by Addressables, if it matters

pliant sapphire
meager pendant
gray thunder
#

nice

tawny elkBOT
potent jackal
knotty sun
#

is this script on the shopui gameobject?

potent jackal
#

yes sir

knotty sun
#

Update does not run on deactivated objects

potent jackal
#

oh

#

i didn't know that

#

then how should I check if the player pressed F?

knotty sun
#

you could make an empty parent object for shopui and put the script on that

potent jackal
#

have a great day!

tawdry jasper
#

How can I prevent my npc character controller from moving on top of my player charactercontroller, when the player stands in the npc's way? (I will eventually add specific movement reacting to the player, but I feel like there's something wrong with the capsules, I have the npcs randomly roaming around and they will hop on top of stuff occasionally (even though their step offset is set to 0.1)
center, radius, height are (2.3, 2.3, 2.4) and my player controller is (0.8, 0.3, 1.6)

#

( to allow them moving down slopes I the np'c move with : _controller.Move(Time.deltaTime * (direction + 3f*Vector3.down)) but even with this additional downward move vector they will pop on top of my player if I "harass them", I'd like to make it impossible somehow)

#

(without making my player capsule taller)

hidden flicker
#

Is there a way to get an object's normal without raycast

tawdry jasper
worldly latch
#

Hello, does anybody know if there is a way to make a function execute in edit mode? I've got a custom button in the inspector to change the color of a light source in game, while it works and changes the color in the inspector then when the game starts the color will be changed I would like this to happen in the inspector, I also have this working by adding [ExecuteInEditMode] above the class name but this means I have to have code in update which I would rather this only happens once by using the custom button that calls the function, that was a lot of yapping for a single question my bad

potent jackal
knotty sun
#

obviously not. true + false = false

leaden ice
potent jackal
#

oh, how do I fix it? I'm sorry but I am a beginner

leaden ice
#

Something like:

if (Input.GetKeyDown(KeyCode.F))
{
    shopui.SetActive(!shopui.activeSelf);
}
``` would be expected
potent jackal
#

TY!!!!

worldly latch
leaden ice
potent jackal
leaden ice
#

that's the same code as before

#

You need to change the code to something like I shared above

potent jackal
#

oh sorry

#

i didn't update it

leaden ice
#

You left part of your old code in

#

delete this cs if (Input.GetKeyDown(KeyCode.F)) { shopui.SetActive(true); }

#

you only need the snippet I shared

potent jackal
#

TY!!!

#

๐Ÿ˜„

hard viper
#

NaughtyAttributes is great.

#

we should have more custom editor tools that work like NaughtyAttributes, where you just apply an attribute to modify the editor.

hidden flicker
# leaden ice _which_ normal?

Sorry, I meant a faceโ€™s normal. Aaand by you asking that question I understand why you need to hit it with a raycast. Ty

leaden ice
#

otherwise, the raycast identifies the triangle in the first place and therefore the normal

leaden ice
#

!code

tawny elkBOT
leaden ice
#

Anyway this code should prevent what you said - so something else is going wrong.

knotty sun
#

then why DDOL?

leaden ice
#

My guess is you have "Play On Awake" enabled on the audio source

leaden ice
dawn anchor
leaden ice
#

I think your problem has nothing to do with this code you shared

wispy nacelle
#

How can I stop a certain light to cast on a certain sprite renderer with Light 2D

leaden ice
wispy nacelle
#

thanks

manic lantern
#

In mobile (specifically android), we have a landscape app and the default behavior of Unity when a user taps an input field is to open a tiny floating keyboard instead of the usual, large "docked" one on the bottom of screen. There is a button to change style right on the small floating keyboard to change it back, but users are complaining. Is there some easy way in Unity to just tell it to open the standard docked version of the keyboard?

fair mural
#

anyone have an idea as to why transform.forward isnt making the bullet go forward when a parent has negative y rot?

leaden ice
#

and which objects are referenced by it

fair mural
#

@warm cobalt ^^^

leaden ice
#

playerCam.transform.forward + direction < this "direction" variable is going to alter the direction from camera forward

#

is just 2 random floats basically speaking so it's not really relevant
Why do you think it's not relevant? Seems very relevant

#

Also... you're even incorporating the current facing direction of... some object?
transform.forward + transform.right * randomBloom.x + transform.up * randomBloom.y;

#

this is ... very strange to say the least

#

Btw instead of adding vectors to create random spread, the better way is to rotate the vector

#

it's more controllable/predictable/understandable/effective

fair mural
#

yeah its out of the norm

leaden ice
#

Or - i guess you mean the spread pattern on whatever you hit?

fair mural
#

yeah

leaden ice
#

Either way this calculation seems really off:
return transform.forward + transform.right * randomBloom.x + transform.up * randomBloom.y;

#

specifically - adding transform.forward .. and this isn't even the camera object right?

fair mural
#

thats what i said yesterday

leaden ice
#

Your SpawnLine function also seems off

warm cobalt
#

nevermind, fixed it.

last time when we had an issue similar to this we replaced transform.forward with playercam.transform.forward and it did nothing
so we just assumed to keep it that way.

but that was the fix in this case

fair mural
#

well, thats a question for him. i dont really do the scripting. i do visuals and design

leaden ice
#

When you call it you're passing in... I think a direciton vector?
SpawnLine(origin, playerCam.transform.forward + direction);
But then inside you're treating that like a position:
line.SetPosition(1, hit);

tawdry jasper
#

I think this SpawnLine(origin, playerCam.transform.forward + direction); should be SpawnLine(origin, origin + playerCam.transform.forward + direction) maybe?

warm cobalt
fair mural
#

well thanks for the insight @leaden ice

lament helm
# fair mural

this looks good asf??? whats the name and where can I play it

#

reminds me of pixel gun 3d

fair mural
lament helm
#

valid

#

r u doing any dev logs

#

as u made the game

fair mural
#

well yeah

#

but theyre private now

lament helm
#

ah say no more

unique delta
#

i have an int for coins. When i use coins -= 4 nothing happens. i want to lose coins.

tawny elkBOT
unique delta
knotty sun
#

all of the code

unique delta
knotty sun
#

coins =- 4;
you said -=

unique delta
#

i tried both

#

i don t know why but when i have the coins negative. For example -43 it works.

knotty sun
#

because it is <= 4

#

there is nothing there that decrements coins when coins >4

unique delta
#

now it works but when i reach 4 coins it just reamains 4

knotty sun
#

then skillselectedx == true

#

your logs should show exactly which code path is used

unique delta
#

ok

proven wren
#

hello guys, i've got small problem, i donwnloaded animation from mixamo, and problem is that when anim is played avatar's position is changed, i want to play anim in a way that avatar's position stays the same, i turned off Root Motion, but still same...

knotty sun
# unique delta ok

you do realize this code makes no sense

 public void skillselect1(){
        
        skillselected1 = true;
        print("1skill");
        if(skillselected1 == true){
            skillselected2 = false;
            print("2skillfalse");
        }
    }
    public void skillselect2(){
        
        skillselected2 = true;
        print("2skill");

        if(skillselected2 == true){
            skillselected1 = false;
            print("1skillfalse");
        }
    }
unique delta
#

thanks i got it anyyways

unique delta
knotty sun
#

no

spring creek
#

Don't do variable1 variable2 ever. Make a list or something. Make a struct or class that contains the necessary information to buy it. Abstract it

unique delta
knotty sun
#
public void Buy(){
    if(skillselected1 || skillselected2)
      if (coins >= 4){
              
        coins -= 4;
        skillselected1 = false;
        print("firstskill");
    }else{
        print("notenoughcoins");
    } 
}
#

your logic is incorrect

#

format your code properly to make it more readable

proven wren
unique delta
#

isn t it the same thing but && transformed in an if

knotty sun
#

that is actially 2 less than he had

unique delta
#

oh ok

knotty sun
#

look at his code, think what happens if skillselected1 is false

proven wren
spring creek
unique delta
#

i know that

knotty sun
unique delta
#

ok i got it thanks

knotty sun
#

see updated code above

rigid island
tawdry jasper
#

I have some npc's using CharacterController and calling controller.Move(some_directionspeeddeltaTime); 1) How do I stop my npc's from climbing on top of each other if they're bunched up against each other? They have 0.1 step offset and still walk over each other. 2) why is my player character controller able to push them? (and when I do push them they clip over each other)? (This one is super weird as I have a different npc setup in almost exact same way (diffrent logic to determine the move direction) and my player character controller CAN't push that one. Would appreciate any pointers on what to look at or how to debug this.

leaden ice
tawdry jasper
leaden ice
#

Also multiple CCs can act weird because they move at different times and they probably don't see each other's new positions due to how the physics engine updates.

#

I have a different npc setup in almost exact same way
Ragdoll Rigidbodies sounds like a very different way than a CC.

tawdry jasper
tawdry jasper
# leaden ice Without seeing the code it's hard to say. One tip is that you need to make sure ...
    void Update() {
        var targetRotation = Quaternion.LookRotation(direction, Vector3.up);
        transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, 40f * Time.deltaTime);
        _speed = Mathf.Lerp(_speed, speed, 1f - _dirchange);
        _animator.SetFloat(_animIDSpeed, _speed);
        _animator.SetFloat(_animIDMotionSpeed, _speed);

        Vector3 move = transform.forward * _speed + Vector3.down * 3f;
        _controller.Move(move * Time.deltaTime);

        if (_dirchange >= 0) {
            _dirchange -= Time.deltaTime;

        } else {
            _dirchange = 1f;
            speed = Random.Range(0.2f, 0.2f);
        }
    }
#

Here's the one that works as expected (doesn't allow itself to be pushed):

    void Update() {
        direction = _stateController.player.transform.position - transform.position;
        direction.y = 0;
        direction.Normalize();

        // turn towards
        Quaternion towardsDirection = Quaternion.LookRotation(direction, Vector3.up);

        float animSpeed, speed;
        float dot = Vector3.Dot(transform.forward, direction);
        if (dot < 0.5f) {
            speed = 0.15f * Time.deltaTime;
            animSpeed = 0.2f * (dot +1f)/2f;
        } else {
            speed = dot * 2f * Time.deltaTime;
            animSpeed = ((dot < 0.8f)? 1f : 1.3f) * dot;
        }
        transform.rotation = Quaternion.RotateTowards(transform.rotation, towardsDirection, Mathf.Max(40f, 20f * 3f - dot) * Time.deltaTime);

        _animator.SetFloat(_animIDSpeed, animSpeed);
        _controller.Move(transform.forward * speed + Vector3.down * 3f * Time.deltaTime);

save for some creazy animation speed manipulation on turning which I should get rid of or cleanup the movement itself is almost the same. So it must be something with the setup of the character controllers?

lost mural
#

Hi, so I am trying to implement an animation of something like this: https://www.youtube.com/watch?v=LXJUYumwh-k. I am working on the color part when the rotating object comes in contact with the stationary object. I basically implemented a collider for each tooth so to speak and I am not sure how to go about it after taht. Is there a way where you change the color of a gameobject based on the percentage of alignment between the two objects?

The changing magnetic field due to the rotation of the rotor in a switched reluctance motor (SRM). This animation was created using MagNet, the electromagnetic simulation software from Infolytica Corp. Read more at http://www.infolytica.com/en/applications/ex0147/.

โ–ถ Play video
heady iris
#

how are you defining alignment?

#

if it's based on distance, then you'll want to measure the distance between two points (probably the position of yourself and of the other collider) and adjust your color based on that

lost mural
#

I am using ontriggerstay but it is not working great because it only fixes on one color

leaden ice
timid depot
#

any idea why Physics.Raycast still detects trigger collision box even tho layer mask is set to collision-less?

leaden ice
timid depot
#
Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, reachDistance, mask)```
#
mask = 1 << 8;
mask = ~mask;```
leaden ice
leaden ice
#

including the "Ignore Raycast" layer

timid depot
#

yes

leaden ice
#

So what's the problem?

timid depot
#

ignore raycast is layer 8

leaden ice
#

It's doing what you told it to do

#

You sure?

timid depot
#

yes

leaden ice
#

show your layers?

#

Pretty sure it's like layer 3

#

Anyway - there's no need to make a custom mask to specifically avoid the Ignore Raycast layer

#

the default layermask already does that

#

so you can simply omit the layermask parameter

timid depot
#

oh you're right

#

its different id than 8

#

but it should ignore it by default when set?

#
mask = 1 << 8;
mask |= 1 << 2;
mask = ~mask;```
#

now it works thanks for your help

rigid island
#

Just set raycast to Ignore triggers

#

no?

#

!code

tawny elkBOT
rigid island
#

use link โซ

tawdry jasper
lost mural
#

So for example this is the code for one of the teeth of the parts https://paste.ofcode.org/Fa5TwReCzyvBjyQJfbh7Gk. The image attached shows the circled gameobject is called north-west and the rectangle object is "other" gameobject. This is the snippet of the code but the same idea can be applied for the other gameobjects. I have an array of colors that TransitionNW goes through in 4 seconds and then it loops through once it is done going through all the colors.

lost mural
lost mural
tawdry jasper
#

Flipping the boolean in on stay seems weird. Triggeronstay will be called on every fixed update until the object leaves the trigger.

worthy island
#

someone can help me to do a system of upgrade with cards? I will post a screenshot to explain better

#

I just want some guide to where to find tutorials about it

#

i dont find any

leaden ice
#

That's a very complicated system that is going to have to tie closely into how your actual combat gameplay and saving/serialization systems work

#

it's not really something you would be able to use a tutorial directly for

#

more like - learn the concepts and roll your own.

worthy island
#

hmm I see

#

thanks

#

do u have some tips to get there?

#

some resources to learn or something

#

I liked a lot that system and i wish so much to introduce in my games

#

its so fun

shell scarab
#

Is this a bug?

[System.Flags]
public enum CellEffect
{
    Open = 0,
    All = ~0,
    AllExceptBlocked = ~0 ^ 1,
    Blocked = 1,
    Mud = 2,
    Storm = 1 << 2,
    Burning = 1 << 3,
}
twin island
#

Why do I have this weird block instead of a line? it's breaking my scripts, how can I fix it?

twin island
#

thanks

tawdry jasper
#

the zombies and sheep use CharacterController with a single call to Move() in their Update() and yet they behave very differently. The zombies seem more "planted", while the sheep very easily bump into the air. Is this something that should work with character controllers or should I ditch the character controller and use rigidbody capsules for the npc's/critters/enemies? I just don't know what I'm missing with the sheep setup that's causing them to behave so differently.

rigid island
tawdry jasper
#

The only 2 diffrences are: the zombies have a ragdoll on them with all rigidbodies set to kinematic, but I don't think that's it as I added a box+kinematic rb to some of the sheep armatures and it made no difference. The other one is I tried to fit the character collider capsule around the sheep which resulted to them being "ball shaped" which kind of explains why they move like balls a bit?

rigid island
#

why not use navmesh agentss

tawdry jasper
tawdry jasper
# rigid island why not use navmesh agentss

I'm thinking of doing that down the road if/when I learn how to use them. Does having a navmesh agent replace the character controller though? I'll still need something on them to collide with?

Plus my issue here is with the sheep: and the sheep can't be navmesh agents cause I want them to use flocking behaviour (ok actually they could be navmesh agents still).

but what would that really solve? maybe I wouldn't have to add the downward vector to their move code?

deft timber
#

Basic tutorial about nav mesh in unity will answer all the questions you just asked

tawdry jasper
#

(I mean the actual issue with the sheep is that they allow themselves to be pushed, will making them navmesh agents solve that? I think navmesh solves a different problem?)

rigid island
#

you make them kinematic with collider

tawdry jasper
#

Well... It's "fixed" as in I figured out why sheep behave different than zombies: they were on different layers, I've put them on the same one and now it works (as I expected too), now my problem is I don't really get why it works since looking at the collission matrix my default and enemies layers look the same to me. But it's on my list of things to cleanup, I have way more layers than I need. (when I started this project I added layers to prevent collisions that I would temporarily reassign objects to, and have since learned I can simply disable the collider)

meager pendant
#

yo

#

what is the equivalent to vector<type> in c#/unity

#

nvm i found it

meager pendant
#

in a 2d topdown game how would i make furniture / items revealed by light

random oak
#

Is this because the physics takes time between processing the rotation?

 private void Awake()
 {
     rPoint = Random.insideUnitSphere * 0.2f;
     //rb.rotation = Quaternion.LookRotation(rPoint, Vector3.up);
     rb.MoveRotation(Quaternion.LookRotation(rPoint));
 }
 //this don't work, always goes to world forward
 void Start()
 {
     rb.AddForce(transform.forward * forceAmount, ForceMode.Impulse);
 }
//this works
IEnumerator Start()
{
    yield return new WaitForFixedUpdate();
    rb.AddForce(transform.forward * forceAmount, ForceMode.Impulse);
}```
lean sail
steady moat
celest iron
#

Hi.
Why does the first time I do the checking it works fine, but the second time it gives me an warning?

while (queue.Count > 0)
{
    var current = queue.Dequeue();

    if (GenerationManager.Tilemap.GetTile(current) is WaterTile)
        return path;

    var neighbors = GenerationManager.GetAdjacentNeighbors(current);

    float value = IslandValue[current.x, current.y];

    foreach (var neighbor in neighbors)
    {
        float currValue = 0;
        
        if (!GenerationManager.Tilemap.GetTile(neighbor) is WaterTile)
        {
            currValue = IslandValue[neighbor.x, neighbor.y];
        }
            
    }
}```
#

The warning is "the given expression is never of the provided type"

#

Which is kinda of odd, as I'm checking for another position, I'm not checking for current again

steady moat
#

Pretty sure it is what your error means

celest iron
#

I know what it means

steady moat
#

Or GenerationManager.Tilemap.GetTile(current)

dusk apex
#

Seeing the actual error would help

#

As it could be one of the other compare statements

steady moat
#

Mostlikely WaterTile does not inherit from the tile class

celest iron
#

It does. The first check works fine, only the second gives me an warning.

steady moat
#

Does WaterTile inherit from TileBase ?

celest iron
#

Yes

#

The first if is fine

steady moat
#

Can you replace the var

#

And give use the return type of the function

#

Oh lol

#

That it is because you are using !

#

Pretty sure you need to do !(...)

celest iron
#

oh

#

OH

steady moat
#

Otherwise it is going to be bool is WaterTile

celest iron
#

Lmaoooo yeee

#

Thanks

#

I didn't realize

somber nacelle
#

you can also use is not

steady moat
#

Does it works on Unity ?

somber nacelle
#

it should in the latest versions

steady moat
#

Maybe I was using an older version

celest iron
#

I totally forgot not was a keyword

dense rock
#

Hey I'm getting a MissingReferenceException: The object of type 'PlayerSpawnManager' has been destroyed but you are still trying to access it.
I have no clue how that happens, not destroying the PlayerSpawnManager anywhere... Can somebody help? Relevant code:

public class PlayerSpawnManager : MonoBehaviour
{
    private void OnEnable()
    {
        PlayerScript.OnPlayerDeath += StartRespawnPlayer;
    }
    private void OnDisable()
    {
        PlayerScript.OnPlayerDeath -= StartRespawnPlayer;
    }
    public void StartRespawnPlayer()
    {
        StartCoroutine(RespawnPlayer());
    }
}

public class PlayerScript : MonoBehaviour, ICanDie
{
    public delegate void PlayerDied();
    public static event PlayerDied OnPlayerDeath;
    public void TriggerDeath(DeathCause causeOfDeath)
    {
        OnPlayerDeath?.Invoke();
    }
}

public class DeathZone : MonoBehaviour
{
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.TryGetComponent(out ICanDie entity))
        {
            entity.TriggerDeath(DeathCause.DeathZone);
        }
    }
}

pls ping me with answers

cosmic rain
dense rock
#

sry one sec

#
Your script should either check if it is null or you should not destroy the object.
UnityEngine.MonoBehaviour.StartCoroutine (System.Collections.IEnumerator routine) (at <10871f9e312b442cb78b9b97db88fdcb>:0)
PlayerSpawnManager.<OnEnable>b__17_0 () (at Assets/_Scripts/Managers/PlayerSpawnManager.cs:74)
PlayerScript.Die (PlayerScript this) (at Assets/_Scripts/Entity/Player/PlayerScript.cs:105)
PlayerScript.TriggerDeath (PlayerScript this, DeathCause causeOfDeath) (at Assets/_Scripts/Entity/Player/PlayerScript.cs:100)
DeathZone.OnTriggerEnter2D (DeathZone this, UnityEngine.Collider2D other) (at Assets/_Scripts/Environment/DeathZone.cs:16)```
cosmic rain
#

Share the whole PlayerSpawnManager in a code paste site !code

tawny elkBOT
dense rock
celest iron
#

What happens when the player dies? Or was supposed to happen.

dense rock
#

atm it only calls Destroy(this.gameobject);
besides invoking the event

celest iron
#

You should always check for nullability in OnTriggerEnter

#

When you destroy a game object in it

dense rock
#

oh interesting, i didn't know that

#

ill test it

woeful sigil
#

Can someone gelp

#

when i try to add a mod vent the vent goes away but the colider dosent Help?

dense rock
celest iron
#

๐Ÿ‘

lean sail
woeful sigil
lean sail
#

its the same thing as a mod vent. I have no clue!

woeful sigil
#

ok thanks

lean sail
#

From a quick google search, i assume you're modding a game. Modding isnt really allowed here though, so ask in the game's related community

cosmic rain
#

I'd say that they need a plumbus.

dense rock
#

another question i have: Is there a way to freeze the game while still having coroutines with time working? Or is there a workaround for timed methods?
with freezing the game i mean player, enemies their animations etc.
Maybe would be good to still have UI animations playing

woeful sigil
celest iron
#

@woeful sigil could you please be more specific in your question? We don't understand what you are asking.

plain spire
#

how can you write to the shadow map?

cosmic rain
#

If you want to pause some objects is setting Time scale, but that's considered a bad practice. The recommended way is to have a pause system integrated into all your game logic.

cosmic rain
latent latch
#

i think I remember looking into it and basically you dont

soft shard
# dense rock another question i have: Is there a way to freeze the game while still having co...

To expand on dlitch comment, the approach I use in my game is a enum that determines my games state in a static class, that static class has a public property with a event things can sub/unsub to (similar to a Observer pattern), so for example, when a enemy spawns they can call GameManager.onGameStateChange += DoSomething;, then "DoSomething" takes the GameState enum and I can do things like gameObject.enabled = state == GameState.Playing, I can also toggle input for certain UI this way, and for classes that dont use Update/coroutines/unity events I can setup a local bool to be toggled based on the event, this is what works fine for my game, maybe this approach can give you some ideas

heady iris
#

that's exactly what I did!

jagged snow
#
    public Gun LongGun;
    public Gun HandGun;
    public int LongGunAmmo;
    public int HandGunAmmo;
}```
Is this the write naming scheme for LongGunAmmo and HandGunAmmo?
spring creek
heady iris
#

you have that backwards

#

camelCase, PascalCase

#

but yeah, some people use PascalCase for public fields and some people use camelCase

#

I prefer to just use camelCase for fields and PascalCase for properties

spring creek
heady iris
#

don't forget SHOUTY_CASE

meager pendant
#

but for like buildings

jagged snow
#

it was more in regards to the naming scheme rather than casing.

HandGunAmmo
vs
Ammo_HandGun

spring creek
#

The two hardest things in coding are Cache Invalidation, Naming things, and One off errors

spring creek
jagged snow
#

thanks!

rigid island
#

yea, it really does come down to preference (working solo ofc)

icy siren
#

https://paste.ofcode.org/34B8BRAVprQxMVxuHKnDNyG
can anyone look at my player script and tell me what im doing wrong? i'm trying to get the jump to work but it doesn't work at all. the function is being called but it still does nothing. tried bumping up the jumpForce to 100 to see if it was just too low and that didnt do anything either. any help on this?

#

i followed Brackeys video on it almost exactly, except i used the new input system so i had to adjust some things but maybe i didnt adjust them right

spring creek
#

Also, you are multiplying deltaTime by mouse input

#

Ah, I see you said Brackeys, yeah. Classic Brackeys error

icy siren
#

sorry where am i using the rigidbody?

spring creek
icy siren
#

ah

icy siren
spring creek
#

I'm seeing two Move calls though? This is pretty convoluted

icy siren
#

idk man its just what he had in the video

spring creek
icy siren
#

okay ill look at that later then. any ideas for the jump

spring creek
#

Is the "Velocity inside Jump" debug showing up?

icy siren
#

yea the function is being called

spring creek
#

Oh, I bet it's the first if in Update

#

You are setting playerVelocity.y there, and that would happen after the callback

#

No, nevermind. That is only when under 0...
So back to wondering what value it shows

icy siren
#

logs of when i hit the jump button

spring creek
#

Ok, you see the issue?

#

Specifically the "Velocity after adding gravity" part?

#

It's negative by the time you do the Move where you pass in the jump call.

icy siren
#

yea i saw that. just having trouble figuring out how to get that part to work

#

fixed it

mossy gust
#

you know in games like getting over it, where you can use the arms to crawl around, and they move accordingly to how you drag your mouse around, like retracting and stuff

How could I replicate that in 2d?

astral nexus
#

how do I approach scene management without strings? I made a wrapper object of ScriptableObject type to store all scene data in it per level, store them in a List, but I still need somehow find a way to find them in the List by some sort of key passed in a Load method without strings, cause they are too error prone and not flexible as a key
it's so basic problem (I think), but I struggle with "non-string" solution

knotty sun
#

you could use an enum

knotty sun
lean sail
heavy kernel
#

hi - we're using build automation in devops to cook multiplatform builds, using BuildPipeline.BuildPlayer(options); etc - this works fine but on windows it produces an executable file without ".exe" on the end, which confuses people we share with - is there a way to control the output executable file as part of the options?

knotty sun
tidal horizon
#

Need some help about input on unity

opal pine
#

Hey guys. Any reason why the below code with start at the camera then point towards the ground? I thought transform.forward would keep the same Y axis and put the line staight infront of the camera.

Gizmos.DrawLine(Camera.main.transform.position, Camera.main.transform.forward * 10);
cosmic rain
#

Forward is a direction, not a position

#

Use draw ray if you want to use a direction

opal pine
#

Thanks. Thats for my debugging but I cant see why im not triggering my debug when hitting a collider...

#

nvm. Using a 2d collider in a 3d game and wouldnt find the 2d. Thanks for helping cause now I can continue debugging.

tight ice
#

Why might my Capsule be flying all over the place when a HingeJoint is created upon collision?
Note: The flying all over the place only happens when I am holding a movement key (WASD) at time of collision. Otherwise, it behaves stable-y.

rigidbody characterController Smoothy.cs https://hastebin.com/share/epemenawur.csharp
MyKeyInput.cs grabs keyboard input https://hastebin.com/share/ozaxiwehon.csharp
^ -- these are the only two scripts on the Capsule

BarLogic.cs is the script on the bar that the Capsule collides with before Capsule goes crazy https://hastebin.com/share/owecezekaj.csharp

Gif of issue: https://i.imgur.com/skB5tWk.gif

also, if the issue is because of anything in Smoothy.cs being active at the time of collision, this confuses me because in BarLogic.cs I am disabling Smoothy.cs upon OnTriggerEnter. so how could it possibly be a problem with code in Smoothy.cs if colliding with the bar should instantly disable it? (I'm noticing that if I remove the //Rotation code in Smoothy.cs that this spazzing out & flying around doesn't consistently happen anymore, but since I'm already telling the code via BarLogic.cs to "Disable Smoothy.cs upon colliding with Cube", I don't know what more I'm supposed to do.)

proven plume
sharp acorn
#

I've got a GameManager with DontDestroyOnLoad that checks which Scene has been loaded and starts an initializing routine on it's specific manager:

{
    switch (scene.buildIndex)
    {
        case 1: //overworld
            StartCoroutine(OverworldManager.Instance.Initialize(playerPosition, timeOfDay, map, entryPoint, overworldSceneCode));
            break;
    }
}```
But when I initialize it on OverworldManager, it gives me an error on this line:
```public IEnumerator Initialize(Vector2 playerPos, TimeOfDay timeOfDay, string mapName, string entryPoint, string overworldSceneCode)
{
    yield return 0;
    pathfindingInjector = GetComponent<PathFindingInjector>(); <--
    yield break;
}```
```MissingReferenceException: The object of type 'OverworldManager' has been destroyed but you are still trying to access it.```
sharp acorn
#

Btw, the second code snippet is being executed in a component of the object that has been destroyed, what am I missing?

fervent furnace
#

your game manager is ddol
how about your OverworldManager

sharp acorn
#

It ain't

#

But the switc in OnLoadedScene should assure there is an OverworldManager in the scene

#

Also, this was working perfectly yesterday xD

knotty sun
#

wrong overworldmanager

sharp acorn
#

There is only one in that specific scene

knotty sun
#

no, you misunderstand
the game manager is refering to the overworldmanager in the first scene, that no longer exists

sharp acorn
#

So, OnLoadedScene is executing before switching scenes?

fervent furnace
#

the ienumerator is belong to the destroyed manager not the new one
no idea why it worked

sharp acorn
#

Does Awake() execute before OnLoadedScene?

#

In any case, this should fix it, but it doesn't:

{
    switch (scene.buildIndex)
    {
        case 1: //overworld
            OverworldManager manager = GameObject.Find("OverworldController").GetComponent<OverworldManager>();
            StartCoroutine(manager.Initialize(playerPosition, timeOfDay, map, entryPoint, overworldSceneCode));
            break;
    }
}```
#

Well, I also should have said that the OverworldManager is a singleton

fervent furnace
#

it may help
you can have a look

drifting bobcat
#

I'm making a game with randomly generated dungeons, so I made it that when the dungeon is generated the NavMesh is baked, but the doors don't connect for some reason, does anyone know why? (The agent size is small enough for it to connect)

plain spire
#

tried setting it to zero?

drifting bobcat
#

I mean I created by hand 2 rooms and it did connect, I think it has to do something with the generation (Im using DunGen)

#

Here i placed the rooms by hand, and it did connect

#

I set it to zero, also didn't work :/

idle flax
#

Hey everyone, I have an item attribute system that currently looks like this:

[System.Serializable]
public class ItemAttribute
{
    public ItemAttributeType type;
    public ItemAttributeValueType valueType;

    [EnableIf("valueType", ItemAttributeValueType.Float)] [AllowNesting] public float floatValue;
    [EnableIf("valueType", ItemAttributeValueType.String)] [AllowNesting] public string stringValue;
    [EnableIf("valueType", ItemAttributeValueType.Color)] [AllowNesting] public Color colorValue;
    [EnableIf("valueType", ItemAttributeValueType.Vector2)] [AllowNesting] public Vector2 vector2Value;
    [EnableIf("valueType", ItemAttributeValueType.Vector3)] [AllowNesting] public Vector3 vector3Value;
}

public enum ItemAttributeType
{
    durability,
    containerSize
}

public enum ItemAttributeValueType
{
    Float,
    String,
    Color,
    Vector2,
    Vector3
}

I was wondering if it's possible to somehow link each ItemAttributeType enum with an ItemAttributeValueType? For example I'd want the durability ItemAttributeType to be linked with a float ItemAttributeValueType.

unkempt knoll
#

hi, trying to render the gun separately, doesnt render the gun (i know the weapon looks trash, just a prototype)

knotty sun
knotty sun
#

ah, you could be right, culling mask is an inclusive mask

unkempt knoll
#

fixed it, had to put it in the stack

proud juniper
#

Am I missing something, or is UI toolkit not as clean as the legacy UI stuff when it comes to callbacks? Asking because having to query the DOM by element IDs to set callbacks seems like a downgrade from how legacy UI lets you define onclick stuff in the inspector. Is there a better way?

steady moat
idle flax
steady moat
steady moat
# idle flax I'll do that, thanks

Something like the following.

[System.Serializable]
public class ItemAttribute
{
    [SerializeReference]
    public List<IValue> floatValue;
}

[System.Serializable]
public interface IValue 
{

}

[System.Serializable]
public class ValueGeneric<T> : IValue
{
  [SerializedField]
  private T value;
}

public class FloatValue : ValueGeneric<float> {}
public class IntValue : ValueGeneric<float> {}
meager pendant
#

Whatโ€™s the most optimized way to make a 2D light flicker script

modest thicket
meager pendant
#

What Iโ€™m doing now is just taking the light intensity when the script initializes and then adding a random value 0.01-1 to it and then tweening to that

steady moat
steady moat
somber nacelle
timid depot
#

ok sorry

clever quartz
#

hello everyone, im looking to make this (image)
from https://youtu.be/HQqZ8z2q96I?t=70

idea: have the entire scene or an area of the scene shown in a specific area

Who will win?

Red VS Blue

Destroy the opponent's base

Thank you for watching :)

[ Content information ]

  1. Destroy the opponent's base and win.

  2. If the base HP is below 500, it will be invincible for 10 seconds and attack faster.

  3. The base makes a basic attack. Additionally, it fires a counter-attack missile as much as the damage ...

โ–ถ Play video
#

any tips are welcome, including some name for it, since i dont know what this is called

#

thanks!

leaden ice
clever quartz
#

thats super useful thanks

strange pine
#

hey, so i want to have my camera switch between different angles a la silent hill 1, what would be the best way to go about it?
I got two solutions im thinking of and can't decide on the approach:

  1. Multiple cameras i flick between disabling/enabling
  2. One camera, switches between transforms sat as empty gameobjects

which way would be best out of those in regards to efficiency, or is there another way i haven't thought of? TIA

heady iris
#

Cinemachine can do this for you.

#

just set the default blend to "Cut".

#

this will make it easy to give each camera angle different settings (notably, field of view) without needing to juggle lots of cameras and keep the rest of their settings consistent

strange pine
#

brilliant, thank you! ๐Ÿ™‚

#

so i've never used cinemachine before so gonna dive into docs, but before i do, would specific cameras also be able to pivot to look at player?

#

i.e. camera 1 is just a static angle, but camera 2 would look at the player and follow while at a static position

#

nvm answered my own question XD

heady iris
#

yeah, there are lots of aim options

strange pine
#

coolio, thank you

heady iris
#

Also, if you're just starting to use Cinemachine, you can choose between 2.0 and 3.0

#

I use Cinemachine 3.0 everywhere now

#

Both work fine and both will be supported for a long while

#

It cleans up a few pain points (for example, 2.0 has a whole special kind of third-person orbit camera)

#

the API also feels nicer; 2.0 uses that annoying m_ prefix everywhere

heavy kernel
#

@proven plume build path looks like a directory tho? is that an additional buildoption?

timid depot
#

i think this is correct channel for that, whats the best solution for player controller if I want it to interact a little bit with physics? my current is using capsule and MovePosition and it moves many objects that are too heavy, clips to walls etc, ChatacterController doesn't use physics besides od gravity i think? any idea what can I use?

leaden ice
heady iris
#

CharacterController indeed doesn't care about physics. It does respect colliders.

#

actually, I'm mildly surprised you're able to push objects around

leaden ice
#

I think they're using a Rigidbody right now

#

MovePosition is a Rigidbody function

timid depot
#

yes I'm using rigid body

timid depot
leaden ice
#

also 500kg is quite small for a car

timid depot
#

I know but I most of the time give half of a normal size

#

mass"

nimble cairn
#

I'm just working on the settings menu for my game and I'm a bit confused with how AA works when you are camera stacking.

MSAA * 8 in the URP settings, yet disabled on the camera?

#

Is there an override setting or is something else happening?

leaden ice
#

but also realistic physics limitations are hard to put into a game. In a game you can always add forces no matter what. in real life you need some other object to leverage against, or you can't actually push

timid depot
#

even when I would put car to 1000kg player will be able to flip car

leaden ice
# timid depot player is just 40kg

but also realistic physics limitations are hard to put into a game. In a game you can always add forces no matter what. in real life you need some other object to leverage against, or you can't actually push

#

the amount of forces you're adding to the player - also relevant

timid depot
#

but when I will add less force player is too slow

#

that's why I'm asking for anything different than MovePosition

leaden ice
#

Forces

timid depot
#

I'll try

#

thanks for your help

#

I'll let you know later if it worked

unkempt zenith
#

Haven't used the old input in a bit, is there a nicer way to do quick key presses?

namespace Controllers
{
    public class InventoryController : MonoBehaviour
    {
        private void Update()
        {
            HandlePotentialSlotSelection();
        }

        private void HandlePotentialSlotSelection()
        {
            if (Input.GetKeyDown(KeyCode.Alpha1)) HandleSlotSelection(0);
            else if (Input.GetKeyDown(KeyCode.Alpha2)) HandleSlotSelection(1);
            else if (Input.GetKeyDown(KeyCode.Alpha3)) HandleSlotSelection(2);
            else if (Input.GetKeyDown(KeyCode.Alpha4)) HandleSlotSelection(3);
            else if (Input.GetKeyDown(KeyCode.Alpha5)) HandleSlotSelection(4);
            else if (Input.GetAxis("Mouse ScrollWheel") > 0f) HandleNextSlotSelection();
            else if (Input.GetAxis("Mouse ScrollWheel") < 0f) HandlePriorSlotSelection();
        }
   
...
vagrant blade
#

Nope, that's essentially it

unkempt zenith
#

Ok

dim crypt
#

Is there no way to do a copy in code? so in code call something that for example copies the color red and then i can right click on a color in the inspector and paste that color

mellow sigil
#
for (int i = 0; i < 5; i++)
{
    if (Input.GetKeyDown(KeyCode.Alpha1 + i))
    {
        HandleSlotSelection(i);
    } 
}
#

(not tested, might need to add casts)

leaden ice
heady iris
dim crypt
heady iris
#

this script would be using that internal code

although, "internal" might be unfortunately literal here: I'm looking at the Clipboard classes, and they're all internal

#

e.g.

dim crypt
heady iris
#

I'm not very experienced here, so I might be wrong! definitely ask in the other channel

dim crypt
#

Ok i will. Thank you

proven plume
#

Build scripts

tribal glacier
#

I'm making a system for navigating a map. All points and ships are stored within the generator. What's the best way to go about saving the "PoissonGen" object so I can say go to a combat scene and come back to the same map? (Ive seen a couple different ways of doing this but I just want takes on whats the best way to go about this)

late lion
heady iris
#

bingo

timid depot
#

can I somehow disable hinge joint with script?

#

or I have to delete whole component

rich elbow
#

I'm using a bidimensional array to instantiate GameObjects, which works perfectly when the size of the object is 1, but they overlap when they are bigger, any ideas how to fix it?

leaden ice
#

On a basic level, you will need to adjust the spacing you're placing things at by the size of those things

rich elbow
#
    private float distance;
    private char [,] map = {
        {'x','x','x','x','x','x','x','x','x','x','x','x' },
        {'x','o','o','o','o','o','o','o','o','o','o','x' },
        {'x','o','o','o','o','o','o','o','o','o','o','x' },
        {'x','o','o','o','o','o','o','o','o','o','o','x' },
        {'x','o','o','o','o','o','o','o','o','o','o','x' },
        {'x','o','o','o','o','o','o','o','o','o','o','x' },
        {'x','o','o','o','o','o','o','o','o','o','o','x' },
        {'x','o','o','o','o','o','o','o','o','o','o','x' },
        {'x','o','o','o','o','o','o','o','o','o','o','x' },
        {'x','o','o','o','o','o','o','o','o','o','o','x' },
        {'x','o','o','o','o','o','o','o','o','o','o','x' },
        {'x','x','x','x','x','x','x','x','x','x','x','x' }
    };


    void Start()
    {
        for (int i = 0; i < 12; ++i)
        {
            for (int j = 0; j < 12; ++j)
            {
                if (map[i, j] == 'x')
                {
                    Instantiate(wall, new Vector3(i, 6f, j), Quaternion.identity);
                }
            }
        }

    }
leaden ice
#

you will need to provide the item width and height somehow

rich elbow
#

it works now thank you :D

swift trench
#

Does anyone know how to create code for determining where a player should aim in order to hit there target based on velocity of the enemy and position of the player.

leaden ice
potent herald
#

I am getting this error:

Objects are trying to be loaded during a domain backup. This is not allowed as it will lead to undefined behaviour!

UnityEditor.Graphing.GraphObject:OnBeforeSerialize ()

My game is running still but i d like to avoid corrupting the project so how do I figure out whats causing it.

maiden quail
#

What is the expected behavior of UnityWebRequest.Get(url);? If I do UnityWebRequest.Get("asdfasdfasdfasdfasdf") and yield on it in a coroutine, it NEVER completes (I would expect it to end quickly with an error). If I paste a valid uri in a browser to where I actually want to GET from, I get the expect JSON blob response, but if I use UnityWebRequest.Get for that same uri, it just yields endlessly and isDone is never true. Obviously there's a error going on here, but Unity's API seems extremely unhelpful.

EDIT: nvm I wasn't calling SendWebRequest() after creating it ๐Ÿฅฒ

rigid island
#

put it in a tryGet and use a timeout

late lion
#

By default, Unity web requests don't have any timeout, so that could explain why it never gives up trying to connect.

maiden quail
# late lion Is there any difference between putting in an invalid URL, like "asdf", vs a val...

Here's an example, this seems extremely broken to me, obviously www.google.com is valid and obviously I have internet:

        [MenuItem("Tools/Test Google")]
        public static void GetGoogle()
        {
            _instance.StartCoroutine(_instance.GetGoogleCoroutine());
        }

        private IEnumerator GetGoogleCoroutine()
        {
            var www = UnityWebRequest.Get("www.google.com");
            while (!www.isDone)
                yield return null;
            
            Debug.Log("this never happens");
        }
#

omg I need to call SendWebRequest don't I

#

I'm dumb

tropic kiln
timid depot
#

or anything else you depend sin in your shader

tropic kiln
#

Yeah thought so, I'm just absolute trash at blender so im not sure how to fix it

timid depot
#

i think its about modelling not scripting

tropic kiln
#

I assume as long as the UV is the same size, I just have to distribute it evenly?

tropic kiln
timid depot
#

instead of uv coord

tropic kiln
tropic kiln
rigid island
maiden quail
tropic kiln
rigid island
unique delta
#

i made a code that instantiate popup text with the damage. i asigned a empty object to instantiate to but just the x is good and y is wrong.

timid depot
#

any idea why those 2 hinge joints behave differently?
first one is created with add component
second one is created with script

#
if (part.hidgeJoint != null)
{
    // create HidgeJoint that will hold door to parent
    HingeJoint hinge = part.gameObject.AddComponent<HingeJoint>();
    hinge.axis = part.hidgeJoint.axis;
    hinge.anchor = Vector3.zero;
    hinge.connectedAnchor = part.position;
    hinge.connectedBody = gameObject.GetComponent<Rigidbody>();
    hinge.useSpring = false;
    hinge.useMotor = false;
    hinge.useLimits = true;
    hinge.limits = new JointLimits() {
        min = part.hidgeJoint.min,
        max = part.hidgeJoint.max
    };

    hinge.breakForce = Mathf.Infinity;
    hinge.breakTorque = Mathf.Infinity;
}```
rigid island
tropic kiln
rigid island
#

go ahead, see what they say

timid depot
#

guys dont be jerks to each other

timid depot
#

like limits would be set to 0 0

tropic kiln
#

fr

timid depot
#

x and y of what is wrong? game object? text?

#

code?

rigid island
#

no memes

unique delta
#

i mean the text spawn below the characther but at the right x

timid depot
#

show code

#

we aint david copperfield

unique delta
#

is ok or should i send the full code

timid depot
#

ok

#

probably your pivot is under character

rigid island
tropic kiln
rigid island
timid depot
unique delta
#

stop guys jesus isn t ok with you arguing

timid depot
#

you have two ways

#

move pivot or add vector3 to it

unique delta
timid depot
#
Instantiate(popupdamage60, estantiate.position + Vector3(0, 2, 0), Quaternion.identity);```
unique delta
#

so i don t think is pivot

round violet
#

how can I get all files in a folder (all wavs, audio clips) and add them to a list of type sound clip

unique delta
timid depot
#

no idea you should give more info

round violet
timid depot
#

you didnt even mention before scenes

rigid island
unique delta
#

i know that

#

i should just put the same y for the both scenes?

timid depot
sleek bough
#

@timid depot Don't post off-topic images

round violet
rigid island
#

this can get you the audio directly as an AudioClip type

timid depot
#

some context

#

with hinge created with unity ui add component it works

round violet
rigid island
#

including local urls

#

aka your pc

round violet
#

also, what is the path relative to for GetFiles ?

#

Drive ? Assets ?

rigid island
#

depends where you want to get them from

round violet
round violet
rigid island
#

Application.persistenDatapath is usually where the root should start

rigid island
round violet
#

withotu me adding one at the time the music to a list in inspector

rigid island
#

thought you meant you wanted external audio from pc to a build

round violet
#

ah sorry

rigid island
round violet
#

no i just want a "get all music here and then do stuff"

round violet
#

but this forces me to create a Resources folder ?

rigid island
#

indeed

round violet
#

can i see it from the Project window ?

#

i only got packages and assets

#

i manually created it in the file explorer

rigid island
rigid island
round violet
#

ressources has to be in Assets ?

rigid island
#

yes

round violet
#

i thought it would be a independent folder

#

mb

rigid island
#

you can have multiple ones but they have to live in Assets

timid depot
#
if (part.hidgeJoint != null)
{
    HingeJoint hinge = part.gameObject.AddComponent<HingeJoint>();
    hinge.axis = part.hidgeJoint.axis;
    JointLimits limits = hinge.limits;
    limits.min = part.hidgeJoint.min;
    limits.max = part.hidgeJoint.max;
    hinge.limits = limits;
    hinge.useLimits = true;
    hinge.connectedBody = gameObject.GetComponent<Rigidbody>();
    // set hinge position to local position
    hinge.anchor = part.position;
}```
any idea? I cant fix it for 20 minutes
#

works when I add hinge joint with unity ui but not with script

leaden ice
#

since part.position will likely be a world space position

timid depot
leaden ice
#

of what

timid depot
#

where part should be attached

leaden ice
#

but the joint is on the part

timid depot
#

yes

#

so it should be zero?

leaden ice
#

the anchor needs to be the local space of the connection point in the part's coordinate system

timid depot
#

I dont get it

leaden ice
#

You did this:
part.gameObject.AddComponent<HingeJoint>();

#

so the joint is on part.GameObject

#

Where is the connection point supposed to be?

timid depot
#

exatcly where part is located in local position

#

so part.position

leaden ice
#

no

#

that would be

#

Vector3.zero

timid depot
#

Ill try wait

leaden ice
#

because the part is at 0 in its OWN local coordinate space

leaden ice
timid depot
#

yes

leaden ice
#

the joint anchor needs to be in the part's coordinate space

timid depot
#

now its inside parents center

#

not parts center

#

with my code position is correct but cant move it

timid depot
#

I still have no idea it behaves so weird

unique delta
#

if i made a public TextMeshPro in a script. How can i put in a prefab that has a textmeshpro.

leaden ice
#

but most likely you used the wrong type

unique delta
#

it dosen t work

echo basalt
#

Hey guys don't know if it's the correct place, but I'm having some trouble making a build on WebGL in UNity 2022.3.5.f1. I'm getting this error:

Building Library\Bee\artifacts\WebGL\GameAssembly\release_WebGL_wasm\namrvu51moua.o failed with output:
C:\Git\AirConsoleMovingOutMad\Library\Bee\artifacts\WebGL\il2cppOutput\cpp\DevmUnityLibV2.cpp:6639:9: error: no matching function for call to

There is more, but it's nothing specific in my code, just related to this Bee folder.

leaden ice
#

not TextMeshPro

unique delta
#

ok

leaden ice
#

TextMeshPro is the 3D version

#

TMP_Text covers both versions (UI and 3D)

unique delta
#

if i have in code Text.text = "80" + 5%maxheal

#

it should be idk 83 or smh

#

but is 803

somber nacelle
#

"80" is a string

#

you cannot add an integer to a string and expect it to increase the string's number. + is used for concatenation with strings. it will not do math

unique delta
#

so how can i

simple egret
#

This is what too much JS does to a man

#

"10" - 1 => 9

somber nacelle
unique delta
#

yes but text is a string not int

#

so how can i use a number

somber nacelle
#

use a number to do your math then convert it to a string

#

you cannot do math on strings

leaden ice
brave silo
#

Howdy howdy!
Anyone know if it is possible to detect camera exposure changes in Unity for mobile devices and webcams? I am interested in tracking the change in brightness/gamma on images.

unique delta
#

it gives me this error

leaden ice
#

you can't write arbitrary code outside of a function

hard viper
#

i think he might need basic C# training/tutorial

timid depot
#

maybe anyone was creating before hinge joints between two dynamic rigid bodies with script and can share snippet? my code still doesn't work after 2 hours of debugging

#

works with unity ui but not with script

heady iris
#

What about it doesn't work?

timid depot
#

i was talking more about it

ebon panther
#

Player Character Inside a Shape Problems

Im having a problem that I would of expected to be easy but is driving me insane and not working....

This is for Quest VR... I have a ground plane (with a mesh collider to keep from falling thru) and a player with a character controller. All works as expected. I want to put the character INSIDE of a cylinder or a capsule and have it contain the player. I want the player to collide with the inside walls if they try to get out.
So i've tried both a cylinder and a capsule both with a capsule collider. I make them much larger than the player and the character controller. The problem is both options immediately forces the player OUTSIDE of the object. The collision then works and I can't get back into the shape.
For trouble shooting I tried with a cube and a box collider this time the player stayed inside the shape but went right thru the wall but then it gets blocked trying to go back inside. I even tried each shape with reversed normals. That didn't work either and it would eject anything in the space with a rigid body. Anyone have any idea whats wrong here????

steady moat
languid hound
#

I'm genuinely stumped.. what's the issue here? Gamemode is the class I'm inheriting from which is meant to just make life easier and then MeleeGamemode is well.. the gamemode

#

It refuses to add listeners and I have to do it manually in the inspector

steady moat
#

You need to either create a mesh or place multiple object around the player. I recommand ProBuilder if you are not familliar with 3d editing tool.

languid hound
#

(For the record just so I don't look stupid the quit was for testing. The loop never quits the app despite the fact the participatingPlayers is always correct before it)

#

Okay nevermind fml it was script execution order

#

Should definitely be using start instead of awake for gamemodes anyways

knotty sun
fading rose
#

Hello, I don't really know in which category my question falls (beginner - general - advanced) so I'll put it here.

I am questionning myself regarding json conversions of things such as ScriptableObjects. If an Object holds a SO when converted, what happens ?

Also, if the "connection" got cut during the conversion, how to establish it back during the re-conversion from json to an Object ?

languid hound
#

I've been getting into a bad habbit of using Application.Quit because its immediate and I'm going to have to edit the script anyways lol

#

I need to break it at some point it just kind of came out of nowhere

simple egret
#

Application.Quit does nothing in the Editor

knotty sun
#

Dont. How do you expect code to execute afterwards?

simple egret
#

You're better off actually using the debugger with a breakpoint

languid hound
simple egret
#

return; then?

knotty sun
#

except your addlistener perhaps?

languid hound
languid hound
knotty sun
#

'It refuses to add listeners'
maybe because of

languid hound
#

It was because of script execution order not the quit

#

But yeah I got rid of the quit after the screenshot

#

I should've mentioned that

clever basin
#
public void ChangeColor()
{
    var color = new Color(Random.RandomRange(0, 255), Random.RandomRange(0, 255), Random.RandomRange(0, 255));
    Debug.Log(color);
    foreach (Transform child in ore.transform)
    {
        var spriterender = child.GetComponent<SpriteRenderer>();
        spriterender.color = color;
        spriterender.material.color = color;
    }
}

I am trying to change the colour of each of the Square sprites under the Ore GameObject. But when I run the above method, they all change to white regardless of the Color() that is created

simple egret
#

Both of them convert to each other and back, seamlessly

clever basin
#

Oh that explains it! Thanks ๐Ÿ™‚

lean sail
simple egret
fading rose
# lean sail Could always <:tryitandsee:1090612861178478703> but I don't know what you mean r...

That's what I had in mind too. I guess I'll go with that unless I find something better.
To give you an idea of why I asked :

  • I have a class Character which just has attributes that will be modified compared to the SO it originates from (eg. the level).
  • It also has the SO as an attribute to seek the attributes that will be never-changing (eg. the name).

I did that to avoid having 300 Characters originating from the same SO having unnecessary common and constant attributes. I feel like it's more optimised memory-wise, etc... Still I need to store them in a json text file which is why I was concerned with SO "connection" (which is just an attribute)

Please do correct me if my thought process is wrong or if you see better options.

steady moat
fading rose
flat abyss
#

I have a crosshair sitting on top of a render texture. I want to raycast to the far back from the crosshair position.
I'm trying to calculate the raycast from the crosshair position inside the RenderTexture, to shoot from the camera that renders it. ```Vector2 screenPosition = RectTransformUtility.WorldToScreenPoint(mainCamera, this.transform.position);

        // Create a ray from the screen position
        Ray ray = mainCamera.ScreenPointToRay(screenPosition);
        Debug.Log(screenPosition);
        return ray;```
steady moat
flat abyss
#

It returns ridiclous values like X:709584, y:459434, 0

fading rose
steady moat
fading rose
#

In fact, I didn't see the problem from that angle, I unnecessarily worried over optimization where it didn't really matter

fading rose
hard viper
#

only worry about memory if you are being wasteful, or memory cost is getting large

steady moat
hard viper
#

300 characters is like one discord message lol

fading rose
hard viper
#

unity would serialize that as a reference, unless you are defining the whole character there

#

and if youโ€™re defining the whole character there, well it needs to get defined somewhere

#

i have my SOs reference other SOs ina field all the time. It literally costs as much as one reference

astral nexus
#

guys, is there some good free resources of making ui management system from scratch? tutorial or good repo to check is fine
not something very complicated, just management of a panels, buttons and decoupling them from main logic by some way
I'm trying to make ui for my game, but it's so clunky and I dunno how things done right for this problem

like quite good examples of making an ui system, not just "how to make a button with functionality", etc.
maybe something with mvc, dunno (I'm not very proficient in mv-family patterns to implement it, it's just for example)

fading rose
ebon panther
soft shard
# astral nexus guys, is there some good free resources of making ui management system from scra...

Im not sure of any specific resources I can send, though with my UI, I use events and serialized classes so I can setup canvas-specific references like text, images, etc, and the UI can just respond to events and update itself when things change, the event itself can pass whatever dependencies are needed (such as the player if the UI needs to display the current health for example, or the player can fire a "onDamage" or "onHealthChanged" event and pass its current health, the UI can listen for that) - panels could be handled like a state machine or a stack if you want to allow popping (like spamming the back/esc button), maybe those techniques could help you build your own UI system

stoic mural
#

What would be the best way to smoothly move an object to another position when you click the mouse?

#

Obviously if i check for the mouse press and call a function its only gonna run once so it won't smoothly move

steady moat
lean sail
stoic mural
heady iris
#

if you want smooth movement, it has to do some moving every frame

#

don't worry about it

lean sail
#

If you are doing this for 1000 objects then maybe start to profile.

chrome trail
#

So is there any way in OnTriggerEnter to check if the collider that was entered was the one the script is attached to or a child of that collider? Because it seems the only parameter that the event returns is the foreign collider

latent latch
#

Compare references by either using GetComponent or cache them somewhere on the script

chrome trail
#

Or rather exclude collisions triggered by its children

languid hound
#

Is there a better workflow with singletons? Right now I have a bootup scene which has the singleton then I add DontDestroyToLoad to the singleton

The issue with this is if I want to work in another scene I have to go back to the bootup scene so the game manager singleton actually gets initialized and then navigate through my menu to the scene

latent latch
chrome trail
#

The object and its children are already on different layers

latent latch
#

I'd expect there's another way, because I'd feel like designing for layers would eat them up pretty quickly for these concepts.

unkempt zenith
#

I think I misunderstand what my line is doing:

        _spriteRenderer.gameObject.SetActive(slot is { Item: ToolSO or SeedPackSO });

What I want it to do is set the sprite rendered to active only if the item at the slot is a tool or a seedpack, but if it changes from a non-tool or seed pack item to a tool or seed pack item it does not activate

latent latch
languid hound
#

I considered that but it just seems so hacky

#

It works but I guess I was hoping there was a more efficient way

latent latch
#

Well, considering when you do build it, you'll always start in the boot screen

#

so temporarily hacky in that sense

languid hound
#

Yeah you're not wrong

lean sail
chrome trail
latent latch
#

right, you exclude them from physics operations

chrome trail
latent latch
#

I'm not too sure about that with collisional events and rigidbodies. I would say just compare layers and ignore them, though I'm not sure how you manage that without doing the casting yourself.