#archived-code-general

1 messages · Page 22 of 1

main shuttle
#

What Starcraft 2 AI does afaik is check whether or not it goes closer to the target or not over 1 second.
So if you grab a bunch of marines, and all double click them on the same spot they fight for that place like your skelly for 1 second, and then it force stops all of them. There is a GDC talk about Starcraft 2's pathfinding/navmesh, imho it has the best fast and responsive movement for strategy games currently, suggest you look at that talk.

west lotus
#

Well another idea is to calculate formation possitions based off the player pos. We do this in one game but for enemies attacking the player

cyan vector
cyan vector
west lotus
#

You would need to recalc the formation based on player pos, not just have a bunch of transforms parented to the player. If player moves check distance to each point, if its bellow min distance shift point away from player.

cyan vector
#

Thanks @west lotus & @main shuttle, after being stuck on this problem, I finally have some solutions. 😄

west lotus
#

Good luck

west lotus
cyan vector
west lotus
blazing trail
#

Anyone know how to solve this problem?
This happened when I finished moving the unity editors folder from C drive to E drive
This is the first time I have a problem like this, and I don't know how to solve it, I'm a beginner 🙂

plucky inlet
blazing trail
#

okay, I'll try to delete my library folder

urban owl
#

if a gameobject is created from prefab, the component property value modified by [ContextMenu] , is not able to serialized !!!!!

urban owl
#

place a prefab to the scene, the prefab has a Mono script.
use [ContextMenu] to modify this component value.
but it's not saved, after switch scene

plucky inlet
urban owl
#

the instances

plucky inlet
#

so you save the scene after editing values? What is your code actually?

woeful leaf
#

!code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

urban owl
#
[SerializeField]
  private Vector4 value;


  [ContextMenu("Build")]
change this value
urban owl
#

(1,2, 3,4);;

leaden ice
#

otherwise Unity won't realize the object is changed and won't save the changes

urban owl
#

I use gameObject to FindObjectWWithType first,

#

because I have so many these instances

urban owl
#

there are 2 scripts, one is to set the other's value

leaden ice
#

so?

urban owl
barren kelp
#

I’m making a flash baton. How do I give it a trigger kinda like a gun that the player presses and it causes damage

woeful leaf
#

What have you tried

barren kelp
#

Okay so I learnt I can use the activate in event thing and that’s the trigger on the XR controller but in order to toggle that off I need code?

woeful leaf
#

What now

wild vigil
#

I have a good idea of what I want to do, just missing a bit of knowledge on the coding side. Would appreciate if I could talk with a skilled coder. Looking at Scriptable Objects and EditorWindow.

main shuttle
#

That one doesn't exist, it's just something that vertx would want 😛

woeful leaf
#

Just realised that

plucky inlet
mental rover
woeful leaf
#

Oh yeah that's quite funny actually

woeful leaf
#

Cool

woeful leaf
#

Even if you weren't to have code, still follow that

wild vigil
#

TBH I'm a bit depressed and this project is helping me take my mind off things.

woeful leaf
#

That's still not helpful

plucky inlet
# wild vigil I have 500+ lines of code

Post your code on a paste website, best part only the code part that is necessary for your issue, then people can look at it. You barely will find someone here making a free coding lesson 1:1

woeful leaf
#

But yes, having the relevant code will also help

low ledge
#

Sanity Check:
I need a backend for my game to retrieve and store some data and do some matchmaking, but I do not need any live multiplayer functionality
Surely I can just do this with a plain ol rest api that I host on some azure server, right? Or do we do something completely different in Unity

woeful leaf
#

No, you should be able to do stuff with API's and databases and such

#

I'd just

keen siren
#

Just started working on a card game with my brother who's new to Unity and doesn't have any coding experience.

Want to create a smooth workflow where he can create new cards, enemies etc. in the editor.

Currently effects are MonoBehaviors that you add to card prefabs. When a card is played all effects are executed. The most basic effect is a DealDamageEffect that has a "Value" field where you enter the amount.

I'd rather have them be ScriptableObject assets (this would for instance allow me to also have the cards themselves be scriptable objects instead of prefab variants) but this comes with the problem that I would have to create one asset for every value, e.g. "Deal5Damage", "Deal7Damage" etc. (I don't want damage to be entirely based on a character strength or similar).

What's the smoothest way around this problem?

woeful leaf
modest furnace
#

Can someone please help me? I'm getting this error and I can't open my unity project (except in safe mode)
Library\PackageCache\com.unity.test-framework@1.1.31\UnityEngine.TestRunner\NUnitExtensions\Runner\UnityTestExecutionContext.cs(110,16): error CS0246: The type or namespace name 'EnumerableTestState' could not be found (are you missing a using directive or an assembly reference?)

swift falcon
#

Hey does anybody know how I can generate a convex mesh using code in unity?

swift falcon
#

When people answer then sure, hard to get help in a constantly moving chat

woeful leaf
#

It's still not allowed

#

Also it's not even constantly moving, you posted them with a 3 minute gap

#

Furthermore, it's even still visible on screen

swift falcon
#

Okay

#

There you go are you happy

#

It's a question more fit for code general than code begginer anyways

quaint rock
#

also have you googled for it or looked at the asset store

swift falcon
#

I have googled it

#

Mostly stuff on convex colliders

#

Google is always where I go first

quaint rock
#

writing a convex hull generator on your own is a non trivial issue, but its also a solved issue

#

so there will be many libraries and assets for creating convex meshes

swift falcon
#

I may be getting confused with concave geometry

woeful leaf
swift falcon
#

Well I'm trying to build a quake/half-life map loader

#

I tried generating tris and figured out quickly that the files don't store tri data but apparently data for convex or concave geometry

quaint rock
#

what does a half-life map loader even mean

swift falcon
#

Well

quaint rock
#

half-life just did map loading based on triggers nothing complex

swift falcon
#

It loads a map

#

From the game half life

swift falcon
#

.map

quaint rock
#

yeah good luck with that

#

also you mean .bsp

#

not .map

swift falcon
#

No I mean .map

#

Jackhammer and trenchbroom and other tools export .map files that I can load in half life

#

I'm using those files

quaint rock
#

assuming you meant compiled maps

swift falcon
#

Compiled would likely be .bsp yeah but I'm going for .map

#

Like qodot for godot

quaint rock
#

also just loading a half-life map in unity is not going to be trivial

#

you will be recreating a lot of wheels

swift falcon
#

Yeah I know

#

It's something I'm doing for fun lol

#

And to maybe use in small retro projects

quaint rock
#

not even sure why you would need convex hull generators for that, but you will need to be doing a lot meshes setup in code

swift falcon
#

So I can use hl1 map editors

swift falcon
quaint rock
#

yeah but you can make polygons from that definition

main shuttle
#

!code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

quaint rock
#

either way, why not use a tool like sabreCSG or something to give brush based csg tools in unity instead

swift falcon
woeful leaf
swift falcon
main shuttle
#

Post it in a proper way, I'm not going to download your file

woeful leaf
#

Probably not visible on phone

modest furnace
#

do `` infront and after your code

woeful leaf
#

Just listen to the !code

main shuttle
#

Just follow the thing I posted...

woeful leaf
#

Don't "try to do something else", just adhere to that

mellow sigil
#

and explain more clearly what the issue is, "I've messed up" doesn't tell us anything

woeful leaf
#

```

#

Well that works too I suppose

#

Also if you're using VS slap CTRL+K+D on that code

#

Also you didn't exactly define what the issue is with the sound

main shuttle
#

Why would this even play sound?

woeful leaf
#

Wait it's not even playing sound? (I didn't really look at the code)

main shuttle
#

Why not just add an event to your animation where it calls the step effect function when the animation is putting the foot down?

woeful leaf
#

Did you google1google2google3?

main shuttle
#

You don't use animations?

#

Okay, so no 3D model that moves then?

quaint rock
#

just do it based on the velocity of it

#

play sound every x seconds while velocity in a direction is greater then some threshold

main shuttle
#

Sure, but what Passerby said is a valid solution. Just check the velocity in Update, and check if the last step sound was x milliseconds ago.

quaint rock
#

with that you could even shorten the time as velocity goes up too

#

each time can cast downwards to get the physics material you are standing over and use that to modify the sound to play and make sure you are infact on the ground

#

so many ways to do it, just break the problem down into how do you play a sound at a set time interval and how do you detect player movement

potent glade
#

important question, I want to make a linux server build of my game but I need to give it commands, how do I collect those commands at my build?

woeful leaf
knotty tulip
#

I have a cube and I want to Instantiate objects within the bounds of that cube without manually hardcoding the bounds. Is there an easy way to do it?

calm delta
#

how do i put a line renderer between 2 ui objects on the same canvas?

woeful leaf
#

Solution?

main shuttle
#

We gave ideas? You want free handouts from us?

calm delta
cyan vector
calm delta
#

@cyan vector how do i get access to the UI Line Renderer?

buoyant crane
calm delta
#

got it, never downloaded an extension like this before :P

jade heart
#

Hey everone, I have some problems with an equation calculator that I want to use for creating volumetric clouds. I'm getting 8 compiling errors, all of which correspond to error CS0149. What part did I screw up on coding and how do I fix it?

https://gdl.space/qihaneqoru.cpp

leaden ice
#

share your error messages, the full ones

#

you can start with just the first message.

#

I will say one thing you've done wrong here is your variable names are completely inscrutable.

jade heart
#

This error repeats but with different lines

leaden ice
# jade heart

and the code as you presented it is exactly hwo it was when that error opped up?

jade heart
#

Yes

#

No changes

sinful scroll
#

is it possible to list the amount of tris being rendered in a scene as a float, if so how can I do it?

leaden ice
#

You've defined this variable R:
float R = Mathf.Log(l) + ((v - lo) * (hn - l)) / (ho - lo);
But you also have this method above:
float R(float a, float b, float c, float d, float e)

#

you are trying to then call the method

#

but you can't, because you've already used that name R for the local variable

#

the way to fix this is not to reuse the name R for your local variable @jade heart

#

local variables should not start with uppercase letters by convention anyway

#

and this is also an opportunity to improve your variable and method names overall, because these single letter ones are very hard to work with.

main shuttle
sinful scroll
#

will these still work when the project is built?

main shuttle
#

No, it's only in the editor.

jade heart
sinful scroll
#

Do you happen to know an alternative which works when the project is built?

dapper flower
#

When should I use static blackboard class to store variables and when should I use a ScriptableObject for the same effect?
Using static blackboard class I need to repopulate on each recompile. In ScriptableObject it seems that it keeps the data, but does it stay the original or it's a copy (after the recompile)?

main shuttle
sinful scroll
#

oh alright then, thanks anyways

leaden ice
#

and when you say "store variables" what kind of data are we talking about? What's the intended use and lifecycle for this data?

dapper flower
dapper flower
leaden ice
#

and again can you explain what "static blackboard class" means?

eager pier
#

Can someone help me which this if statement. I need to grow a small square. 2D collider logic

leaden ice
#

and use a SettingsProvider

#

so you'd get a section in Project Settings

leaden ice
#

what does "grow a square" mean exactly?

#

what is this supposed to be doing or checking?

eager pier
#

I have a point ( Vector2 location)

#

It's returning an array

#

I can show in-game problem

#

Right now, it's drawing lines. I need sqaures

#

Problem is if statement

dapper flower
# leaden ice and again can you explain what "static blackboard class" means?

It's a globally accessible class that has some useful value types and reference types. For example, I create the EditorPreferences' class instance that will be stored in UnityEditor.EditorPrefs class. I also have a few constants like DefaultSavePath for a Reset method to use. Classes don't need to know what Blackboard class is, they just need to get the data from it. Its usually what a blackboard class is.

dapper flower
leaden ice
#

nothing is kept

#

except for things that are serialized to assets

#

or something like EditorPrefs

dapper flower
#

So using a static POCO or SO, I'll always need to repopulate?

leaden ice
leaden ice
eager pier
leaden ice
#

E.g. instead of u == location.x || u == location.x + 10 shouldn't it be u >= location.x && u < location.x + 10?

covert folio
#

Does anyone know a bit about android studio? Is it possible to put an APK or AAB that I get from unity inside of a view in android studio an put buttons etc over that view with android studio? I wanna use AR functionality from Unity but the rest from android studio

leaden ice
#

not quite as an APK/AAB but you can embed a Unity game as a view in an Android app

#

lemme dig up the docs

covert folio
#

would be awesome, couldn't find anything about that. Not sure what exactly im looking for tbh

leaden ice
eager pier
#

Ty for help

#

Man this shit is buggy

thin aurora
#

I got this basic command class that takes a command with a handler to invoke, but for some reason my handler is not allowed. I expect the Delegate type to allow my method, but I end up with the given error. I can't find anything about Delegate types not being allowed in constructors. What am I doing wrong?

public struct PillowCommand
{
    public PillowCommand(
        string name,
        string description,
        Delegate handler,
        PillowCommandArgument[] arguments,
        PillowCommandParameter[] parameters)
    {
        this.Name = name;
        this.Description = description;
        this.Handler = handler;
        this.Arguments = arguments;
        this.Parameters = parameters;
    }

    public string Name { get; }
    public string Description { get; }
    public Delegate Handler { get; }
    public PillowCommandArgument[] Arguments { get; }
    public PillowCommandParameter[] Parameters { get; }
}
leaden ice
#

you should define an actual delegate type

#

and use that

#
public delegate void LogHandler(string message, string? prefix);```
thin aurora
#

I don't have a specific type though. I'm not restricting what can be used

#

The list of parameters can vary

leaden ice
#

Oh I see

#

you have a list of parameters

thin aurora
#

It's a command system, it's reflection to an extend

leaden ice
#

(what's the difference between Arguments and Parameters?)

thin aurora
#

Parameters are optional, maybe I should rephrase them

#

I could swear this would work

#

But apparently not because I can't get it to work on methods now

leaden ice
#

I've never tried to do things this way 🤔

thin aurora
#

I swear this worked before, I have no idea how lol

leaden ice
#

Should you not just do this the old fashioned way, with an interface or something?

public interface MyDelegate{
  void Run(PillowCommandArgument[] Arguments, PillowCommandParameter[] Parameters);
}```?
thin aurora
#

Would love a solution to this though

late lion
#

DynamicInvoke should only be used when absolutely necessary. You have better options, you should those.

thin aurora
#

Which is?

safe knoll
#

it's not too pretty but you can cast it to it's delegate type which will allow it to get through.

    void TakeAFunc(System.Delegate dele)
    {
        dele.DynamicInvoke( ... );
    }

    void AnotherFunc()
    {

    }
    
    void FuncWithInt(int i)
    {

    }

        TakeAFunc((System.Action)AnotherFunc);
        TakeAFunc((System.Action<int>)FuncWithInt);

Also not pretty: Just straight up use reflection. pass the object and function name. Not that a command system cares too much, but one benefit is MethodInfo.Invoke performs better than Delegate.DyanmicInvoke.

swift falcon
#

Singletons work for a single instance. Is there a way to do something similar when multiple objects (so multiple instances) share the same script? I'd want my checkpoint objects to survive the scene reload

quaint rock
#

Singleton is not what makes it survive the scene reload

potent sleet
quaint rock
#

you can just DontDestroyOnLoad them or you can just make sure they are memebers of a scene that does not unload

swift falcon
swift falcon
quaint rock
#

depends on the implementation

#

really what you want is what Null described

cedar pivot
#

hi, i have a player controller script, when player touches the ball; ball position is setting to players forward position.

but i dont have a dribble system. When i run/walk, ball doesnt move and its awful.

how can i make a dribble system like this? "https://youtu.be/-47ak3wYHZs?t=510"

⚠️: if ball is far from player, player shouldnt move

HEDİYEEEE STEAM OYUNUUUUUUUUUU!!!:D
Oyunu alan arkadaş yorum kısmına oyunu aldığına dair mesaj atarsa sevinirim.

Sanctum: Collection
https://www.humblebundle.com/?key=RuVFke3dKAyZmF3m

▶ Play video
cedar pivot
potent sleet
#

ye goodluck with that

#

pretty complex system like that cant be done in 2 days

#

unless ur a coding god

quaint rock
#

really would fake it and do it all as a animation

#

otherwise maybe attack the ball to a target joint on the player

#

and add force to it once and a while

swift falcon
quaint rock
#

but yeah it will take day or 2 work to make dribbling the ball like that look good and work

cedar pivot
swift falcon
quaint rock
#

checkpoints all have 1 common parent object

swift falcon
#

Oh in the hierarchy

potent sleet
#

ddol on the manager

quaint rock
#

that way they can all be managed by it, and that can be set to not be destroyed when a scene loads

swift falcon
#

I'll try that thanks

static matrix
#

Error CS1612 Cannot modify the return value of 'ParticleSystem.emission' because it is not a variable
Any help with this? I need to have dynamic emission amounts

leaden ice
#
var emissionModule = myParticleSystem.emission;
emissionModule.whatever = whatever;```
static matrix
#

tank u

fervent burrow
#

Hello there, I have this simple enemy AI where they just walk around and chase the player when he gets in range, but sometimes my enemies stop on non-walkable areas... Is there someone who can help me with this problem?

#

this is the code I have for the Enemy AI

potent sleet
#

doubt agent can go there

#

you have something else causing it

#

@fervent burrow show inspector for Agent

fervent burrow
#

it has a box collider

#

well, the enemies don't go inside the non-walkable area, but they stop against it

swift falcon
#

@potent sleet @quaint rock The DDOL is in my CheckPointManager script right?

If so, how do I reference each checkpoint in my CheckPointManager GameObject?

quaint rock
#

Drag them all into a array, or Get components in children

swift falcon
#

Is there any way I can use the vertices I have stored in an array to generate a tri pattern that will correctly generate a mesh?

swift falcon
swift falcon
#

Thank you

split plover
#

is there a variation on something like ImageConversion.LoadImage that DOES NOT upload to the GPU? I'm writing a v1 of a tool and feel like uploading a bunch of stuff to the GPU that is just going to be processed CPU side (for now) will just be a bottleneck?

cedar pivot
#

hi, i have a player controller script, when player touches the ball; ball position is setting to players forward position.

but i dont have a dribble system. When i run/walk, ball doesnt move and its awful.

how can i make a dribble system like this? "https://www.youtube.com/watch?v=__tZ4MvkcEg"

Player receives pass in-stride running at full speed, carries the ball for a bit, then reverses direction.

▶ Play video
leaden ice
#

looks super complicated

#

a ton of animation/inverse kinematics work

#

and procedural animation

cedar pivot
#

yeah but i need a simple system

leaden ice
#

if you want something simple it won't look anything like that

cedar pivot
#

hmm yeah

#

its simpler than it i think

wild vigil
#
public class ListManager : ScriptableObject
{
    static Dictionary<string, List> propertyLists;

}``` How would I initialize this dictionary in a scriptable object? I want it to always be there. I know in monobehaviour I would place in the start method.
leaden ice
#

you sure you want it to be static btw?

wild vigil
#

Can I place that right in the property block?

leaden ice
#

property block?

hexed pecan
leaden ice
# cedar pivot please help 😢

not understanding what you're wanting. If you have attempted something and need help with it you can ask. But you seem to just be asking for someone to build the system for you from scratch.

cedar pivot
wild vigil
hexed pecan
worthy scaffold
#

Hi! I'd like to use mesh.CombineMeshes method to do some batching. But I can't seem to retain any other uvs other than the regular uvs (I need lightmapping uvs as well as uv set 4 but they turn up blank) 😿
Anyone got any ideas?

proper oyster
worthy scaffold
#

yeah I have that active on meshes I combine that use lightmap. And I can see in my shader that its flagged as having lightmaps but the uv data is blank 😦

proper oyster
#

you may have to find a way to do it without unitys help

worthy scaffold
#

do you mean not using the combinemeshes method?

worthy scaffold
#

aah I see

#

Yeah that seems like an option

#

thanks!

wild vigil
#

How would I link my asset file to my editorwindow?

barren kelp
#

Hi. If I want to change component in script by referencing the “XR Grab Intractable” component and then if I wanted to do something with the interactble event more specifically the activate feature. What would I need to reference in my script would it be interatble events or ActivateEventArgs

wild vigil
#

I mean, I have a ScriptableObject asset file that is working like a permanent database and I would like my EditorWindow to see it and use it.

#

In the case of a monobehaviour I believe I can just link it directly, but not sure how to go about this with EditroWindow.

wild vigil
#

I'll give that a try.

regal marsh
#

So does controller vibration work on a ps5 controller?

#

in unity i mean

proper oyster
ebon steeple
#

I want to create a premade script when clicking an option, sort of like how I can create a new scene when clicking "Scene", but It'd be my own name with my own script. Thanks in advance!

wary ferry
#

Does unity have some system from drawing components created via script to the scene before running? Like if I add a box collider to a sprite programatically at awake can I get it to draw the box collider's gizmo?

leaden ice
#

if you want it to draw a particular gizmo in scene view you can use OnDrawGizmos() or OnDrawGizmosSelected() and draw whatever you wish

wary ferry
#

so i dont have to build something manually

leaden ice
wary ferry
#

you're right that makes sense

#

will check it out

swift falcon
quaint rock
#

you do not need to DDOL the childern

#

only the parent

#

only mentioned GetComponentsInChildren so you have a easy way to access all of your checkpoints from the manager object

#

var checkpoints = GetComponentsInChildren<Checkpoint>(); in the checkpoint manager script for example would get you all checkpoint components that are on child objects

eager aspen
#

Hi all, I need to implement a star pathfinding in my project. I've never done this before. I've started looking into it and I think I mostly understand it but there's one thing I'm not getting

In my project I'm using it to determine if block A is connected to block b via a chain of other blocks

These blocks can be destroyed in the middle of a chain and I see a potential issue where when I'm walking the grid that when it hits the blank space it's just not going to clear the open list

So how does one go about determining that there is no path when some of the nodes are completely cut off

leaden ice
#

you should also clarify if you're just implementing A* yourself or using the "A* pathfinding project" asset.

eager aspen
#

I'm implementing it myself

leaden ice
#

once it's empty you've traversed everything

eager aspen
eager aspen
#

How else would I do it?

leaden ice
#

that's not how the algorithm works

#

you put your starting node in the queue

#

that's it

#

to start with

#

then you are only ever adding the neighbors of the current node to the queue

#

anything that is not reachable from the starting node will naturally never get added.

eager aspen
#

Oh!!

#

Got it now that makes sense

#

Thanks so much! I would have been circling that all day

coral hornet
#

how should i go about making a Z axis curve in a 2.5D game? basically i want the player to turn around a curve and have the camera continuously follow them on their path, where the light blue is the cameras position, the blue is the cameras direction its facing, and the black is the players path from a top down perspective

coral hornet
#

ill look it up

leaden ice
#

as for the camera, use Cinemachine

coral hornet
# leaden ice use splines

wait so can you explain to me how splines work? from what i can tell they are just a 3D representation of Bezier curves, right?

leaden ice
#

have you gotten your IDE configured yet?

leaden ice
#

you had errors which were not showing before

#

meaning it was not configured

somber nacelle
#

have you actually started using the Vector3 you assign in OnTriggerStay

#

so you haven't changed the code at all yet?

#

then show the current code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

coral hornet
somber nacelle
#

actually, post the current code in #💻┃code-beginner because you shouldn't have crossposted in the first place since you were already receiving help in that other channel

#

just because you didn't receive a spoon-fed answer doesn't mean you weren't receiving help

leaden ice
#

hold on

somber nacelle
#

so then what part of that interaction was not receiving any answer or help on the topic you had a question for?

swift falcon
somber nacelle
#

and we clearly moved past that and i was providing information about your issue. if you wanna just cry about not getting spoon fed help then i'm just going to block you. good luck getting help when you refuse to even cooperate with those actively trying to help you 🤷‍♂️
also nice job editing your message after the fact when you said "i don't know what that means" instead of "it is already configured" 😉

thick socket
#
      tmp.Q<Button>("HeroButtonRenderer").clicked += () => HeroButtonClicked(hero);

    }
    static event HeroButtonClicked(HeroInfo hero)
    {

    }
#

I know this is very wrong...how would I setup this to be an event?

somber nacelle
#

is HeroButtonClicked supposed to be an event that other objects are subscribing to? or is it just supposed to be a method?

somber nacelle
#

that doesn't make sense

thick socket
#

🤔

somber nacelle
#

you can subscribe a method to your event and invoke that event, but the event itself cannot be defined like a method

thick socket
#

hmm ok thanks

#

I got to go watch a video again

#

was wanting everytime that function to be called

#

and event triggered and everyone that subscribed to the event did a different function

somber nacelle
#

i think you should for sure go find a tutorial about events because you appear to have some major misconceptions about what they are and/or how they are defined

desert shard
#

events are epico

thick socket
somber nacelle
#

i haven't used UIToolkit so i have no idea. i imagine that it probably has button-related events though 🤷‍♂️

thick socket
#

figured easiest way was using an event

somber nacelle
#

okay and again, i have not used UIToolkit so consult the docs. i'm sure they are pinned in #🧰┃ui-toolkit

teal delta
#

Hi there, I made an cube and i want it to stay in place and rotate around player (so that It looks at him) could anyone help me get into the right direction?

leaden ice
#

what behavior do you want? You want it to orbit the player?

teal delta
leaden ice
#

draw a picture?

#

show a video example?

teal delta
#

Yeah will do that

#

Wait a sex

#

Sec*

#

Does this make any sense?

leaden ice
#

is this 2D or 3D?

teal delta
#

Yes

#

2d

leaden ice
#

which one lol

#

ok so

rich sleet
#

"is this 2D or 3D"
"yes"

teal delta
leaden ice
teal delta
rich sleet
#

i know, it was just funny lol

leaden ice
teal delta
#

Thank you : D

leaden ice
#

it might be transform.up instead of right, it kinda depends how your sprite is drawn

teal delta
#

Well, i can always play around it

tough osprey
#

If you were going to have a large area on a 2d grid game that grows trees and then when they get big enough an NPC comes over and chops it down to get wood, would you have the trees and their sprites be Tiles on a Tilemap where you manipulate the tree by modifying Tiles on the Tilemap based on state? Or would you just use a GameObject for each individual tree? Let's say the area may contain 100-200 trees. As I write this out, I'm leaning towards one option, but curious for input anyway.

leaden ice
#

if you can handle all the stuff by inspecting the grid data and doing grid-based pathfinding and grid-based logic, then it can all be in tilemaps

thick socket
#
renderTexture.style.backgroundImage = new StyleBackground(hero.renderTexture);
(throws erros)

Are you able to set RenderTexture in code in UI Toolkit? I'm able to find setting all other types of background except this

tough osprey
# leaden ice if you can handle all the stuff by inspecting the grid data and doing grid-based...

Thanks, it's a roller coaster in my mind. I was originally thinking that I can do it with Tilemaps, but then I thought that calling an instanced object to keep track of the chopping state and handle dropping the wood and despawning the tree would be nice to have incapsulated in a Tree object, so I was thinking GameObject. But now I'm thinking a Scriptable Object per tree that works with a Tilemap. Partly because I'm going to want to do the same thing for other types like rocks, and those would benefit from RuleTiles for rendering larger structures (and the performance benefit of Tilemap for rendering many instances of these things)

leaden ice
#

but just having basic POCO objects in your own data model in a grid structure would probably work quite well

#

With the TIlemap as the presentation layer, so to speak

tough osprey
#

haha thanks, I was just realizing ScriptableObject isn't what I want. I misunderstood their purpose, I thought they were a sort of POCO. I read the docs for ScriptableObject and they're very cool (I'm using them for their intended purpose elsewhere without even realizing it). I'm also working with PhotonFusion so I need some NetworkObject with a NetworkBehavior to act as the controller with an internal structure of items for the trees and their state.

crystal kite
#

tyty ill try that out

vestal crest
#

have you ever made UI sytem with state pattern?

#

i wanna know whats the logic behind handling ui with state pattern

wild vigil
#

How do I link a scriptableobject to a prefab, in a way that when the prefab changes the scriptable object will respond?

swift falcon
#

@quaint rock I just ended up making a singleton in my CheckPointManager. It works as intended tho I have a NullReferenceException I have to solve. Thanks a ton tho man, the hierarchy was the key. Thanks Null (too many of you) too!

hexed oak
#

Why can't I get JObject.FromObject to return when passing an Int32 as a parameter?

jaunty needle
#

Hello guys, so I have planets in a solar system that I can instantiate and they get added to a list but I want them to be destroyed on impact with another planet and remove themselves from the lest. How can I use events to do that or some other method without directly referencing the list?

whole olive
#

why wont this work

somber nacelle
jaunty needle
#

Basically I have multiple planets that each need to declare an event whenever they die but I don't think I should loop through every single one of them just to listen out

#

So I was thinking maybe there is a different solution

proper oyster
jaunty needle
#

wait how do I make a singleton again

#

do I have to make the class static for that?

proper oyster
jaunty needle
#

alrighty thank you

jaunty needle
#

And I can't really make this static

naive swallow
#

Is there any way to define an interface to only apply to MonoBehaviours? So that you can use properties like .transform on the Interface.

proper oyster
naive swallow
jaunty needle
proper oyster
jaunty needle
#

ok

#

wait so I can make the list static too right?

proper oyster
jaunty needle
#

i'm reading an article alright 👍

swift python
#

Hey can anyone help me why i cant build and run my game? i get burst compiler errors. If you know how to export the log of the console maybe its easier for you to check. I tried to google it and they suggest I need a special module for the Universal Windows Platform in my visual studio. I have tried to install said modules repeatedly and also checked and renamed the file so that the editor can find it. but the errors remain unsolved

jaunty needle
#

But I just don't know how I can do that...

swift python
#

yea

leaden ice
#

IDK, share your specific errors etc.

proper oyster
swift python
jaunty needle
swift python
#

this was after i tried to rename a folder that was named "arm64" into "arm" because he kept complaining he couldnt find the link.exe

jaunty needle
#

It's mainly the list doing its job that I'm worried about

#

Acc it's fine

naive swallow
jaunty needle
#

I'll just directly reference it

swift python
past pier
#

Is there any way to achieve a reverse-sphere-cast in Unity? Meaning that the sphere (or any of the geometric casts) needs to completely overlap an collider (not just "nudge" it for example) for it to count as a "hit"?

naive swallow
swift python
#

@naive swallow i mean i was just trying to fix my problem, because he kept saying he cant find it. so i tested that option out. i guess its a bit iffy yea

leaden ice
swift python
#

anyone who can help me? 😦 I have the URP

naive swallow
#

Don't copy the folder

swift python
#

i deleted it.

#

its not helping what you are saying because im back where i was. 0

#

do i just go ahead and install them all ? i spent last two hours trying to install all of the latest versions

indigo hound
#

Hey there! Is there a way to check if a sprite is currently behind a sprite mask (so when it's being hidden) via code?

leaden ice
indigo hound
#

That actually might work

#

Thx

swift python
#

to anyone interested. I had to uncheck and check this, to make it work:

#

thank you anyway!

wild vigil
#

I am editing a dictionary inside a scriptable object from a EditorWindow. When I leave edit mode and enter play mode my dictionary is reset. Why is the scriptable Object not maintaining the changes to its data...

cosmic rain
swift python
#

but apparently it wasnt enough. had to uncheck it and then check it again

#

then for some reason he found some other missing components

steady moat
cosmic rain
quaint rock
swift python
cosmic rain
swift python
#

yea but now i got the next slap in the face:

quaint rock
swift python
#

Why cant things just work 🌝

wild vigil
steady moat
#

Personally, I do the conversion with Linq (.ToDictionary()) in the Awake

quaint rock
dusky quest
#

i have this class and i want the second constructor to call the code in the first constructor when its done, is that possible?

quaint rock
#

jsut call it by name

#

oh nvm you need to constructor chain it

steady moat
#

You can do it in OnValidate, if it is something you wish to control. That being said, the ISerializationCallbackReceiver is a more complicated way to do it.

dusky quest
quaint rock
dusky quest
quaint rock
#

public Country(string name, Color color) : this() {

dusky quest
#

thanks

warped sphinx
#

ok so im trying to figure out witch collider has stopped colliding. I used oncollidionexit but I cant figure out who stopped colliding???

quaint rock
#

Debug.Log should help out

warped sphinx
honest yarrow
#

Hello this is my code. I keep getting the error "object reference not set to an instance of an object" Ive been trying to figure this out for so long. Can someone please help?

#

Theres a problem on line 39

#

But I don't know what it is

somber nacelle
#

your IDE needs to be configured

tawny elkBOT
honest yarrow
honest yarrow
#

Which one?

#

Manual or Unity

somber nacelle
#

well did you install visual studio via the unity hub when you installed the unity editor or manually?

honest yarrow
#

Manually

somber nacelle
#

then take a guess at which you should click

honest yarrow
#

Ok

#

Thanks

somber nacelle
#

once you've got that configured you need to figure out why one (or more) of the objects hit by the overlapcircle do not have a Monsters component

honest yarrow
#

Wait, where do I find this modify option?

somber nacelle
#

in the visual studio installer like the instructions said

honest yarrow
#

But I already have it installed

somber nacelle
#

great! then open the visual studio installer and select the modify option

honest yarrow
somber nacelle
#

you wouldn't be getting a NullReferenceException on the line you highlighted if all of the objects on that layer had it 😉

quaint rock
#

the overlap or what ever you used, captured something that does not have the Monsters component

honest yarrow
#

Ohhh

#

That makes sense

somber nacelle
#

you should use TryGetComponent, but you'll also want to figure out why something is being detected by that query that shouldn't be

quaint rock
#

you can either make sure with your layermask it only hits things with the component, or you can simple check for null and return early or use TryGetComponent

broken light
#

is there a way to convert a string input to a type ?

#

so say the field has "int" then i can convert this to a type so i can make say an array int[]

#

i need this for an editor tool where it can generate an array of a custom type the user decides

quaint rock
#

got a example of the string

#

got stuff like int.Parse that can take a string and make it a single int

broken light
#

its a field in the inspector of type string so the user could put MyCustomClass

#

or any other type

#

then i would want MyCustomClass[]

quaint rock
#

this is very much sounding like a xy problem

broken light
#

a what

#

which part are you confused by ?

somber nacelle
broken light
#

ok ill explain the scenario

#

i have a map editor tool and users can create their own custom tile class

#

the editor then needs to be able generate array data of their custom class

#

so right now my idea to solve this is to use a string input of the name of their class

#

and the editor tool will use that to create the array of the type

#

they arent GOs or prefabs so i can't reference it

quaint rock
#

so approaching this with strings is asking for trouble

broken light
#

so how do i approach it

quaint rock
#

why cant the user custom tiles just be extending a existing type and override methods of it

honest yarrow
quaint rock
#

or just be types implementing a interface

broken light
#

which isnt part of the interface

quaint rock
#

if its a user type, how do you expect to access data on it, of types and names you do not know about

broken light
#

also intefaces dont show in inspector

#

which is a pain

broken light
quaint rock
#

making the user extend a existing type you control lets you still be able to store it in a knowen type, and still be able to know about and call methods on it while letting the user override parts of it

broken light
#

hmm i guess but then i either have to force the data to be an array of monobehaviour derived classes , or non monobehaviour dervied classes or structs and the user has no choice in the matter

#

i can see a situation where i dont want monobehaviour but also scenarios where i do for other setups

quaint rock
#

if you really want to push forward you can just use reflection to do it. but i highly would discourage it

#

since it makes using it on the other end so much harder, since you would know nothing about the type the user is providing

honest yarrow
#

could you help me out again?

honest yarrow
#

would I use this to only hit the objects with Monsters components
if (attackPoint == null)
return;

somber nacelle
#

well ideally your layermask should be set up to only detect objects with that component, otherwise use TryGetComponent to determine if an object has that component on it

honest yarrow
#

How would I use TryGetComponent, I've only used getcomponent so far

honest yarrow
#

I still need help, would this be the code I would use?
if (TryGetComponent(out Collider2D Monsters))
{
TakeDamage(attackDamage) = true;
}

quaint rock
#

if (TryGetComponent(out Monsters monsters)

somber nacelle
#

TakeDamage(attackDamage) = true; also makes no sense

quaint rock
#

then the component it got would be in the monsters variable so you can
monsters.TakeDamage(attackDamage)

honest yarrow
#

It still doesn't work, I get the same error and I'm using the code same code

#

Same error message

somber nacelle
#

Show the full error message including stack trace as well as the relevant code

honest yarrow
#

That's the error messa

#

Message

#

That shows up in console

somber nacelle
#

And the code?

honest yarrow
#

if (TryGetComponent(out Monsters monsters))
{
monsters.TakeDamage(attackDamage);
}

somber nacelle
#

Well none of that could give a NRE, but you're also calling TryGetComponent on this object instead of the object from the array

#

Make sure to call it on the correct object then save the code and try it again

honest yarrow
somber nacelle
#

call TryGetComponent on the object from your foreach which i believe was called enemy

honest yarrow
#

It still doesn't work

#

Same error

somber nacelle
#

show the full class using a bin site

honest yarrow
#

There is also an underline under the enemy part

somber nacelle
#

well then your code didn't compile and you shouldn't even be able to enter play mode

#

if it's a red underline, that is

#

in fact, if that is the case and you've actually saved your code then you should have a whole new error in the console

honest yarrow
#

When I used enemy

somber nacelle
#

well since i'm not psychic why don't you share the code like i've asked and also the error message

honest yarrow
#

if (TryGetComponent(out enemy Monsters))
{
Monsters.TakeDamage(attackDamage);
}

somber nacelle
#

why did you swap out the component type for enemy?

#

you should be calling TryGetComponent on enemy using the . operator

honest yarrow
#

How do I change that, sorry I'm really confused now

somber nacelle
#

do you know how to call a method on an object?

honest yarrow
somber nacelle
#

yes

#

also:

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

honest yarrow
honest yarrow
somber nacelle
#

share the full class

honest yarrow
#

Ok

dapper vigil
#

When im buildin the game i get this error
“Create visual studio code”
But i have legit no clue what to do about it 🤭

#

Then i create it with that visual studio code and tadaa even more confusion 😂

somber nacelle
dapper vigil
#

I will share tomorrow, time to head to bed for now UnityChanClever

honest yarrow
#

Here is the full class

somber nacelle
#

show the current error message as well

somber nacelle
#

make sure you actually save the code. you don't even have an Update method in this class

quaint rock
#

the stack is not from the code you posted

honest yarrow
#

Same error

somber nacelle
#

then you're looking at the completely wrong file

#

double click the error in the console and it will take you to the correct code

quaint rock
#

the error you gave us is saying there is a NRE on a line with no code, and references a method that does not exist

honest yarrow
#

Oh

#

I fixed it

#

It works now

#

Thank you so much guys

somber nacelle
velvet elk
#
public class Billboard : MonoBehaviour
{
    [SerializeField] Camera cam;

    void Update()
    {
        if(cam == null)
            cam = GameObject.Find("PlayerCamera").GetComponent<Camera>();

        if(cam == null)
            return;
        
        transform.LookAt(cam.transform);
        transform.Rotate(Vector3.up * 180);
    }
}

im following a tutorial for a multiplayer game and this script that finds a player's camera and looks at it returns the NullReferenceException error on the GameObject.Find line

how can i fix this?

somber nacelle
#

that means there was no object found with the name "PlayerCamera"

#

also you know you can use Camera.main to get the camera tagged with the MainCamera tag without needing to use any of the Find methods, right?

sharp oracle
somber nacelle
wispy grail
#

does anyone know of a function that would disconect a player from a relay? for example a function like RelayService.Instance.LeaveAllocation.

somber nacelle
wispy grail
#

how could i send i close request? there really isnt any clear definition

#

i think i found it thanks for the help

wispy wolf
#

I've been trying to wrangle the UI system for a bit and I thought I had it figured out. I have a segmented meter and I'm creating the segment nodes in Awake() like this:

nodes = new Image[max];
for (int i = 0; i < max; i++)
{
    GameObject node = new GameObject($"BarNode.{i}", typeof(Image));
    node.transform.SetParent(transform);

    Vector3 offsetPosition = Vector3.zero;
    offsetPosition.x += anchorSprite.rect.x + ((i + 1) * nodeSpacing) + (i * nodeSpriteWidth);

    node.GetComponent<RectTransform>().anchoredPosition = offsetPosition;

    nodes[i] = node.GetComponent<Image>();
    nodes[i].sprite = onSprite;
}

The problem is that the node ends up with an arbitrary Z position, some arbitrary scale, -10 rotation on the X (wtf?).

wispy grail
#

try setting the parent when you create the node and not after

wispy wolf
wispy grail
deep willow
#

why whenever i open visual studio, i have to go into preferences and set it as the IDE i want to use as a default ?

#

how do i keep it as default

#

?

wanton obsidian
#

So, Im making a multiplayer game and trying to get an interaction script to sync door opening and closing however when the Client interacts it works and does the correct opening and closing animations but when a client opens the door the Host sees the opposite animation.
When the client opens/closes the door, the host will see the opposite animation. If the door is open for the host and the client interacts the door will jerk closed then play the open animation and reverse if the host sees it closed

deep willow
#

i did but everytime i try opening it when i reopen unity, it switches back

wild vigil
#

I was using a dictionary in a Scriptable Object, only to find that dictionaries are not serializable. How would I achieve the same key value setup using lists?

rain minnow
round creek
#

hello, i would like to create a leaderboard for a small game i have; how should i go about doing this?

rain minnow
wild vigil
rain minnow
wild vigil
rain minnow
wild vigil
#

My initial idea was to place the Key and Value into a struct. Would this work?

#

I would prefer to work within standard libraries

rain minnow
#

you can have a list of structs with a key/value, but then you have to use Find with a predicate to search and retrieve the struct based on its key field . . .

rain minnow
wild vigil
#

how would I run that search on the key field?

#
int index = listAddresses.FindIndex(x => x.key == prefab.name);
rain minnow
#

no reason to use FindIndex if you have a struct (with key/value), just return the element . . .

wild vigil
#
int index = listAddresses.FindIndex(x => x.key == prefab.name);
AssetDatabase.DeleteAsset(listAddresses[index].address);
propertyLists.Remove(propertyLists[index]); 
listAddresses.Remove(listAddresses[index]);
#

I'm using the prefab name as the key

rain minnow
#

problem is, you need to manually search for duplicate keys. if you have any, it'll return the first one found . . .

wild vigil
#

would someone have 2 prefabs with identical names in a project?

full scaffold
#

what are you trying to do

wild vigil
#

I'll leave it broken for now.

#

I was trying to store a dictionary in a scriptableobject...

rain minnow
uncut mason
#

Hey! I'm trying to display debuff sprites in my project but im running into an issue. I need the debuff sprites to move based on the number of them, so if there's one debuff it should be at local 0,0 but if there's 2 they need to both move to the cumulative position is centered as well, and 3 be centered etc etc.. How would I do that?

wild vigil
rain minnow
uncut mason
#

oh my god why was i adding them as Gameobjects with spriterenders. i might be mentally deficient

#

thanks

wild vigil
#

Are lists serializable in ScriptableObjects?

#

I've switched to lists and they still not being stored.

#

So you cant serialize structs. Good to know

gritty birch
#

the entities do not get rendered .why?

swift falcon
gritty birch
swift falcon
#

Just don’t post the same thing in many channels

bitter hound
#

Is there a downside to using a public variable with a private setter, beyond not being able to use the [Range(0,1)] etc things?

[field: SerializeField]
public float someValue {get; private set;}

[SerializeField]
private float someOtherValue;
#

It seems to work, but I don't know if it comes with downsides I don't know of, or is against a recommended standard, or something of that sort.

pine spire
#

@bitter hound what’s the purpose of float being public? Inheritance?

bitter hound
#

Other scripts can read the value but not change it

pine spire
#

Have public getter and private settet

bitter hound
#

That's what it does, yes

thin aurora
#

!ide

tawny elkBOT
bitter hound
#

I assume it's mostly identical to

[SerializeField]
float _someValue;
public someValue {
  get { return _somevalue;  }
}
pine spire
#

@bitter hound I assume this pattern is totally fine, though I would doublecheck if changing it is actually outside scope of other classes

bitter hound
#

I've checked and it seems to work so far, but I've been an artist that sometimes codes before, and now I'm looking to transition into being a programmer, so I want to make fewer guesses based on "it seems to work" now. 😄

pine spire
thin aurora
#

If you have no need to read it outside the class, you might aswell make it a private field

bitter hound
#

Alright, I hadn't noticed that `field:`` makes the other... uh, property modifiers work

thin aurora
#

Your property is just a wrapper for a backing field right now, same as any other field, so there is not much use to it if you don't actually make use of the features of the property

bitter hound
#

and a private field would be private float someValue {get; set;} right?

thin aurora
#

That's a private property

#

private float _someValue; is a private field

bitter hound
#

In that case I don't know the difference between a field and a property

thin aurora
#

{ get; set; } indicates the getter and setter of a property

#

You can modify the way you get / set its backing field

bitter hound
#

Previously I've just called all of these 'variables', it seems like I have some reading to do

thin aurora
bitter hound
#

Yeah, I get that part

thin aurora
#

A variable can be many things

bitter hound
#

I found this:

Avoiding Overuse of Property Getters and Setters

Most people don't realize that property getters and setters are similar to methods when it comes to overhead; it's mainly syntax that differentiates them. A non-virtual property getter or setter that contains no instructions other than the field access will be inlined by the compiler, but in many other cases, this isn't possible. You should carefully consider your use of properties; from inside a class, access fields directly (if possible), and never blindly call properties repeatedly without storing the value in a variable. All that said, this doesn't mean that you should use public fields!

Source: http://dotnet.sys-con.com/node/46342

https://stackoverflow.com/questions/2166433/why-ever-use-fields-instead-of-properties

It seems to imply that in some cases properties can be a bit slower?

tough aurora
#

hello, i am trying to call a: yield return StartCoroutine(exampleCoroutine()); (inside a coroutine)
but the problem is that the coroutine has a for loop and is not looping correctly

#

i am not sure what the problem is, but i suspect it may have something to do with the code being paused per frame

thin aurora
#

It is actually a violation to use public fields

pine spire
#

Properties are basically a conventional format for get and set functions. In C# it is generally considered good practice to use them instead of public fields. Real differences start when you use them to verify if input and output are correct. And nothing stops getter from being more complex than just return value.

thin aurora
thin aurora
mental rover
tough aurora
mental rover
tough aurora
#

in a coroutine which calls a coroutine after the next

#

public IEnumerator cutscene(){
yield return new WaitForSeconds(3f);
yield return StartCoroutine(FadeTo(1, 3.5f, sprite1));
StartCoroutine(runText("presents", presentsText, .2f));
yield return StartCoroutine(FadeTo(1, 5, sprite2));
yield return new WaitForSeconds(5f);
}

pine spire
mental rover
tough aurora
#

on a trigger enter

mellow sigil
mental rover
#

you can add a debug log for when the cutscene is called - you will likely find it's being called twice

tough aurora
#

ok

tough aurora
#

i've tested it and the same thing happens

mellow sigil
#

Don't call it twice

#

you have to find where you do that

mental rover
#

verify that is happening first, don't just assume

tough aurora
#

right

mental rover
#

if that is the case though, an easy way is to add a bool, e.g isPlaying, that is set to true when it starts, and false when it ends - then only start the coroutine if isPlaying is false

wild bane
#

guys, if we plan to make some online multiplayer
do we still need the playerprefs ?

#

for each client

tough aurora
mellow sigil
#

Question makes no sense, why would you need playerprefs for anything?

#

although if it's being called twice when it should only be called once it's better to fix the root cause instead of patching it

tough aurora
#

should i disable the collider component?

mental rover
tough aurora
#

also it works now btw

mellow sigil
#

I mean if it's being called more than you expect then there's a problem that you're just covering up

tough aurora
#

hmm, so is this to do with the collider trigger component or something else? the only elements in this situation that i can think of are just the trigger collider and the player going into it

mental rover
#

debug logs are your friend

tough aurora
#

ok

#

maybe its because i have multiple colliders on my player

#

but i think your fix should be ok

thin aurora
#

I'm not sure if I ever want to introduce any sort of guard clause to them. I can understand if you add those, but right now I would rather put those in a method too.

dapper vigil
swift falcon
#

anyone familiar with firebase know why im getting this error?

mellow sigil
#

Best guess is that the database URL is not set in the Firebase config

proper oyster
dapper vigil
#

So i got this weird issue where, the first 2 times the enemy boss spawns in normally, but the third time it disappears and never returns, however i dont see anything that changes lol...

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

dapper vigil
#

This better? first time using it

wild vigil
#

ComputeBuffer.SetData requires a non nullable data type. I was using a struct. Struct can not be serialized in a scriptable object. What is the correct way to proceed?

neat lagoon
#

what do you mean struct can not be serialized in scriptable object?

#

are you using the [Serializable] attribute on the struct and making sure the field itself is serializable? for example with [SerializeField]

wild vigil
#

is a 4x4matrix serializable?

neat lagoon
#

yes actually

wild vigil
#
    public struct MeshProperties
    {
        public Matrix4x4 mat;
        public Vector4 color;

    }
neat lagoon
#

yes mark your MeshProperties struct with the [Serializable] attribute

wild vigil
#

will [SerializeField] work?

neat lagoon
#

that is for the field, let me show

#
[Serializable]
public struct MeshProperties
{
  public Matrix4x4 mat;
  public Vector4 color;
}

public sealed class MyScriptableObject : ScriptableObject
{
  [SerializeField] private MeshProperties m_meshProperties;
}
#

if you make the field in the scriptableobject public, you don't need SerializeField

wild vigil
#

why is Serializable not available for me...

neat lagoon
#

requires System namespace

#

using System;

#

do you know how to include namespaces?

wild vigil
#

I could literally kiss you right now

#

Thank you. Thank you. Thank you.

#

I was rewriting as a class - but then that introduced its own problems. I read somewhere that structs weren't supported.

tardy agate
#

is it possible to ignore a script for a specific platform? like #if (UNITY_EDITOR) but for Windows builds only

tardy agate
#

thank you!

vague tundra
#

What is the proper way to rotate an object with a character controller component?

deep willow
#

Anybody know how to fix this prefab being all jumbled when i try to edit it?

#

it aligns perfectly when i instantiate it, but not when im editing it

#

might be because it doesn't know how to align until it becomes a child of a grid layout?

#

i aligned it to the grid layout then made it into a prefab

narrow summit
#

I think the automated canvas is the problem

#

And it defaults to the resolution of the game view

#

@deep willow ^

deep willow
#

how do i solve it? lol

narrow summit
#

Change the resolution of your game view

#

Or usually, I just edit in the scene honestly, and then apply it back to prefab

deep willow
#

not sure what you mean

#

edit the scene?

wild nebula
#

Anyone know where UnityEngine.Transform is at the c# source ref?

pearl radish
jaunty needle
#

Guys how do I change a variable of a prefab as soon as it's instantiated because there is this flickering when I instantiate this planet

#
    {
        Vector2 spawnPos = cam.ScreenToWorldPoint(Input.mousePosition);
        GameObject planet = Instantiate(planetPrefab, spawnPos, Quaternion.identity);
        planet.GetComponent<CelestialBody>().radius = 0.1f;
        CelestialBody celBod = planet.GetComponent<CelestialBody>();
        AddBody?.Invoke(celBod);
    }
#

It starts out as radius = 1 but then flicks back to 0.1f

#

ok i fixed it

#

thx guys

thin aurora
#

No problem, glad to help

swift falcon
#

hey

#

can i ask somethin

atomic wasp
#

Hi, I'm working on a script that changes vertex colors on a skinned mesh instance. It works, but for some reason when I copy from SkinnedMeshRenderer.sharedMesh to an instanced mesh it replaces the source sharedMesh in project assets as well. This is documented in the API reference, though it doesn't say why it is so or how to work around it. Is there a way of working only on an instance of a skinned mesh and not the source asset? Short of constructing a new mesh piece by piece in code.

teal delta
#

hi there, why doesn't this add force to my 2d object? (i checked with console.WriteLine and it finds gameobject with tag and also the object has rigidbody)

main shuttle
teal delta
#

but i have the same on player and i can add force to it just fine

main shuttle
#

That doesn't matter. You are sure that the AddForce gets called?
If so, show a screenshot of your RigidBody2D component.

teal delta
#

thats my setup for ball

main shuttle
teal delta
#

nope, just one with tag ball

main shuttle
hasty canopy
#

There's your culprit

teal delta
#

ohh

#

didnt think of that becasue i ususally do 3d games

hasty canopy
teal delta
#

yeah it works now

hasty canopy
#

Doing findobject in update is very performance extensive

teal delta
hasty canopy
#

Cool

teal delta
hasty canopy
teal delta
main shuttle
#

Just serialize it...

hasty canopy
#

Very big

teal delta
#

i think both do something once on start

hasty canopy
main shuttle
#

Finding at all is bad practice.

teal delta
hasty canopy
#

So if your computer has 120 fps, it will find an object 120 times from your heirarchy

hasty canopy
#

Start is called only once

teal delta
#

and awake?

hasty canopy
#

Also once but before start

teal delta
#

so its just a little bit faster

#

and thats the main diffrence?

hasty canopy
#

There's an entire execution order

teal delta
#

the more you know i guess

lucid valley
daring cove
#

Hey, there.

How to reduce slip in wheel colliders?
I have been modifying Sideways Frictions values and Forward Friction values, but can't figure it out.

My wheels are constantly turning left or right uncontrollably.

dusk apex
plucky inlet
#

Hello everyone, is anyone firm with Editor and PrefabUtility? I am trying to find out, when an object is modified in the scene, somehow this is giving me a zero count list, even if I add something to the prefab. I also tried to update delegate, but that only happens when the prefab is actually saved.

Returns 0 List => PrefabUtility.GetObjectOverrides(childTransform.gameObject).Count);
Returns 12 Length Array no matter the changes => PrefabUtility.GetPropertyModifications(childTransform));
dry geyser
#

Good afternoon, I have a question about a movement I'm doing, currently I have a vehicle that moves by physics and I would like to make this could not hit the walls and slide down these, does anyone know any way to do it, if with raycasts or some mathematical formula similar to PID?

plucky inlet
#

Hello everyone is anyone firm with

soft shard
thick socket
#

attempting to do sorting on a list but now sure how to go about it

#
List<VisualElement> SortedList = itemsList.OrderBy(o => o.???).ToList();

I have a itemsList of VisualElements...but I want to sort by a background color inside of the visual elements

#

aka by

tmp = itemsList[itemAtIndex]
tmp.Q<Button>("ItemButton").style.backgroundColor;```
#

that background color

#

hmm

#

might just be easier to have everything in a dictionary

plucky inlet
thick socket
cinder ether
#

Hello, how can I separate game input from UI input ? For example, when I click on a button, my script from a totally different game object also recognizes the click

thick socket
plucky inlet
thick socket
#
List<StoreItemsVE> SortedList = itemsList.OrderByDescending(o => o.itemRarity).ToList();

how could I add in like a secondary sort? (this "should" work for sorting by rarity)

#

ex) I want them to sort by ItemType, then secondary sort by ItemRarity

thick socket
thin aurora
#

Tip: googling a specific question about something most likely gives you the answer, since many people before you probably wondered this

#

Source: My answer was a 5 second google search

thick socket
#

alright here is an actual one I can't figure out from google

thin aurora
#

First link worked for me 🙃

#

Not to bash of course, googling is a very good skill to have

thick socket
#

inside of a sort, I have an enum I want to sort by...how can I chose the "order" of high to low items?
alright here is an actual one I can't figure out from google

public enum ItemType
    {
    Undefined,
    Currency,
    Loot,
    Material,
    Supply,
        Recipe,
    Weapon,
    Armor,
    Helmet,
    Shield,
    Jewelry,
        Backpack,
        Coupon
    }

if I wanted a different way to sort this enum how could I do that?

#

aka I want recipe, then weapon, then supply as the sort order for example

plucky inlet
thin aurora
#

It sounds very specific

mental rover
#

enums are just ints

thick socket
#

like chose the order in which it sorts by

thin aurora
#

An enum is just a list of numbers so if you use Enum.GetValues you get a list of them

thick socket
#

(enum is from an asset and could really mess up asset code if I change values)

plucky inlet
mental rover
#

what you could do is create a wrapper that associates a secondary sorting priority value for each, then sort by that value - though that will be something extra you'll need to maintain

#

just a static dict that maps enum to another value, say

plucky inlet
#

Or just use the NAME plus an INT to be able to sort the enum by name but still got its correct int to call on

thick socket
#

sweet thanks guys 🙂

#

last question...hopefully

#

why can't I set my itemsList to the new SortedList?

plucky inlet
mental rover
#

it is outside of the scope

plucky inlet
#

itemList is a list of whatever type and SortedList is a type of the namespace Collections

#

And that 😄 outside of scope too, I would not call it uppercase sortedList tho, cause it seems to be already a thing in collections

thick socket
#

ah gotcha...renamed SortedList to sortedList

#

and now its fixed 😭

#

didn't know SortedList was a keyword(also just stole the code from stackOverflow)

plucky inlet
#

yeah, bad habit, abandon this! 😄 copy paste without thought will get you 0 knowledge

thick socket
#

I mean, I understood the code, just didnt realize the variable name they chose was bad lol

#

anyway, thanks everyone!

#

sorts was my most hated things from my coding classes like 4y ago lol

reef peak
#

i just shoot it towards the ball

warped condor
#

If anyone has time to help could you please DM me so I can send you the details of my problem since my issue seems to be a bit complex to post here. Put simply though I'm having trouble updating a object to match a target position exactly each frame using unity's physics, without causing jitter and also any objects that have a hinge joint component freak out and jitter a lot when interacted with even though I'm using methods such as Rigidbody.MovePosition and MoveRotation

plucky inlet
leaden ice
#

(and pick one channel, you xposted to physics)

warped condor
leaden ice
#

It'll be your thread

#

you can flood it all you want

#

Post code as per

#

!code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

leaden ice
#

NaAquelo's physics thread

warped condor
#

Thanks

fiery oracle
#

does anyone have experience with building large open world games? wondering how do i manage terrain chunks for performance

#

i am considering activating terrains around the player on a 3 x 3 grid:

#

with each terrain tile being 512 x 512, will this be too large for optimization purposes?

#

(i am also using culling)

leaden ice
#

every game is different

fiery oracle
#

right, are there other approaches I can explore?

leaden ice
#

approaches to what?

#

Profiling?

#

Or what?

fiery oracle
#

terrain streaming

leaden ice
#

Other approaches besides terrain streaming?

#

Not sure I understand

fiery oracle
#

approach to terrain streaming

leaden ice
#

you haven't really described any approach

#

you just said you'd keep 3x3 loaded

fiery oracle
#

right, that's one approach

#

tiles are activated as the player moves around

#

would love to hear how someone who built an open world game handled this

leaden ice
#

that approach is what terrain streaming is

fiery oracle
#

okay, thank you

potent sleet
tired egret
#

I’m working on Lag Compensation and I ran into a problem. On the server I instantiate a “RewindHitbox” game object and then immediately shoot a Raycast. But the problem is apparently at least one FixedUpdate needs to run for a raycast to hit a newly moved object.

potent sleet
#

They do "portals" when to activate terrain relevant to player @fiery oracle

fiery oracle
#

i actually am watching that talk now! i've seen that talk years ago too

potent sleet
fiery oracle
#

thank you

grim marlin
#

Hello, trying to make a camera for my character. Work well in first person , but in third person the camera does not orbitate or stays in the back of my player. Not sure how to do it.

    public void Look(Vector2 lookDirection)
    {
        // Convert mouse input to rotation
        float mouseX = lookDirection.x * Time.deltaTime * sensX;
        float mouseY = lookDirection.y * Time.deltaTime * sensY;
        yRotation += mouseX;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -45, 45f);

        // Rotate camera
        transform.rotation = Quaternion.Euler(xRotation, yRotation, 0f);

        // Rotate Player
        playerOrientation.rotation = Quaternion.Euler(0, yRotation, 0);
    }
main shuttle
fiery oracle
#

okay, thank you