#archived-code-general

1 messages · Page 394 of 1

coarse nexus
#

well the null check is there

#

but the error is the same

#

what

#

the

#

qmlerkwdbnl

modern atlas
#

why are you setting it to null in the declaration? _intervals = null;

coarse nexus
#

just a reflex

#

to set everything null until i change it

#

but its not null in the editor

modern atlas
#

ok so don't assign it null to begin with and try running again

coarse nexus
#

bro if i dont assign anything its automatically null

#

and i set values in the editor

#

so its not null

#

and it works for the character

modern atlas
#

well you are going to get the null reference exception if you:

  1. don't apply a null check on the instance of the class/object

  2. it's set to null upon start

coarse nexus
#

the serializefield sets it

#

to something

modern atlas
#

?? SerializeField only makes it visible in your inspector

heady iris
#

the field initializer is applied when the object gets constructed

#

Unity then applies serialized properties to the object

#

iterate over every item in the list and call PulseScale on it

#

Are you creating a BeatSync by adding a component to something via code?

modern atlas
# heady iris this will have no effect

i'm not entirely sure what his code structure looks like. what he's sharing with us seems quite vague as it seems like there are other scripts in play

heady iris
#

I agree that this is a very confusing mess of random code, yes

#

I need to see all of the relevant scripts in something I can actually follow -- one paste link per script

#

no screenshots

#

I do not currently understand what you are doing, which makes it very hard to offer any advice

gilded crystal
#

Is there something else other than fov that affects the camera scale? Specifically I'm asking about pip scope calculation, for example in escape from tarkov a 1x pip scope has 15 fov on the camera, which gives a similar result as a non-pip reflex scope that changes player camera fov to 55.

However if I try to replicate the same 15 fov camera setup in unity, the scale in scope is much higher than in game. Could someone please explain this to me?

somber nacelle
#

!collab 👇

tawny elkBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

muted mirage
heady iris
#

ah, proper scopes that only zoom in inside the scope

#

(picture-in-picture)

#

One important thing is that unity uses vertical FOV -- maybe Tarkov uses horizontal?

gilded crystal
#

Hi, I believe it is vertical as shown in their community modding sdk project. Besides, I'm modding 7 days to die and checking the camera at runtime with unity explorer, it also says it's vertical

#

Here's some comparisons I took before:

#

as shown in the picture, the 2 cameras have the same fov but significantly different scale. I think I have copied the properties from the main camera via Camera.CopyFrom

#

I'm still hoping to get some hint on what might be affecting the zoom😭

worn sedge
#

hey guys um

#

im not necessarily making a game

#

im making a library app for my school

#

any ideas?

cosmic rain
#

Many ideas. Try eating ice cream with mustard.

modern mist
#

how do i assign a material trough script? here is what i did already (simplified because i am using arrays of objects and materials)

MeshRenderer Renderer = Block.GetComponent<MeshRenderer>();
Renderer.materials[0] = BlockMaterial;

all of the objects end up with default materials
any idea what i did wrong, or how to troubleshoot it?

gilded crystal
#

Renderer.materials does not return the original array

modern mist
#

oh

open bluff
#
            float avoidFloorDistance = 0.1f;
            float ladderGrabDistance = 0.4f;
            if (Physics.Raycast(transform.position + Vector3.up * avoidFloorDistance, targetDirection, out RaycastHit raycastHit, ladderGrabDistance)) {
                Debug.Log(raycastHit.transform);
            }

I have a basic raycast code in Unity, this raycast does not work if the collider of the opposite object is triggered, if not, how do I solve this problem? I am using Unity 6. I did not have such a problem in other versions.

robust dome
fiery elm
#

any good ways to make minigolf physics not suck? had to lock rotation on the ball because hitting walls made it spiral and fuck up the arc, but that just resulted in the ball not wanting to slide into the hole

#

ama post the border and ball pmats in a sec but already nuked angular drag n it fidnt help

modern mist
deep stirrup
#

I have encountered a strange problem: if I set canvas scaler to "scale with screen size", the sliders just break when the resolution of game window is higher than roughly 1600 by 900. I can press the handle, but I can't move it with my mouse. It happens in both editor and build, maybe I am missing something?

trim schooner
#

Not missing something, you'll just have setup/done something wrong

#

!ask

tawny elkBOT
hexed pecan
# gilded crystal

I'm having trouble understanding your issue.

the 2 cameras have the same fov but significantly different scale
What 2 cameras? Do you mean the player cam and scope cam? Or the scope cams in your screenshots?

#

I guess im asking what is the real issue here/what is not working properly

#

I personally had to just eyeball the FOVs for PIP scopes

gilded crystal
hexed pecan
#

Ok you didnt mention that or im blind

gilded crystal
#

but as you can see, the sphere in the editor is correctly scaled while the runtime camera actually downscale the cube

hexed pecan
#

Okay I see now

gilded crystal
#

I'm completely clueless about what might happen in between, so any suggestion is appreciated😭

hexed pecan
#

Doesn't the player camera's fov also change when you aim in 7d2d?

#

Is that replicated in the editor?

gilded crystal
#

It actually supports zoom in and out the player camera with mousewheel, and doing that in game does not affect pip camera at all

#

And it shouldn't anyway

#

I can simulate it in editor of course, it's basically another fov change

#
  1. player camera with 85 fov
  2. player camera with 37 fov as the previous in game image
hexed pecan
#

So the viewmodel doesnt scale with the player camera's FOV?

#

Because these look identical to me

civic girder
#

How are "level up stats" usually implemented?
For example: in rpg maker, you'd have these curves where you can set the stats for each level (refer to screenshot)
Example 2: A game like pokemon or any rpg really, where each unit levels up and gets different stats (some get more atk, others more hp, etc etc).

I'm aware that I'd need to built my own system in unity. Right now I have my stats in a ScriptableObject and I'm using composition to set it in my monobehaviour.

class Unit: MonoBehavior {
 [SerializeField] StatsSO stats;
 public void Awake(){
    //copy stats to class variables as a reset per battle
    // also allows for easier time dealing with stat changes due to buffs/spells
    // since the SO is treated as read-only for initialization
    // and getting the "original" data
    this.atk = stats.atk;
    this.hp = stats.hp;
    ....
 }
}

However, I'm not sure how to handle leveling up. Making an SO for each unit and for each level (Each unit can go from 1-9 and each unit has a different stat progression, so each should have their own formulas/curves) seems time consuming and probably not the way.
Does this mean that each SO needs to be aware of:

how much exp for the each level?

The stats/curve at each level

Then it becomes a matter of comparing my current level and experience points with the next level's?

If so, are these curves often generated using json/external scripts?
or are there some plugins people typically use? (ideally: official packages or something of the sort)

Sorry for the beginner question, I'm just confused.

hexed pecan
#

@gilded crystal And are you aware if 7d2d uses a separate camera for the viewmodel (arms+gun)?

gilded crystal
#

Yes, it was achieved by bliting a weapon camera render texture onto the player camera texture before, and the devs removed the weapon camera and achieved the same effect by setting some material property block for fpv renderers in the latest update, and I've also added that script to my editor project so it works the same way

vernal goblet
#

How do I publicly mention MinMaxSlider or mention it at all

gilded crystal
#

Btw, from the escape from tarkov modding project, the pip camera starts with 15 fov for 1x zoom and that's what worked for me in 7d2d game too

vernal goblet
#

AFK real quick

gilded crystal
#

Math seems dead to me

vernal goblet
#

its not connected to sliders??
thats comfusing

mild bridge
#

wow i love interfaces wtf i just figured out what theyre used for

vernal goblet
#

Apparently it wasn't some sort of property I could use to get from sliders (the component)

#

but now that I'm trying to just get sliders themselves I noticed the component sliders can't be drag and dropped as a public property

cursive moth
#

Hi, I am trying to create a class that can be serialized in json.
It's working well so far, with one exception.
If I don't inherit from anything, it can't be null.
If I inherit from UnityEngine.Object, json utility never fills it with data(ig it's incompatible?).
If I use ScriptableObject it requires me to create an actual instance of that so, no thanks.
Is there an alternative I am missing?
I explicitly need the object to be null by default and also be able to get a value from the json utility.

To provide a bit more context, I have this function for loading data from json:

        private void LoadConfig()
        {
            Data.ResetToDefault(true);
            JsonUtility.FromJsonOverwrite(_configText, Data);
            Data.Load();
        }

It basically resets values to default, overwrites the Data class and then calls the Load() function on it.
Issue is, I want certain things to start off as null in that Data class, when it's overwritten.
Thanks in advance!

fiery elm
#

i assume thats what youre aski g for anywho

cursive moth
hexed pecan
#

Why would you need to inherit from anything?
Ah i see the nullability

thin aurora
#

I suggest you use Newtonsoft instead

#

Your issue is fixed then

cursive moth
#

issue is, with json utility I can simply overwrite the entire config with any data, that simplifies the workflow if you have several types of config

#

is newtonsoft able to do that too?

thin aurora
#

JsonUtility is a shitty tool that has existed for a long time and it lacks the most basic features

#

As far as I know Newtonsoft works the same and works better on every level

#

Unfortunately there are issues with Unity when it comes to serializing code because Newtonsoft (and any other tool for that matter) expects you to use properties rather than fields

cursive moth
#

ok, let me look into that, should be fairly easy to replace then

thin aurora
#

And Unity has had a very poor system of conventions and it uses a lot of fields

#

So types like Vector3 need a bit of extra work to get working, but it is perfectly possible

cursive moth
hexed pecan
#

I wonder if you could use [SerializeReference] with the default JsonUtility to support null values

#

Since it allows unity to serialize null values

thin aurora
#

When I tried JsonUtility I could not get null working whatsoever

#

Had to resort to the same system Nullable<> uses, with an explicit HasValue bool

cursive moth
# cursive moth that's fine with me, as long as I can make them null by default

To explain my issue a bit further, I am making a music visualizer that's also a bit of a framework?, if you'd call it that.
It offers an easy way to create new scenes and configs for those scenes, with the exception of custom data types that should be stored.
Issue arises from the fact I'd like users to be able to easily define default values that would be applied if user ones are not found in config, for example the thing seen in the first picture.
It should look like this in the class json should load into:

        [SerializeField] [GradientUsage(true)] public Gradient DefaultCubeColorOverLife;
        public ConfigGradient CubeColorOverLife;

Now, the issue is, I have no way of assigning the default value if the user defined one is not found in the config because the ConfigGradient is never null.
That would go for any other class and, therefore, I am looking for a way to make the class null by default if not found in the config.

hexed pecan
cursive moth
thin aurora
#

JsonUtility is unable to do a lot more

#

root objects, dictionaries, stuff like that

#

If you are going to make workaorunds for literally everything you are better off switching to a better serializer

cursive moth
thin aurora
#

As far as I know Vector3 is one of the few instances where Newtonsoft does not work, which is only because of Unity's bad syntax

#

But there are examples on how to support those online

cursive moth
#

oh my bad, I thought you said newtosoft

hexed pecan
thin aurora
hexed pecan
#

The doc says this for SerializeReference

cursive moth
#

ok, it sounds like I should switch to a better json serialization lib, lemme d that first

knotty sun
hexed pecan
#

So I thought since unity uses JsonUtility internally maybe it would support that

thin aurora
#

When Unity switches to CoreCLR you will also be able to use System.Text.Json which is extremely fast and performant, and it works very similar to Newtonsoft

#

I would assume they also fix their shitty conventions by then

cursive moth
#

wish I could wait that long, I am close to making this fully functional and will switch to a better implementation when it's available

knotty sun
hexed pecan
cursive moth
hexed pecan
#

Genuine question

thin aurora
knotty sun
#

it's not, none of Unity Structs have [System.Serializable] so are not serializable out of the box

thin aurora
#

Perhaps the conventions do remain the same, though. I sure hope not

thin aurora
#

To be fair, this is not an issue with convention. Just a missing attribute

eager yacht
#

They already have to maintain api difference for older unity versions where it is missing newer things. So not that new

thin aurora
#

You see JsonUtility does not break because it serializes fields rather than properties

#

Though you could configure Newtonsoft to serialize fields and not properties, so I suppose you can work around it

#

But generally properties are the things that represent shareable data and/or points of access to data

cursive moth
thin aurora
#

Vector3->Vector3->Vector3->Vector3->Vector3->...

knotty sun
#

which is why Unity imposes a 10 level limit on recursion in it's serializer

thin aurora
#

You could probably also impose a limit on Newtonsoft, but the better way would be to add a custom type serializer

#

Considering it also serializes a lot more than just this, which is garbage data. Only the xyz component is important

#

Here is a solution. Pretty sure these converters all fix the issues with newtonsoft

knotty sun
#

tbh as Unity has their own branch on Newtonsoft you would indeed have expected them to have fixed this

eager yacht
thin aurora
#

You can't really blame a tool that is designed to serialize properties

#

How would it know?

knotty sun
thin aurora
#

Newtonsoft doesn't assume what it has to serialize, that would be silly. It's up to the developer to explicitly ignore properties with [JsonIgnore]

heady iris
#

yeah, I use that package

cursive moth
#

ok, so if I got this right, I should switch to newtonsoft, add the repo as a submodule, and use that since it already has color serialization, correct? (nvm, it doesn't have the gradient de/serialization, which is what I need)

eager yacht
#

It mainly just annoys me when I can't tell it "hey serialize properties, but just ones that don't have logic". Like that could just be a serialization setting flag since it already expects properties. So I instead have to make a custom contract resolver to fix that project-wide (which is annoying to deal with imo).

heady iris
#

now we're doing TURBO reflection 😉

wheat spruce
#

I want to create a tool/system for my game, and I'm stuck on finding a way to put it all together.
I'm not keen on the idea of my GameObject having 8 different components, initilisation is a challenge (especially when one component relies on another), and it honestly doesnt feel right to lay out everything like that

hexed pecan
#

You could add a component that handles initialization and maybe also ticking the components if needed

wheat spruce
#

at the same time, there's no way I'm putting everything that would be in each component, into one single class

hexed pecan
heady iris
#

it is nice to have something that's "in control", yes

wheat spruce
#

not sure if it helps, but here's an overview of the way everything is connected. Each block would be a different component

heady iris
#

this might be a stupid question

#

but you know that Unity has tilemaps, right

wheat spruce
#

I dont have any plans for tilebased stuff like unitys 2D system

eager yacht
heady iris
#

Hm, that does sound tractable

eager yacht
#

Yeah it is, I just had to do it manually LUL Solved all my unity newtonsoft problems instantly

heady iris
#

I was thinking of properties that just return or set another field

#

but then that field would need to be serialized anyway

#

so there'd be no point in serializing the property

wheat spruce
#

my tilemap system is purely so I can keep track of the design of the garden and so I can generate it accordingly, its not related to the context Unity has for the term

thin aurora
#

Why not just specify the property should be ignored with something explicit like an attribute? If you were to put in the assumption that everything without a backing field has to be parsed then that is going to introduce some weird unexpected bugs

wheat spruce
#

I'm wary when it comes to having a class derive from MonoBehaviour, I dont really know if there is a catch to it. But I'm thinking something like this

public class GardenBase : MonoBehaviour
{
  void Awake()
  {
    //different elements constructed here
    //like a Rectangle to define the bounds of my garden
  }
}

public class Garden : GardenBase
{
    //as GardenBase defines all the parts of my garden system
    //this Garden class is where I can write the actual logic
}```
#

I want to avoid my Garden class having a giant chunk of initialisation stuff, and as its purely a system of related components, it seems logical to have a base class take care of setting out all the parts of it

heady iris
#

Perhaps "Rectangle" shouldn't be a MonoBehaviour at all

wheat spruce
#

oh its not, its a struct

heady iris
#

ah, okay

hexed pecan
#

I mean, you can do this if it feels more organized to you

#

It's also possible to make a partial class and split a class into different files

heady iris
#

I tried that once and it was icky

#

it's fake organization

eager yacht
# thin aurora As in with an explicit backing field? Because I don't see why you would ask for ...

I've never needed, or wanted, to serialize a property that has logic on it in any type 🤷‍♂️

If you were to put in the assumption that everything without a backing field has to be parsed then that is going to introduce some weird unexpected bugs
It already tries to do that though 🤔 , unless you put the attribute to ignore the property. That's a problem if you don't have access to a bunch of types and you run into cases, like Vector3, where it has a logic property recursively serializing itself. So you either have to make a wrapper type (per type), a converter (per type), or a contract resolver. Instead of just letting me specify that I want to exclude properties without backing fields.

Anyways, this is just something I've run into in many work projects, so just a slight rambling.

heady iris
#

yes -- nomnom's problem is that Json.NET is overly aggressively and tries to serialize every single property

eager tundra
#

you can add the [JsonObject(MemberSerialization.OptIn)] attribute to the class and serialize whatever you want explicitly

young tapir
wheat spruce
young tapir
#

One class or one use of the script throughout your entire game

wheat spruce
#

definitley not a one script game

#

I just mean theres never going to be variants that derive from GardenBase

#

nothing like SnowyGarden : GardenBase or ForestGarden : GardenBase

thin aurora
#

Regardless I'm not sure why you can't just insert an explicit attribute. Everybody does this

#

That's a problem if you don't have access to a bunch of types and you run into cases, like Vector3, where it has a logic property recursively serializing itself.
This is very much just bad design, though. If they didn't default to a shitty serializer they would have likely fixed this on their end already

#

But now you have to resort to converters since they choose JsonUtility over Newtonsoft

young tapir
thin aurora
#

The only issue here is that you can't serialize everything, but this is something I have never had an issue with. If you serialize something, it is always a type that is supposed to be serializable. You would not serialize a whole Monobehaviour, for example. You would have a data object that is serialized. (it would not make sense anyway because you can't deserialize it back into a Monobehaviour)

young tapir
#

One central garden base per scene, which you just access indexes of. After defining them in the component

wheat spruce
#

I havent worked with ScriptableObjects yet, but are they also not really intended to create many variations of a base?

rigid island
young tapir
#

You'd only need one. Or one per scene to define them

#

The array would store loads of different, pre-defined garden shapes. I actually used them for an audio setup which works pretty nicely. Same objects for the entire project

rigid island
#

they main difference is that SOs can have instances in the asset view since they are...assets

heady iris
#

ScriptableObject lets you create your own kinds of unity objects

cursive moth
# thin aurora Your issue is fixed then

Dude, I am so thankful to you.
This fixed 12 hours of my pain in 10 minutes 😭
I simply replaced:

JsonUtility.FromJsonOverwrite(_configText, Data);

With:

JsonConvert.PopulateObject(_configText, Data);

And everything is working flawlessly now.
I have to do some more testing with this but it's looking really good!

heady iris
#

notably, these objects aren't derived from Component

#

This lets you create assets out of them

#

much like a Material

#

you can totally just create a material through code and never had an asset

#

(and this happens very frequently, in fact)

#

ScriptableObjects are good for when you need to share a piece of data among many scenes or assets (prefabs, other scriptable objects, etc.)

thin aurora
heady iris
#

They aren't a good fit if you just need to reference a piece of data once

#

That's where you might use [SerializeReference], along with a package to provide a type selection UI

#

That lets you serialize a field that holds a non-unity-object

#

and, vitally, lets you store any derived type

cursive moth
heady iris
#
public class ParentSO : ScriptableObject { public int parent; }
public class ChildSO : ParentSO { public int child; }

[Serializeable] public class ParentPOCO { public int parent; }
[Serializeable] public class ChildPOCO : ParentPOCO { public int child; }

Given these classes:

public ParentSO foo; // fine, can hold instances of ParentSO or ChildSO -- it's just a reference to another unity object
public ParentPOCO bar; // bad, can hold a ChildPOCO, but its "child" field won't be serialized!
[SerializeReference] public ParentPOCO bar2; // good, will correctly store both ParentPOCO and ChildPOCO
young tapir
#

Just as a small example. ^^

#

Oop, @wheat spruce meant to ping you in that lol

wheat spruce
#

That could be useful, for the moment I'll see how much progress I can get without a scriptable object

#

Unless theres some killer feature or advantage that SO have over me writing a generic base/derived combo

young tapir
wheat spruce
#

ah, missed that one

young tapir
#

My main reason is ease of use lol. I'd rather use a scriptable object than remake scripts if I'm going to use them a looot.

#

Even with Copy/Paste

wheat spruce
#

yeah, if I was going to create many variations of my Garden class, I can see the benefit

#

essentially everything in the diagram I posted earlier, you can think of them sharing the same namespace

hexed pecan
#

I usually use SO's as containers for a POCO data classcs public class ThingAsset : ScriptableObject { public ThingData data; }

[Serializable] public class ThingData { ... }```
This way I don't always need a SO instance if I want to deal with ``ThingData``
#

But can easily use SO to reference a ThingData if I want to use a premade one

#

(Not necessarily related to your discussion - just throwing it out there)

young tapir
#

Then again, I have almost no knowledge on the subject of saving stuff between play sessions lol

hexed pecan
#

Not really - anything inheriting from UnityEngine.Object isn't supposed to be serialized to JSON

#

Which is another great reason to not directly store the data in the SO but in one of its fields instead

young tapir
#

Hm, makes sense. A lot of serialization seems like really well made trickery

heady iris
#

I mean, you could totally serialize data from a ScriptableObject and then shove it back into another instance later

#

But, much like Components, you aren't meant to construct these objects on your own

knotty sun
heady iris
#

I give many of my SOs a guid field. I use that to serialize references to them

#

and to look them up when deserializing later

heady iris
#

Deserialization is the job of all the king's men :p

knotty sun
# young tapir How so? 👀

because deserialization can have consequences, especially for properties so you have to do it right and in the correct sequence

young tapir
heady iris
#

If creating your objects includes side-effects, or the order of operations is very important (maybe Foo needs to have its Bar assigned before its Baz assigned), it can get very icky

#

Cyclic dependencies do not induce joy

eager yacht
# thin aurora > That's a problem if you don't have access to a bunch of types and you run into...

Now that I have some more coffee (and had to do some stuff), yeah that's fair, albeit it's still weird how props like that are serialized by default to me. Like if I serialize the inputs (adjacent fields), I wouldn't expect an output (the getter) to be serialized too. But it is what it is, so I just live with it lol.

The only issue here is that you can't serialize everything
In one project we had to serialize an ecs world (so everything), and we used json just so we could quickly test with world snapshots (couldn't do binary saving yet due to data ambiguity in a few spots). So that was an issue if things stored vectors anywhere LUL Another one was when we saved settings to json that had some vectors; that one is the more basic case anyhow (and we ended up just switching to toml).

prisma hatch
#

hey fellas, just watched Brackey making an audio manager, and that got me questioning, whats the difference between coding your own audio manager and using FMod?

heady iris
heady iris
#

FMOD makes it easy to combine multiple pieces of audio into a complex event with randomization and controls

#

You can totally do all of that yourself (I did for a while)

prisma hatch
#

I see

wheat spruce
#

actually, now that im writing the base class, I've hit a similar problem as before.

public class GardenBase : MonoBehaviour
{
  GardenFloor Floor; //defines the bounds of my garden, can also trigger events ie OnFloorClicked

  void Awake()
  {
    //option 1
    Floor = GetComponent<GardenFloor>();
    //option 2
    //dont use a component, hardcode GardenFloor into GardenBase instead
  }
}```Option 1 doesnt avoid the fact that I dont want a bunch of additional components, and option 2 also isnt really a good solution either.
prisma hatch
#

but are there any downsides to doing it yourself? (beside taking a tad bit longer)

#

cause if not then I guess I wont touch FMod, unless it brings in some very nice QoL changes to the project as a whole

heady iris
#

I was really on the fence about FMOD for a while

#

because I figured it didn't do anything I couldn't do myself

#

switching to it was certainly a Process (tm)

prisma hatch
#

its like re-learning FLstudio all over again to me

#

and yeah what I'm thinking rn is exactly how you've phrased it too

wheat spruce
#

GardenFloor is an integral part of the Garden, it defines the actual physical form of the garden, and most other elements rely on the Floor (like getting dimensions for a texture)

young tapir
heady iris
#

basically, if you don't feel that you're being creatively stifled by DIY, then give it a crack

young tapir
#

I personally think it's worth it, ya

prisma hatch
#

fair point of views

heady iris
#

you might not need fifty-dimensional underwater basketweaving features in your project

young tapir
# prisma hatch fair point of views

Plus, it allows you to tie in custom things while knowing exactly how the code works CatYes
Adding haptics to the collision was like 10 minutes of work with mine.

prisma hatch
#

these are actually pretty good reasons to consider ngl

#

thanks fellas

hexed pecan
prisma hatch
#

well, more or less I would just tip my toes in Fmod a tad bit before getting back to DIY (cause ive coded it for like half a day and would be FUMING if I change to Fmod after all the work ngl)

heady iris
#

I understand you can even use that in a built game

hexed pecan
#

I used FMOD embarassingly long without realizing you can use that to modify it in real time instead of having to quit playmode and rebuild banks 🤦‍♂️

#

Recently checked out the FMOD profiler, its pretty cool too

prisma hatch
#

oh god thinking of which is there anyway to make the load-time to playmode faster

#

it takes forever to load imo

eager yacht
#

I do wish I could wrap my head around the fmod + studio workflow. It seems so nice, it just never "feels right" when I try and integrate with it LUL

prisma hatch
#

this is like caveman (me) discovering fire (this doc)

#

thank you osmal, very cool

hexed pecan
#

Make sure to read it all though, there are some caveats

heady iris
#

I enter Play Mode in like half a second. It's pretty neat.

#

I have built the entire game to behave correctly with Domain Reload off

#

I recently discovered an interesting behavior caused by disabling Scene Reload!

eager yacht
#

Doesn't Awake (or Start?) not re-run

heady iris
#

on objects that already had Awake called, at least

#

so, ExecuteAlways objects

hexed pecan
#

Also someone asked some days ago if FMOD clutters your workspace
I'm garbage at answering stuff like that on the spot, but the answer is the opposite since you don't have all those audio files dangling around

heady iris
#

It had to do with physics.

#

I think I was having a problem where the pivot point of a joint was apparently changing even though literally nothing in the scene asset changed

#

Oh man now I have to go back and look at that again

#

Joints are already cursed

#

The problem would go away after a recompile

hexed pecan
#

I'm pretty sure theres something fucky about joint initialization

heady iris
#

since that reloaded objects

heady iris
young tapir
#

But, this isn't exactly code related 😛

hexed pecan
heady iris
#

I use PuppetMaster and pray

heady iris
#

It's pretty tidy

hexed pecan
#

Yeah same

heady iris
#

This does add another criteria for correctly going to a random old commit and having a working build

#

And, you know, at that point -- I might as well not version control my FBX files, since they're exported automatically from Blender...

#

I just need the importer settings

#

I'm getting bad ideas!

eager yacht
#

Is there a good generalized guide about the fmod workflow that you've used? I want to use it in the future, but as a non-audio person it just hasn't clicked yet.

heady iris
#

So imagine you want to make a "bullet impact" sound

#

that might be several smaller sound effects played together

#

a thunk sound, a gore noise

#

FMOD lets you create a single "Event" that sequences sounds

#

It can randomize which sounds it plays, apply filters to those sounds, and combine smaller events into larger events

#

If I want a "low violence" mode, I can add a parameter that controls whether any of the gore sounds play

prisma hatch
heady iris
#

You can punt a decent bit of logic out of your game and into FMOD studio

heady iris
hexed pecan
prisma hatch
#

fair point

hexed pecan
#

And still keep learning new stuff

heady iris
#

I did that for a while

hexed pecan
heady iris
#

and Unity now has the Audio Random Container for basic stuff

heady iris
#

slightly borked

prisma hatch
#

oh words?

heady iris
#

i've had issues with them just sending me to the landing page

#

I think I had to switch to a slightly older version of the unity integration

#

(that might be fixed by now; this was half a year ago)

hexed pecan
#

Btw @heady iris Do you use spatial audio with FMOD? And which one

heady iris
#

Oh boy

#

so I've implemented my own audio occlusion system

hexed pecan
#

Yeah but do you use like HRTF

#

I use Steam Audio's spatializer instead of FMOD's spatializer in my events

#

Directional audio is way more accurate

heady iris
#

I wish I could use Steam Audio, but I'm on an ARM macbook

#

pretty sure it doesn't work on that platform

#

I just use the built-in Spatializer

#

I had problems with it panning WAY TOO FAST for a while. I eventually worked out that FMOD was trying to output 5.1 surround sound

hexed pecan
#

@eager yacht And others, if you do have FMOD questions throw them in #🔊┃audio so maybe we can get some life to that channel too

heady iris
#

My occlusion system controls the EQ and reverb

#

we should probably be over there lol

heady iris
#

well -- I should probably be working right now, so I'll do that first 😉

late lion
#

I use Steam Audio for all my game jam games. So nice.

heady iris
#

I was looking into this a few months before that point

#

But I swear I've checked more recently

#

WELL

#

I'm going to look into this very soon

hexed pecan
#

One downside I have noticed is that the Steam audio spatializer really only supports mono sounds. So I use default spatializer for near sounds that I want to be stereo and then fade into spatialized sound when further away

#

Unless im missing something

#

Anyway yeah I'm gonna stop spamming this channel

prisma hatch
#

hey fellas, back at it with yet another question

#

is there a difference between using, say
void OnSmth

and

private void OnSmth

thick terrace
prisma hatch
#

thank you!

misty drift
#

Hello! Could someone please help me to understand how to handle different mobile screens in Unity?
I mean case when we have different aspect ratios. I feel like I had to cut part of the game, not shure how to handle it better

#

I feel like in one case I can just add black lines on the sides and it will be ok. But in case I have different resolution when not entire content fit screen, I'm a bit confused what to do.

soft shard
misty drift
#

I mean I feel scaling game itself will cause a lot of issues, but may be it's given to support different mobile resolutions.

soft shard
misty drift
#

This is one of my main concerns too, since right now I'm using camera (to world position), but I feel when it's resized I may have inconsistent behaviour.

soft shard
misty drift
# soft shard You can adjust the resolution in the Game window to see how your game will look ...

At the moment not all position depends on camera bounds. For example when I create level it's easier for me to place enemies by hand in specific position or coordinates (I have scriptalbe object config etc, so it's more complex than by hand but it's not important here). I assume if I will use camera bounds I will have to adjust those via some calculations, and it looks much more complex in this case than just using world positions for all. And enemy out of screen depend on camera.toworldposition. It's just a lot of guide use camera.toworldPosition for some reason, that's why I'm a bit confused.

soft shard
steep saddle
#

I feel like I'm going crazy. Using Unity 6 with the render graph api, and when I try to render a camera to a render texture, the resulting texture is super flickery...but only when my laptop is plugged in? I don't even know how to begin troubleshooting this

#

Well, it didn't do it in a build, with or without power to my laptop, so... Setting this aside for now, I guess

rocky jackal
#

IF i use this code to get the surrounding filled out tiles of tile X(the center one of the image) I would expect to get a debug log that is as follows:
false, false, false,
true, false, false, false, false, false
But i get what i get is the following:
false, false, false, false, false, true, false, true, false
Why is the order so wrong and why is there a second true statment ?

mellow sigil
#

It should be surroundingOffsets[x * 3 + y]

#

or y * 3 + x depending on how it's set up

rocky jackal
mellow sigil
#

You can calculate on paper how it behaves. It has to check all values from 0 to 8, if you do x + y it repeats values between 0 and 4

#

Put Debug.Log($"x = {x}, y = {y}, x + y = {x + y}, x * 3 + y = {x * 3 + y}") inside the inner loop

rocky jackal
mellow sigil
#

That just depends on what values are in the offsets array. It works because the value (-1, 0, 0) is set to element 3 which corresponds to [0][1] in the surroundings matrix

#

Although it's unusual that it's [y][x] instead of [x][y]

rocky jackal
#

i mixed up rows and columns, but i do understand it now and im happy it finally works

swift falcon
#

I need to create a dll that can be used in unity 2022 or newer. The project will be compiled into dll outside of unity and then used in unity by importing the dll. My question is, which .NET version my dll should target if i want it to be usable regardless of unity api compatibility level. Should i target the .net standard version used by unity or the .net framework

rigid island
swift falcon
rigid island
#

iirc standard makes it easier for multi-platform

swift falcon
#

I read the documentation and .net framework support in .net standard 2.1 was N/A so definitely not the 2.1 version

rigid island
swift falcon
#

Hmm okay thanks. But does .net framework 4.8 actually support .net standard 2.0 dll though? I only found the documentation for what .net standard support but not what .net framework support

rigid island
#

actually now that I read this I'd go with .net standard

Support for managed plug-ins compiled for .NET Framework is limited when you use the .NET Standard 2.1 profile in Unity. Any .NET Framework APIs that are also present in .NET Standard are supported. However, the .NET Framework API contains types and methods that are not available in the .NET Standard 2.1 profile.

#

idk the .net framework might give you more options with other .net libraries

swift falcon
#

Ah okay thanks

#

I'll try to search again

rigid island
solemn ember
#

hey guys

#

sometimes, my character will hold a weapon with both hands

#

do I have to recreate all animations for it to hold it with both hands?

#

or I can make something that only influences where the arms are

rigid island
distant niche
#

I'm using fusion to try to do active ragdoll multiplayer and my player 2 client keeps throwing this error and not rendering the physics. Any ideas?

distant niche
#

I see, apologies! Will ask there

uneven summit
#

not sure if this is the right channel, but i'm having an issue where while constraining my 2D player character's movement to a spline, the player character rotates if the curve is not directly horizontal to match the spline, wheareas i want its rotation to remain constant. I've tried freezing rotations in the character's rigidbody, but that doesn't work. any ideas on how i can keep the player character from rotating?

jade knoll
#

is it possible to assign a sprite from my assets to a sprite renderer via code. Without assigning it manually in the editor beforehand?

rigid island
#

the question is, why

jade knoll
#

can I use addressables for it?

rigid island
#

sure thats what they're for

jade knoll
# rigid island the question is, why

I am making a cardgame and I want to store decks in a database meaning the database will have lists of the card IDs as "Decklists".
To load them into the game I made a prefab for a "blank" card that has a sprite renderer for the cardart. I want the the cardart to be assigned into the prefab's sprite renderer when a Gameobject is created using that prefab.

#

and as to not have to create prefabs for every single card I want to use a generalized one that assigns name, art etc through the assets

rigid island
#

you could potentially make it addressable/asset bundle though anyway for maybe external assets

jade knoll
#

okay thanks i will see if i can find something

weary swift
#

!code

tawny elkBOT
weary swift
#

Hello, I want to make a moving platform for my game and I tried different things but nothing really worked. I got this version that still doesn't totally work and I need your help please. I use a CharacterController for my player, a rigidbody (kinematic with interpolation set as interpolate) for the moving platform. I do not want to use parenting. My current code is this, the player can stay on the platform but when I move in the opposite direction as the platform my player move slower. I think it's because the character movement are in world position and not local to the platform and I don't know how to correct it : https://hatebin.com/vdjdspcprv

left olive
#

it can handle the player on moving platforms. it has examples as well to help you out.

fast dune
#

Is it bad for performance to modify material properties every frame? Does it like recompile the shader or something

wheat spruce
#

Nah, it just sets the new value of that property in your shader. Next time the shader executes it's code, it will use whatever value that property is currently set as

lean sail
#

!collab

tawny elkBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

high condor
#

is there a way to make it so you can stretch the size of the window?

inner yarrow
#

Is there a way to use coroutines to move something for a certain amount of time?

vestal arch
high condor
#

nvm i found what i needed

vestal arch
zealous lagoon
#

Hello, wanted to get some opinions on this. Is it better to make delegate voids / events and have all your systems (like UI manager, audio, etc.) subscribe to them, or simply create a function which calls all the neccessary functions directly via static instances? In my game I'm kind of stuck with a combination of the two and was thinking of trying to eliminate one in favor of the other.

cosmic rain
robust dome
#

also if you are not familiar with Singletons, i would highly recommend you also make use of them. They can reduce your workflow really strongly.

#

in generell i think working with events is cleaner than creating a reference to everything.

#

as dlich metioned, a combination of events/references is not always a bad idea

#

you would find out what is clean and requires less work.

zealous lagoon
zealous lagoon
robust dome
#

ye

cosmic rain
#

You can proxy to the singleton via static methods too

zealous lagoon
cosmic rain
zealous lagoon
# cosmic rain It depends. You usually want a many-to-one relationship, rather than one-to-many...

I see, thanks for the tip! My gamemanager definitely has a bit too many events, like there are 16 or so right now :/
Then to trigger one a script can call a function on the gamemanager which makes it do some things related to the event (e.g. update score) and then calls the eventn notifying the subscribers. It's definitely getting a bit messy at this point so maybe I can remove some of the events and make it just call the functions those events would eventually lead to anyway

cosmic rain
# zealous lagoon I see, thanks for the tip! My gamemanager definitely has a bit too many events, ...

Maybe rething the dependencies that you have in your project. Sometimes it's better to pass a reference to a directly related object, instead of using an intermediary, like your gamemanager. For example, if you no have a chain like player - gamemanager - uiManager - uiPanel, it might be wiser to just pass the player reference to the uiPanel, and let it subscribe to the necessary event, so that the dependency chain becomes uiPanel - player.

zealous lagoon
fiery elm
cosmic rain
# fiery elm how did we get to that daisy chain

Just an example. In theory you could have something like gamemanager subscribe to a player event, like TookDamage, then call a method on uiManager like SetHPBarValue and the uiManager call something like SetBarFillValue.

#

It's not weird for a beginner to have something like that.

fiery elm
#

maybe but its weird to me

#

just have the uimanager subscribe directly

civic girder
#

what's the consensus on having GameEvents, UIEvents, etc classes?

Where their only job is to expose events for others to invoke/subscribe to?

#

kinda like unity's QuizU sample

cosmic rain
#

This kind of questions are usually a matter of preference and context.

civic girder
#

I'm just concerned about potential pitfalls tbh considering I'm not used to this design pattern this way (I'm familiar with events tho)

lethal ether
#

for some reason UI elements is deciding to give me a NRE

vestal arch
#

then you haven't set something properly, probably?
can't tell you much without any info

lethal ether
#
UIEvents.OnStartBuildingClick (UnityEngine.UIElements.ClickEvent evt) (at Assets/Scripts/UIEvents.cs:26)
UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/build/output/unity/unity/Modules/UIElements/Core/Events/EventCallback.cs:64)
UnityEngine.UIElements.EventCallbackRegistry+DynamicCallbackList.Invoke (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target) (at /Users/bokken/build/output/unity/unity/Modules/UIElements/Core/Events/EventCallbackRegistry.cs:228)```
vestal arch
#

Assets/Scripts/UIEvents.cs:26
check what you're trying to dereference there

lethal ether
#

im calling my nodePlacementSystem.EnableNodePlacement(); which is instantiated in the UIEvents file

vestal arch
#

then nodePlacementSystem is null

lethal ether
#

how can i make it not be null?

vestal arch
#

...set it?

cursive moth
#

Hi, I am working with newtonsoft json and my custom data types.
I made it all work, but there is a small thing I'd like to make better if possible.
Here's an example of my data type:

[Serializable]
public class ConfigVector2
{
    public float X;
    public float Y;

    public ConfigVector2()
    {
        X = 0;
        Y = 0;
    }
}
// Some other code I have

Now, it ofc works as expected, but in order to allow for default values set by scene creators(I am making kind of a framework, not a game), they have to use a specific approach.
It consists of defining the default value and config value:

[JsonIgnore] public Vector2 DefaultCameraClippingPlanes = new(1, 1000);
[ReadOnly] public ConfigVector2 CameraClippingPlanes;

When the config is reset to default values, assign null to the config value:

public override void ResetToDefault(bool silent = false)
{
    CameraClippingPlanes = null;
}

When the config is loaded, right before the OnConfigLoaded event is raised, assign the default value to the config value if it's still null:

public override void Load()
{
    CameraClippingPlanes ??= DefaultCameraClippingPlanes;
    base.Load(); // Invokes the OnConfigLoaded event
}

Let me explain what's going on here.
With regular values, such as int, string etc., simply assigning the default value directly in ResetToDefault() works just fine, because if not found in the config, it'll remain as it's default value, and if found will be fully overwritten by the new config value.
Issue with custom data types is that they usually consist of multiple fields/properties.
Good thing about JSON is that it allows you to not define what you don't need, e.g. you only wanna change the X value of a Vector2, go right ahead, Y will just not be loaded.
Whilst this is excellent, it also introduces an issue of the Y remaining as the default value if it wasn't null at the time of loading(you assigned the default value in the reset method).

#

I am open to any suggestions, thanks in advance!

#

Oh yeah, one more thing that could help with understanding how the code flows is this:

        private void LoadConfig()
        {
            // Using ResetSilent because the OnChanged event will get triggered by Load() anyways
            Data.ResetToDefault(true);
            JsonConvert.PopulateObject(_configText, Data);
            Data.Load();
        }
#

Please @ me if you have any recommendations.

shrewd hornet
#

can anyone here posit why my 'CustomPropertyDrawer' is not showing up.. not sure if this is the right place to ask this...
I have some working already.. but on this particular object, the inspector is looking very 'vanilla' and it is not showing up...

stoic sluice
#

Does anyone know if there's something special you have to do with your textures to use them with a URP Decal projector?

#

Transparent parts of the texture I'm projecting seem to mess with shadows.

vestal arch
#

!collab

tawny elkBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

vestal arch
#

we don't allow these kinds of posts here. we provide free community support

#

try doing it yourself and if you encounter any problems you can ask here for free

vestal arch
#

@novel monolith please also do remove both your job posts

untold crystal
#

i have this one little problem for some reason my animation does not transfer to what it should when the condition is met in unity if someon can help me fix ?

vestal arch
#

not if you don't provide any info. sounds like you have an #🏃┃animation issue rather than a code issue though

open bluff
#

There is a bomb attached to my character's left hand, but I want this bomb to be attached to both hands of the character. When it is attached to a single hand, it can cause problems in character movements and animations. How can I solve this problem?

open bluff
#

what exactly should I do?

vestal arch
#

do you know what IK is?

open bluff
#

yes

vestal arch
#

ok try googling for how to do that with unity

#

i know it's the tool for the job but idk how to do it lmao

open bluff
#

okey okey

#

thanks

weak snow
wheat spruce
#

I've made an event class, but I cant find a way to invoke the event.

namespace ZenGarden.Events
{
  public static class MouseEvents
  {
    public static event System.Action OnMouseClick;
  }
}```
```cs
using ZenGarden.Events;
namespace ZenGarden
{
  class Garden : GardenBase
  {
    void Update()
    {
      if(Input.GetMouseButtonDown(0))
      {
        MouseEvents.OnMouseClick?.Invoke();
      }
    }
  }
}```I get an error saying `The event MouseEvents.OnMouseClick can only appear on the left hand side of += or -=`. But I dont get why as all I'm doing is invoking the event, `+=` is only used to make something subscribe to the event, wont it?
#

I have a different class that has subscribed to the event correctly with MouseEvents.OnMouseClick += HandleOnClick;

#

just unsure how to actually call the event

vestal arch
#

isn't it just MouseEvents.OnMouseClick()

weak snow
wheat spruce
#

Invoke() is what calls the event, its not a method

#
public event System.Action TestEvent;

void Update()
{
  if(Input.GetMouseButtonDown(0))
  {
    TestEvent?.Invoke();
  }
}```This works without an issue
vestal arch
wheat spruce
#

I dont know if thats much good, totally different use of events to my static class, plus I dont think interfaces can be static

hexed pecan
#

Outsider classes can only subscribe to it but they can't invoke it because it is marked as event

#

To be clear, that keyword is not necessary

wheat spruce
#

How could I make the event so it can accessed anywhere like static easily allows?

hexed pecan
#

Read what I said 🤔

wheat spruce
#

ooooh!!

#

hell yeah!

#

So what is the purpose of event?

hexed pecan
#

It's like an access modifier in the sense that it prevents other classes from raising the event (invoking it)

wheat spruce
#

ah, I see

#

I've always felt a bit unsure with actions/events in general, but thats mostly out of not using them a whole lot

hexed pecan
#

They aren't that scary after all, try to get used to them, useful stuff

#

I remember it took a while for me until it clicked

wheat spruce
#

hopefully thats how it'll be once I finish the events class. I'll be doing EventArgs so I can pass whatever I need around, all stuff I've done before, so doing it a few more times should be good practise

vestal arch
#

im not super sure since i haven't used them, but from the SO post/answer:
events can be explicitly implemented like properties, but here where you haven't implemented one, it'll get an automatic implementation
and similar to how a property like int x { get; set; } has an internal backing field, an event also has one, which is private like with a property
and Invoke is part of the private backing field
so with an automatically implemented event, only the declaring class can invoke it

wheat spruce
#

I remember when I had no idea the idea of how to do MouseEvents.OnMouseClick.Invoke(); to call an event, and same with MouseEvents.OnMouseClick += HandleOnClick; to subscribe

#

its just practise at the end of the day

hexed pecan
vestal arch
hexed pecan
#

Ah I see

#

Never seen that done before

#

Or probably have but didnt pay attention

vestal arch
#

with that you can have an explicit backing field which you can specify access level for

#

idk why you'd want to do that, given the entire concept of events, but it's there

hexed pecan
#

I'd try rephrasing the question if you can't get answers

#

IMO it's good to have the actual question asked briefly at the beginning and then provide details

earnest moon
#

what are variables that look like this called?

#

was it event

#

i don't remember

heady iris
#

This is a UnityEvent

cursive moth
# cursive moth Hi, I am working with newtonsoft json and my custom data types. I made it all wo...

To sum this question up, I created a class, e.g. ConfigVector2, that I wanna deserialize with newtonsoft json.
It works well, but if I want both X and Y components to be overwritten when loading the new data, I need to do that explicitly in a function that gets called before loading the json data.
I am talking about the case where you defined X in the config but not Y, which is what I want users to be able to do, but it also complicates the workflow of a someone implementing this data type into their config.

cursive moth
heady iris
hexed pecan
#

I didn't mean "don't include details", I just prefer hearing the question first and then the details

heady iris
#

I'm pretty sure this leads to allocations though

cursive moth
#

again, this is fully functional, what I wanna do is simplify the workflow with custom types so you can simply reset the value in ResetToDefault() and not have anything to do with the Load() function

heady iris
cursive moth
#

if you use the approach I suggested where you set it to null in ResetToDefault(), and then assign the default value in Load() if it's still null, it'll work properly, this requires an additional line for each variable tho and is not very intuitive

heady iris
#

You write the default, then apply the data from the config file

#

or does PopulateObject wind up setting the Y field even if the config didn't have a value for Y?

cursive moth
#

no, that's what I'd like it to do, as of rn, it just leaves Y to whatever you set it to in ResetToDefault()

heady iris
#

What would the correct behavior be?

cursive moth
#

the way I'm thinking of it is, if the data type is found in the config, overwrite it with whatever data is available as a whole class, not just it's members

heady iris
#

That sounds counter-intuitive to me. I would expect anything I don't explicitly provide to keep its default value

#

if I specify X=10, I'd expect to get X=10, Y=1000

cursive moth
#

yes, it would be counter intuitive in 99% of cases, but not this one

#

let me show you why, give me 5 minutes

#

Ok, so where it starts being a problem is if we introduce colors.
If I define a color gradient like this:

    "ColorOverLife": {
      "ColorKeys": [
        { "Color": { "R": 1.0, "G": 0.4 }, "Time": 0.25 },
        { "Color": { "G": 0.0, "B": 1.0 }, "Time": 1.0 }
      ]
    }

You would expect it to look like it does in the first picture.
However, if we don't overwrite the default data, it'll end up looking like the second picture, since it's only adding on top of the default gradient which looks like this:

    "ColorOverLife": {
      "ColorKeys": [
        { "Color": { "R": 0.0, "G": 0.4, "B": 1.0 }, "Time": 0.25 },
        { "Color": { "R": 1.0, "G": 0.0, "B": 1.0 }, "Time": 1.0 }
      ]
    }

Does what I'm asking for make sense now?

heady iris
#

Sounds like you have bad defaults!

cursive moth
#

🤦

heady iris
#

Perhaps there's a distinction to be made

#

The default value for the Color field could indeed be white

#

But the default value for individual parts of a Color could still be 0

cursive moth
#

I think I know what you might be suggesting so let me make sure.
You'd like the default color to be defined as black, so that when the color is added via config, instead of adding to some random colors, it's added to black and looks correct, right?
If that's the case, it won't work.
As I said, this is not a game, it's sort of a framework that others can use and default values allow them to easily define how things would look out of the box.
Imagine if someone installed the visualizer, and instead of seeing the thing in the first picture saw the thing in the second picture.
I would argue that, at least, in case of colors, the way this works by default is counterintuitive.

gray mural
#

Having a Vector2Int start position inside of the Tilemap, what is the best way to find the nearest position with no tile in it?

heady iris
#

There's a difference between "no value at all" and "a partially specified value"

#

Perhaps that's where your problem lies

#

{} -> it creates a color that is white, because we didn't specify a color at all
{"Color": {}} -> it creates a color that is black, because we didn't specify the R/G/B values
{"Color": {"R": 1}} -> it creates a color that is red

cursive moth
vestal arch
#

how would you handle multiple possible results

cursive moth
#

the only way I could think of is setting the value to null, and then after the data is loaded, if still null, assign the default value, which brings me back to the original problem, not user friendly

wheat spruce
#

speaking of tilemaps, are those only suitable to be used with stuff like Sprites/Tile?
I'm implementing my own tilemap system in my game, but I figure if theres enough general use with the unity tilemap, it could save me a lot of trouble re-implementing 100% of that system myself

heady iris
#

However, there's nothing stopping you from creating tiles that instantiate prefabs

#

(in fact, this is built-in to Tile, I'm pretty sure)

#

These prefabs can contain Renderers of their own

#

and whatever else you want

#

The tilemap will only understand that you have tile X in cell Y

ivory ether
#

I have a question, im coding a game which i want to publish january - february, if I need help, can I just write here and ask questions or how does that work?

wheat spruce
#

I'm not using my tilemap to actually create anything in the scene, its just used as a way to store data to be used down the line

tawny elkBOT
ivory ether
#

okay

gray mural
# vestal arch probably just looping until you find one?

In this case, it would be better to start from the startPos with the square of 1x1, and check each tile, starting from e.g. top left and moving clockwise. The square will be increased in all four directions with every loop, so 3x3, 5x5, 7,7 etc., and the process is stopped once the empty tile is found.
I just feel like it will be better to implement with 2D Raycast? This means, shooting a Ray in the four directions, but I wonder how it works with diagonals and twisted paths

heady iris
#

I paint on a tilemap to place crates in a Giant Crate Room (it has a lot of crates)

#

Then I run a script that interprets the tilemap to spawn prefabs

jade knoll
#

I need a database for my cardgame. It's supposed to store user logindata cards and decks. I've used MsSql before but I would like to know if there's a solution for this provided by unity directly, since implementing it was a pain in the ass last time.

vestal arch
#

also, 2d raycast can't cast to hit.. an empty space

heady iris
#

Very very loosely

SetNull();
RunUserCode();
SetDefaults();
vestal arch
#

i mean, it could work if you just make your "empty" tile have a collider and bucket that in? i don't think that'd be a particularly good solution

heady iris
#

You do some setup, then call their function, then replace nulls with default values as needed

gray mural
vestal arch
#

also so we're on the same page; what do you mean by "closest"?
euclidean or taxicab or some other metric? does it account for walls, that kind of stuff
also #archived-code-general message

wheat spruce
#

All I do is take a rectangle which is the boundary of my garden, my tilemap class produces a basic array of tiles static Tile[,] _tiles;

vestal arch
gray mural
vestal arch
#

ah so like, king moves. i forget what that's called

gray mural
vestal arch
#

so you're just gonna count the results?

gray mural
#

Supposedly? It this is more efficient than enumerating through the tiles

vestal arch
#

i don't think that'd really work for far cases, you'd have to cast infinitely far

#

and you'd have to add more raycasts to account for diagonals

gray mural
#

Yes, and e.g. 2 tiles to top and 1 to left from the starting position won't be detected

vestal arch
#

looping is far more efficient for this

#

looping would just be accessing stuff, no need to check colliders and allocate space to report collisions

cursive moth
heady iris
#

I'm more than a little confused

gray mural
vestal arch
#

they're physics-based, so compared to algorithms, not very

wheat spruce
#

Can you not simply raycast to find the position on a plane, then use that position to look up which tile in the grid exists at that spot?

vestal arch
#

find the position
of what exactly

heady iris
#

the tricky thing is that you're looking for a hole in the tilemap...

cursive moth
#

that's what I've been saying the entire time :/

gray mural
#

The tricky thing is that these holes shouldn't be shifted on a single axis from the starting position. Not just diagonally, the offset can be (2, 5), so that the tiles are not detected with a line Raycast

heady iris
wheat spruce
heady iris
#

this sounds more relevant for clicking on the tilemap

wheat spruce
#

hole as in no tile exists at that location?

cursive moth
gray mural
heady iris
#

note that "inside of the Tilemap" is ill-defined

vestal arch
#

well there is a bounds

heady iris
#

You'll need to either use its current cell bounds (a rectangle that includes all of its cells) or provide bounds

gray mural
vestal arch
heady iris
#

suppose I have an empty tilemap

#

no cells are inside of the tilemap's bounds

gray mural
vestal arch
#

@gray mural also please answer this

how would you handle multiple possible results

gray mural
heady iris
#

in the first case, it's pretty obvious what you mean by "inside", but what about the second case?

vestal arch
# gray mural What do you mean by adding stuff outside?

"inside of the tilemap" is kind of a tautology on its own. a tilemap is its own universe, everything's in the tilemap
but that's not super useful, so there's a bounds that defines the "inside" where tiles exist
but nothing's stopping you from putting stuff outside of those bounds
so you can have stuff inside the tilemap, outside of the tilemap

heady iris
#

at least, if I expect for the empty spaces to be pretty common

#

if they are very rare, then I would want to store the empty tiles in a collection (ideally something that handles spatial queries well)

gray mural
heady iris
gray mural
gray mural
# heady iris i don't understand this statement

I suppose that tilemap contains tiles, meaning these tiles are inside of it. So by saying "an empty tile inside of the tilemap" I mean the tile, which belongs specifically to the tilemap being discussed

heady iris
#

unless you have an actual tile type for "empty space"

#

and anywhere that doesn't have a tile is out of bounds

gray mural
#

I suppose, it still has a maximum size, but I have mentioned the nearest empty space to the specified position

heady iris
#

Gotcha. In that case, just iterate over larger and larger rings until you find a spot with no tile

#

If you need to keep it in bounds, filter out cells that aren't inside of a BoundsInt

vestal arch
#

it might be reasonable to limit your search to the bounds of the tilemap

heady iris
#

not if you want to be able to place tiles that expand the bounds!

#

The nearest empty space to the water tile is to its upper-left

vestal arch
#

... i did say "might"

wheat spruce
#

basically creates a line from A to B, if a tile intersects anywhere on that line, you know the line aims towards a tile

gray mural
# vestal arch it might be reasonable to limit your search to the `bounds` of the tilemap

I just wanted to say:
If the non-empty tiles are definitely covered by the bounds, then, assuming the previously suggested algorithm is used, you will never have to go more than 1 tile further from the bounds to find an empty tile, which is only the case if the entire tilemap is covered with them. Then you won't have to limit the search to the bounds, since it is certain that the tile is found once increasing the searched rectangle's size to exceed the bounds by 1.

The thing is that the bounds' shape doesn't certainly match the search's, so it is definitely wise to limit the search.

gray mural
gray mural
spare swallow
#

Hey all, I'm a little lost as to why my Unity consistently crashes while this script runs (I have tested and can confirm this is causing the crash)

while (player.Inventory.isMovingitem)
        {
            player.Inventory.itemCursor.transform.position = Input.mousePosition;
        }

It's simply a boolean while statement, which moves a gameobject to the mouse's position, however it guarantees my UnityEngine will indefinitely stop responding, I've checked Unity's Editor logs and it shows nothing out of the ordinary. Is this a bug or something I'm missing?

knotty sun
#

because nothing is changing player.Inventory.isMovingitem ?

heady iris
#

Why would it ever stop running?

spare swallow
#

Ah, that's my bad. I had wrongly assumed you could use a while statement identically to an if statement, why doesn't this just throw an error instead of crashing Unity?

knotty sun
#

infinite loop, maybe you actually meant to do it

spare swallow
#

I see, I appreciate the help. My assumption that the while statement would work as an if statement until the bool was false. However, I now regretfully realize an if statement does exactly that haha.

heady iris
#

Well, yes, it does run until the thing you give it becomes false

#

(which is the problem)

#

An if statement placed in an Update method (so that it gets executed once per frame by Unity) sounds reasonable

spare swallow
heady iris
#

you run out of space on the stack and an exception throws

spare swallow
heady iris
#

(or Unity instantly dies, on macOS)

#

💥

#

An infinite loop doesn't consume any extra resources per iteration

slim trail
#

Hello

#

I have a problem with DiscordSDK

#

This code throws error: Tuple must contain two elements

#

I can't even run a game

heady iris
#

And what is line 33?

#

You cropped out the line numbers

slim trail
#

Oh

#

sry

#

it's "Activity activity = new()"

#

in UpdateRichPresence func

high condor
#

how do i make my game have a resizable window at set aspect ratios?

heady iris
heady iris
#

Can you share the entire script in a single paste? Use one of these sites !code

tawny elkBOT
slim trail
high condor
#

is that a thing unity can do?

indigo tree
high condor
#

Nah I just don't want you to be able to stretch the screen like this lol

#

i want you to be able to stretch the screen but not change the aspect ratio

spare dome
#

I have a question, If I were to write a boids algorithm wouldn't that be a poor "pathfinding" algorithm as well? I say this because the boids have 3 rules to make them act like birds "Separation, alignment and cohesion" as Sebastian Lague calls it, but with these 3 rules they have obstacle avoidance and the ability to steer to a desired point in a 3D space. Would this produce some sort of pathfinding effect if you make all of them steer towards a point in 3D space? (Of course A* would be a better pathfinding algorithm, just curious)

eager yacht
soft shard
# spare dome I have a question, If I were to write a boids algorithm wouldn't that be a poor ...

Im going to take a guess and assume it probably wont be very effective without also adding in a "scoring" system as A* does, otherwise while your birds may be able to avoid hitting eachother and getting around things, it probably couldnt follow the middle of a shortest path without basically skidding walls and other surfaces to get around things, but I also dont fully understand the exact algorithm your using on a mathematical level and how it sees the environment, so thats just a untested guess

heady iris
#

Each boid only looks at its immediate vicinity

#

So the algorithm will fall apart if an obstacle is too big to scoot around

#

The point of algorithms like Djikstra's and A* (the cooler Djikstra's) is that you can find the best solution no matter how bad the obstacles are

#

(assuming it's possible to get to the destination at all)

#

I've implemented Djikstra's for one of my game's system. Then I did A* for another...but the heuristic is currently return 0, so it's basically Djikstra's

#

😉

spare dome
#

Yeah the normal pathfinding algorithm such as A* is better for pathfinding in general but I was just curious if the boids algorithm could "pathfind" even if it wasn't the greatest at it

wheat spruce
#

Maybe if you had a target position boids move to, and you move the target along the best path to the goal...but that's just DjIkstra with extra steps

spark sorrel
#

You guys think it looks okay for a first game? Its for a "fun" class at school

wheat spruce
#

That looks neat!

spark sorrel
#

Trying my best haha. Imma need to add my character ennemies. Hope i dont fuck everything up

wheat spruce
#

I believe in you

#

💪

spark sorrel
#

Why in my script my Rb and speed doesnt show?

#

Am i missing smth?

swift falcon
spark sorrel
#

Idk im following tutorials lmfao

#

Its my first game ever☠️

swift falcon
spark sorrel
#

Horizontal movement

swift falcon
spark sorrel
#

Also need jump x)

swift falcon
#

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public float sprintSpeed = 10f;
public float jumpForce = 5f;
public KeyCode leftKey = KeyCode.A;
public KeyCode rightKey = KeyCode.D;
public KeyCode jumpKey = KeyCode.Space;
public KeyCode sprintKey = KeyCode.LeftShift;

private Rigidbody2D rb;
private bool isGrounded = true;

void Start()
{
    rb = GetComponent<Rigidbody2D>();
}

void Update()
{
    float move = 0f;

    if (Input.GetKey(leftKey))
    {
        move = -1f;
    }
    else if (Input.GetKey(rightKey))
    {
        move = 1f;
    }

    float currentSpeed = Input.GetKey(sprintKey) ? sprintSpeed : moveSpeed;
    transform.position += new Vector3(move, 0, 0) * currentSpeed * Time.deltaTime;

    if (isGrounded && Input.GetKeyDown(jumpKey))
    {
        rb.velocity = new Vector2(rb.velocity.x, jumpForce);
        isGrounded = false;
    }
}

void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("Ground"))
    {
        isGrounded = true;
    }
}

}

swift falcon
# spark sorrel Also need jump x)

Create a new C# script in Unity and name it PlayerMovement.

Copy and paste the above code into the script.

Attach the PlayerMovement script to the GameObject you want to move.

Make sure your GameObject has a Rigidbody2D component and a collider (e.g., BoxCollider2D).

Ensure that your ground objects have the "Ground" tag for the jumping logic to work.

spark sorrel
#

Holy shit it worked thx so much

swift falcon
spark sorrel
#

Good

swift falcon
#

I enjoy helping people

spark sorrel
#

Snuffer i have another question for ya

swift falcon
spark sorrel
#

Idk what that mean ☠️

#

Im such a newb☠️

swift falcon
#

let me inspect

spark sorrel
#

It happens when i press the play

#

Inspect the code ?

swift falcon
spark sorrel
#

Oh okay

swift falcon
spark sorrel
#

im listening👀

swift falcon
#

Ensure Rigidbody2D is Assigned: Make sure your GameObject has a Rigidbody2D component attached. This is referenced in your script by rb.

Initialize Rigidbody2D in Start(): Double-check that rb is being correctly initialized in the Start method.

Here's a revised snippet to verify the initialization:

#

void Start()
{
rb = GetComponent<Rigidbody2D>();
if (rb == null)
{
Debug.LogError("Rigidbody2D component not found on " + gameObject.name);
}
}

#

Verify Collider for Ground Detection: Ensure that the ground objects have the tag "Ground" for the collision detection to work correctly. Also, ensure your player has a collider (like BoxCollider2D) attached.

Check for Null References in MovePlayer Method: If the error persists in the MovePlayer method, make sure any objects or components accessed there are properly assigned and not null.

#

That should fix

#

if not then I will do hour's of research

spark sorrel
#

thats alot for my smoll brain man

swift falcon
#

So I can pinpoint the error

spark sorrel
#

in the script you gave, theres no error, it says its all good. when i try to start the game and linking my rig to my scrip it says that

swift falcon
spark sorrel
#

It means no problem

swift falcon
spark sorrel
swift falcon
# spark sorrel

But do you want more flexible movement like dashing and crouching?

spark sorrel
#

I need crouch, horizontal and a high jump

#

But like rn i cant even play it cause of errors 😦

swift falcon
#

What do you mean by horizontal ?

spark sorrel
#

Right, left

swift falcon
spark sorrel
#

Right with " D" left with "A" jump with W and crouch S

swift falcon
#

Sprinting?

spark sorrel
#

No need

swift falcon
spark sorrel
#

Its a school, basic stuff for exams

#

School class*

swift falcon
swift falcon
spark sorrel
#

Yeah optional class

#

I took it for fun

spark sorrel
#

☠️

swift falcon
#

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public float crouchSpeed = 2.5f;
public float jumpForce = 10f;

private Rigidbody2D rb;
private bool isGrounded = true;
private bool isCrouching = false;

void Start()
{
    rb = GetComponent<Rigidbody2D>();
    if (rb == null)
    {
        Debug.LogError("Rigidbody2D component not found on " + gameObject.name);
    }
}

void Update()
{
    float move = 0f;

    if (Input.GetKey(KeyCode.A))
    {
        move = -1f;
    }
    else if (Input.GetKey(KeyCode.D))
    {
        move = 1f;
    }

    if (Input.GetKey(KeyCode.S))
    {
        isCrouching = true;
    }
    else
    {
        isCrouching = false;
    }

    float currentSpeed = isCrouching ? crouchSpeed : moveSpeed;
    transform.position += new Vector3(move, 0, 0) * currentSpeed * Time.deltaTime;

    if (isGrounded && Input.GetKeyDown(KeyCode.W))
    {
        rb.velocity = new Vector2(rb.velocity.x, jumpForce);
        isGrounded = false;
    }
}

void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("Ground"))
    {
        isGrounded = true;
    }
}

}

spark sorrel
#

Uhm i cant crouch and it says

#

Tag: ground is not defined

#

Jump also dont work

swift falcon
spark sorrel
#

Did u put jump on W?

#

Oh yeah it work for crouch

#

I just dont have the animation yet

#

Whoopd

swift falcon
spark sorrel
#

How do i do that

swift falcon
#

Select your ground objects in the Hierarchy.

In the Inspector, go to the Tag dropdown at the top.

Select Add Tag... if "Ground" is not listed and add a new tag named "Ground."

Assign this "Ground" tag to your ground objects.

spark sorrel
#

But jump doesnt work

swift falcon
swift falcon
#

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public float crouchSpeed = 2.5f;
public float jumpForce = 10f;

private Rigidbody2D rb;
private bool isGrounded = true;
private bool isCrouching = false;

void Start()
{
    rb = GetComponent<Rigidbody2D>();
    if (rb == null)
    {
        Debug.LogError("Rigidbody2D component not found on " + gameObject.name);
    }
}

void Update()
{
    float move = 0f;

    if (Input.GetKey(KeyCode.A))
    {
        move = -1f;
    }
    else if (Input.GetKey(KeyCode.D))
    {
        move = 1f;
    }

    if (Input.GetKey(KeyCode.S))
    {
        isCrouching = true;
    }
    else
    {
        isCrouching = false;
    }

    float currentSpeed = isCrouching ? crouchSpeed : moveSpeed;
    transform.position += new Vector3(move, 0, 0) * currentSpeed * Time.deltaTime;

    if (isGrounded && Input.GetKeyDown(KeyCode.W))
    {
        Debug.Log("Jumping");
        rb.velocity = new Vector2(rb.velocity.x, jumpForce);
        isGrounded = false;
    }
}

void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("Ground"))
    {
        isGrounded = true;
    }
}

}

spark sorrel
#

I can only jump 1 time and then i cant

#

And i dont see tag dropdown, my platforms is from a tile sheet

swift falcon
#

try this

spark sorrel
#

It shows the error of ground but like it doesnt have an inpact on my movement

swift falcon
#

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public float crouchSpeed = 2.5f;
public float jumpForce = 10f;

private Rigidbody2D rb;
private bool isGrounded = true;
private bool isCrouching = false;

void Start()
{
    rb = GetComponent<Rigidbody2D>();
    if (rb == null)
    {
        Debug.LogError("Rigidbody2D component not found on " + gameObject.name);
    }
}

void Update()
{
    float move = 0f;

    if (Input.GetKey(KeyCode.A))
    {
        move = -1f;
    }
    else if (Input.GetKey(KeyCode.D))
    {
        move = 1f;
    }

    if (Input.GetKey(KeyCode.S))
    {
        isCrouching = true;
    }
    else
    {
        isCrouching = false;
    }

    float currentSpeed = isCrouching ? crouchSpeed : moveSpeed;
    transform.position += new Vector3(move, 0, 0) * currentSpeed * Time.deltaTime;

    if (isGrounded && Input.GetKeyDown(KeyCode.W))
    {
        rb.velocity = new Vector2(rb.velocity.x, jumpForce);
        isGrounded = false;
    }
}

void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("Ground"))
    {
        isGrounded = true;
    }
}

}

spark sorrel
#

Still only able to jump 1 time

swift falcon
#

Alr bro let me lock in

spark sorrel
#

Is it because ground is not defined ? So it doesnt think im touching the ground

#

To jump again

swift falcon
#

Check for Colliders: Ensure that your ground objects have colliders (like BoxCollider2D) so they can collide with the player.

Verify Collider Settings: Make sure your player's collider (e.g., BoxCollider2D) is set up correctly and positioned to detect collisions with the ground.

Once these steps are done, the OnCollisionEnter2D method should correctly detect collisions with ground objects and reset the isGrounded flag. This will allow the player to jump again after landing.

Here's the relevant part of the script again for reference:

#

void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Ground"))
{
isGrounded = true;
}
}

spark sorrel
#

Are you down to do a call? Would be more simple

swift falcon
spark sorrel
#

So in my tile map i have colliders, do i need to add one?

#

I have no colliders *

#

Nvm i do have one

swift falcon
#

as in unity

spark sorrel
#

Rn, i have platforms, tile map collider 2d, rigidbody 2d for my character and also a box colider 2d

#

And thats it lol

swift falcon
spark sorrel
#

Im not sure to understand what you want me to say

swift falcon
spark sorrel
#

No idk how to anything

swift falcon
spark sorrel
#

ITS MY FIRST GAME LOL

swift falcon
#

It looks like you an experienced unity user

#

although i mostly use unreal engine

spark sorrel
#

Nah im complete dog

#

😂

swift falcon
#

Features included:

WASD movement
Mouse look with camera rotation
Jumping when not in flight mode
Press F to toggle flight mode
In flight mode:
Space to fly up
Left Shift to fly down
WASD for directional movement
Smooth transitions between walking and flying

spark sorrel
#

i dont need flying and i cant move

swift falcon
ionic marsh
#

help im making an fps game and my character isnt jumping

#

im lost with troubleshooting

heavy plume
#

Hi! does anyone know if there are any known issues with playing a video asset on windows?
I'm getting the most generic error: VideoPlayer cannot play clip : Assets/Videos/SkillPlaceholder.mp4 < this is the asset path
(Also not sure if this is the right chat channel on this discord, lmk if there is a better one)

  • It works perfectly in unity editor on the same machine, the issue is only in builds.
  • it's IL2CPP on windows.
  • Tried transcoding options, h264/vp8 < all work in editor as well.
  • Tried disabling engine stripping / lowest stripping levels.
  • Tried loading via URL and confirmed URL is correct, same error as when using a video as asset.
  • Tried preparing and calling play on prepare callback
  • Audio output mode is none, it's a single video track video only
  • Version is Unity 6000.0.29
vestal arch
ionic marsh
#

it appears that my character is constantly jumping

vestal arch
#

you wanna show the code you're using to make the jump happen?

ionic marsh
#

alr 1 sec

#

my code is too long to be pasted in here

#

it says I need nitro

#

i can try messaging in segments

vestal arch
#

don't show your entire code

#

show the part you're using for the jump

ionic marsh
#

alr

vestal arch
#

!code

tawny elkBOT
ionic marsh
#

private void Jump()
{
// reset y velocity
rb.velocity = new Vector3(rb.velocity.x, 0f, rb.velocity.z);

    rb.AddForce(transform.up * jumpForce, ForceMode.Impulse);
}
private void ResetJump()
{
    readyToJump = true;
}

}

#

this is to apply the force

vestal arch
#

and how are you calling Jump?

ionic marsh
#

'''cs if (Input.GetKey(jumpKey) && readyToJump && grounded)
{
readyToJump = false;

Jump();

Invoke(nameof(ResetJump), jumpCooldown);
vestal arch
#

please format your code like the embed shows above

#

so have you debugged to see if Jump is being called, and if it isn't, check if Input.GetKey(jumpKey), readyToJump, and grounded are as you expect

ionic marsh
#

mb for late reply

#

Debug.Log(readyToJump);

//when to jump
if (Input.GetKey(jumpKey) && readyToJump && grounded)
{
readyToJump = false;

Jump();

Invoke(nameof(ResetJump), jumpCooldown);

}

ionic marsh
#

Delete this paste Start a new paste with this content

Debug.Log(readyToJump);

//when to jump
if (Input.GetKey(jumpKey) && readyToJump && grounded)
{
readyToJump = false;

Jump();

Invoke(nameof(ResetJump), jumpCooldown);

}

vestal arch
#

...you haven't formatted any of your messages

#

so what do your debugs say

ionic marsh
ionic marsh
vestal arch
ionic marsh
vestal arch
#

Not quotation marks.

open bluff
#

I wanna implement velocity to unity starter third person controller asset, for pushing player to spesific directions. What is the right way?

ionic marsh
vestal arch
ionic marsh
#

I will fix that

#

done

pearl burrow
#

Hi, im trying to create an easy way to save and retrieve skill data between game sessions.
My go to is to use a Dictionary<string, int> (i just need to store the level of the skill, hence using integer).

for saving that string into the dictionary im thinking of 2 options:
right now im using set of enums so i can just access to the desired skill with MyEnum.SkillName but (and it sounds stupid) i need to cast it to string every time.

I would like to use a set of string constants and create my Editor class to chose from a dropdown menu just like the enum in the inspector but i dont know which use case is better

dusk apex
pearl burrow
#

for clarity i would like to see the names of the skills in my saved json (and for statistic maybe in future)

#

is a readonly string[] in a static class good option?

dusk apex
#

Well, needing a static class is quite a big concern by itself - moreso than the read only attribute. Read only would be relative to what you're explicitly trying to do.

sacred sinew
#

hi, I'm trying to create a spaceship driving simulator and I don't really know how to move it without it stopping when you release the key (I want it to have a variable to create 'drag' whenever it's getting close to a planet later) but I don't really know how to do it. Can someone help me ?

pearl burrow
#

im trying to find an easy way to create a reference to these scriptable objects when i load back the game, aswell as for when i save it

#

since they are already in the hierarchy once the scene load i just need to put the levels in there

#

thats why i need to retrieve them from a dictionary(?) with the given ids (and i wanted to use simple string,int dictionary)

#

also i need to be able to access to these skills from parts of my game. for example if i want the level of the FireBall at a given point i wanna be able to access to it doing myAbilityDict["fireball"] and thats why i was using enums

little meadow
pearl burrow
#

because i have many skills and many different enums, i dont want to hold all the skill names for different categories in one huge enum

little meadow
#

haha, fair, that'd be my reason against it too 😄

pearl burrow
#

so im using string for the dict but now i need to cast the enums to string. i guess its the best option

little meadow
#

so, you define the skills and their IDs in SOs?

pearl burrow
#

i just made an editor script that gets all the Enum names from the different enum categories ive made and lets me pick one from it and put it as string into a scriptable object

#

so i have one scriptable object for the skill that contains a string which will be the id of the dictionary

#

and in future i can access to it by just doing myDict[category1.skillname]

#

sometime editor scripting saves you many thinking

snow lantern
#

I wonder how to program potentiometers for Unity.

rigid island
snow lantern
#

Alright, then I'll have to build the box for the guns, solder the arcade buttons to a keyboard circuit board.

rigid island
rigid island
#

if you said potentiometers then you would probably need a different controller like Arduino or Pi

snow lantern
snow lantern
rigid island
snow lantern
rigid island
languid hound
#

Does anyone know why ClosestPointOnBounds and ClosestPoint are just so horrendously inaccurate

#

I'm feeding it the world position of my hand and sometimes it will just return a position identical to the hand's position and sometimes it will provide a somewhat accurate position

#

It's never actually returning a good position

#

Do I need to convert it to local space or something

#

Nvm ClosestPoint works but ClosestPointOnBounds doesn't I think I might've been doing something wrong

spark bluff
#

running into issues with buttons and serializations

sacred sinew
#

I have an error message that I don't understand, can someone explain " plasticSCM/Unity.plastic.Antlr3.Runtime.dll is missing " please ?

spark bluff
#

basically i have this extremely simple public void statement which changes the text of a given objects with two different things to serialize, a string and the TMP_text object i want to change this on

#
{
    textasset.text = text;
}```
#

however this does not show up when i attempt to select this function to execute as a button onClick function

#

i suspect it has to do with attempting to get two different types of variables, a string and TMP_text asset

rigid island
#

most likely because it doesn't support those parameters let alone 2

spark bluff
#

while i could plug one of these parameters at the top of my script i do wanna keep this modular

rigid island
#

seems like you might have a fundamental misunderstanding how this supposed to work

#

if you want something modular you should use an actual script to do so

arctic steeple
#

In a professional team , do team members have to use the same Unity version ? Like I use Unity 6 but my mate use Unity 5 , will that be ok ?

vestal arch
#

if you're working on the same game, no, that's gonna cause issues

#

definitely with major versions

knotty sun
vestal arch
#

with minor versions, you might get away with it? but it'd still be super unreliable

#

just use the same version

arctic steeple
#

Do most developers switch to Unity 6 in companies nowaday or they still use Unity 5 ?

knotty sun
#

Very few people indeed still use Unity 5

#

you do realize there is Unity 2017,2018,2019, 2020, 2021 and 2022 between Unity 5 and 6

fiery elm
#

whats a good way to tie a class to a gobject
need a "map" holder to store refs to random shit (start point, diff parts of the map, goal collider) and i dont want to give it a whole monobehavior

knotty sun
fiery elm
#

college

#

dick

knotty sun
#

wrong answer <@&502884371011731486>

sleek bough
west lotus
fiery elm
#

but meh sure

west lotus
#

2019 is not unity 5 however

#

Its unity 2019

fiery elm
#

huh

#

tmyk

fiery elm
#

borders, the floor, start and end point

west lotus
#

Versions go in this order 5 2017 2018 2019 2020 2021 2022 2023 6

fiery elm
#

am additionally storing these in a Map class for easy access (and because apparently retrieving these through obj children is bad) but thats obviously clunky

west lotus
#

So what is your question really ?

fiery elm
fiery elm
#

because right now i cant exactly assign to Map's vars without a lot of hacks

west lotus
#

Are you asking how to put the right reference in start_point for example ?

west lotus
#

Easiest way is to make Map a mono why don’t you want that ?

fiery elm
#

i mean i assume i can do some all_objects (or whatever) .GetChild("map")[0].GetChild() etc etc

fiery elm
west lotus
#

It really is not

fiery elm
#

idk if it is

#

h m

#

ama peek what mono is exactly cuz im used to class inheritance == equip the class with all hte baggage of the parent

#

yeah from a briref look this doesnt seem needed

#

its not a script its just a class

west lotus
#

All scripts are clases

fiery elm
#

and not all classes are scripts yeah

west lotus
#

Inheriting from Mono would allow you to easily reference other objects from the hierarchy

#

Otherwise you need to first get the references somehow, pass them to the constructor of the map class and then have that map instance be used where you would like it

#

There is nothing wrong with having a lets say singleton monobehaviour that holds important data for your level

heady iris
#

you may be thinking of "component" here