#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 702 of 1

timber tide
#

try again

rich adder
#

it most certainly works

#

most common way its done..

quiet hazel
#

Maybe I am doing it wrong, how do you do it

timber tide
#

you've got playerprefs otherwise if you only need to store like a level index

rich adder
polar acorn
quiet hazel
#

I works kind of but it doesn't save everything

#

Like it saves almost everything, but it doesn't remember what other scripts do, I don't know how to explain it

rich adder
#

how about show the code?

#

we can't do much with vague statements lol

quiet hazel
#

I don't have the code, I tried it in a different project which I deleted a while ago, it's just before I try it again, I want to get it right

rich adder
#

roughly

//save
string jsonData = JsonUtility.ToJason(dataToSave, true)
File.WriteAllText(pathToSaveFolder, jsonData);

load do the inverse

#

its that simple

teal viper
#

Neither of which we know, so we can't really give you the right answer.

#

I suggest: Google and find what ways there are. Then try them out or research their ups and downs and decide which one suits you better. Then try it out and see if it fits you for sure.

quiet hazel
#

Alright, I'll try something and update you

teal viper
#

Any more specific questions along that path can be asked in the community and you will likely get a better answer than to the current generic question.

quiet hazel
#

Okay, thank all you guys anyway, I'll keep you updated

rich adder
nova kite
#

Thank you Iโ€™ll give it a shot then๐Ÿฅฒ

pulsar plover
#

What is the difference between public and serialized fields?

rough granite
#

generally better to keep variables private and use encapsulation to change / get them, though not like i do this myself 90% of mine are public :/

brave compass
rocky canyon
#

private variables are normally hidden in teh inspector
serializing it makes it exposed in the editor
but the functionallity of it is the same as a regular private variable

pulsar plover
rocky canyon
rough granite
rocky canyon
#

very nice lol

rough granite
#

going from 10 to 177 (ignoring that half the lines are the [] thingys

rocky canyon
#

i hope all those values match the inspector values ๐Ÿ‘€

rough granite
#

nope not at all

rocky canyon
#

it'd suck to accidently break it and recompile

#

๐Ÿ€

rough granite
#

i doubt even 10 of them are :/

rocky canyon
#

๐Ÿ˜ฌ i used to take screenshots and / or keep lots of recordings while working on my CC controller.. b/c lots of my values changed and i couldnt be arsed to set the defaults to match

#

now i have the default values branded in memory

rough granite
#

it's just easier to change em here and not wait 40 seconds

rocky canyon
#

ohhh cool those tabs are awesome

rough granite
#

yeah little feature of Odin Inspector but when havign this many variables (theres another like 8 scripts kinda like this) having the object selected while in play mode brings me from 150 fps to 25 fps

brave shadow
#

I'm having difficulty overriding a value,and I'm having difficulty finding a solution online

#

I have a class called "weapon", with a line like this:
public Vector2 direction = new Vector2(1,0);

#

And I want to change this value in a child class called "DiagonalWeapon"

#

How would I do this?

rocky canyon
#

weapon.direction = someValue;
should work fine
just make sure the weapon class isn't overwriting it back.. (like if weapon is setting it to something in Update)

brave shadow
#

thing is, if I do something like that:

#
{
    Weapon.direction = new Vector2(0.71f, 0.71f);

}
#

I am told "weapon" does not exist in this current context

rocky canyon
#

oh an inherited class

not sure how ud do that one

#

wouldnt it just be "direction" = then?

acoustic belfry
#

Hey i have a question. I have a lot of different tabs, and wich i need to modify every single each of them and their text. The only way i know how to do so is if i make a referencial value and configurate each single one of them, is this the only way? Or is there another?

acoustic belfry
frosty hound
#

As in, will it cause issues? No it won't

acoustic belfry
#

but i mean, it wouldn't be like, too tedious or smt?

#

or unprofessional

#

idk

#

i mean, i just dont want my codes to suck

#

but if others proyects do it, then i guess i will not worry

rocky canyon
brave shadow
lofty mirage
#

if that is the question

#

for text however, it's fine I believe

acoustic belfry
acoustic belfry
rocky canyon
#

could probably do something like that w/ a function codex.Discovered(enemy); and not have any booleans

brave shadow
#

As unforutnately the "direction" of my projectile isn't actually changing

rocky canyon
#

ya, i think some context would help greatly.. altho i may not be the guy to help b/c i dont use inheritance that often

#

so im probably not the best person to know.. but the more info u provide the better for anyone that sees

rocky canyon
#

like ^ have the codex make the button visible or not or whatever

acoustic belfry
#

another idea that i had but wich is slighty paradoxic is having an int, if number is higher than X, display some tabs

issue is, i should present all stuff in order, or else it would "spoiler"

rocky canyon
#

u pass in the enemy when u meet or kill it..

#

the codex takes the enemy.. finds the appropriate button.. does things to it

brave shadow
#

The only place I can find in it where "direction" is referenced is here:

#
    {
        //This is where the weapon is rotated in the right direction that you are facing
        if (weapon && canAttack)
        {
            if (weapon.weaponType == Weapon.WeaponType.Melee)
            {
                weapon.WeaponStart();
            }

            else
            {
                GameObject projectile = Instantiate(weapon.projectile, weapon.shootPosition.position, Quaternion.identity);
                projectile.GetComponent<Projectile>().SetValues(weapon.duration, weapon.alignmnent, weapon.damageValue);
                projectile.transform.localScale = new Vector3( projectile.transform.localScale.x * (scale.x / Mathf.Abs(scale.x)), projectile.transform.localScale.y, projectile.transform.localScale.z);
                //projectile.transform.localScale = new Vector3(projectile.transform.localScale.x, projectile.transform.localScale.y, projectile.transform.localScale.z);
                Rigidbody2D rb = projectile.GetComponent<Rigidbody2D>();
                if (player.transform.localScale.x > 0f)
                {
                    rb.AddForce(weapon.direction * weapon.force);
                }
                else
                {
                    rb.AddForce(new Vector2(-1,0) * weapon.force);
                }
                


            }

            StartCoroutine(CoolDown());
        }
    }```
#

You can ignore the "melee" secion, I am not using it

acoustic belfry
brave shadow
#

And the projectile currently shoots horizontally, as the Weapon class direct (the vector direction for the default Weapon class is [1, 0])

#

wait, i got it.

#

I think it's that else, add force step.

#

yeah, I can shoot diagonally to the right now, at least!

#

I think that's it

rocky canyon
# acoustic belfry but how specificly? i mean, do you mean by killing the enemy the tab should be t...

so like for example ur enemy could have a ID number or something that corresponds to the button that represents it

public class Enemy : MonoBehaviour
{
    public int codexID;
}```

when u meet it or kill it or w/e you'll probably have a reference to it..
soo you could call a function from the CodexSystem and shoot that reference over to it
```cs
    public void Unlock(Enemy enemy)
    {
        if (unlockedEntries.Contains(enemy.CodexID)) return;

        unlockedEntries.Add(enemy.CodexID);

        // Enable matching button
        codexButtons[enemy.CodexID].interactable = true;
        Debug.Log($"Codex unlocked: {id}");
    }```
then the codex script would just check if its unlocked already.. or interactable already and if its not it does it..
#

i mean thats just a simple example. but Functions/Events and stuff can do things directly without having to check abunch of bools or something

acoustic belfry
#

oh, i think makes sense, well, thanks

rocky canyon
#

no problem.. it takes a bit to get used to that kinda workflow tho..
when i first started i'd use bools for everything.. especially inventory..
hasPistol, hasShotgun, hasBlueKey, hasRedKey

#

and it would end up with long if,else statements

#

now i just make a class called Key for example.. give it an ID or a Color.. then i just make a list of those..

brave shadow
#

thanks @spawn ! I got things working as intended now!

rocky canyon
#

run thru the list.. checking the colors.. instead of a bool for each ๐Ÿ˜…

acoustic belfry
#

i mean so it get the numbes for the enemies's IDs

rocky canyon
#

yea

#

an array of buttons would work

#

with each index meaning a different creature or w/e

acoustic belfry
#

oh, well, thanks :3

rocky canyon
#

np ๐Ÿ€

acoustic belfry
#

btw interactible means the click works?

rocky canyon
#

yea, its whether or not the button is greyed out and/or clickable or not

acoustic belfry
#

cool, thanks

acoustic belfry
rocky canyon
#

wouldnt need to be.. makes it easier tho

acoustic belfry
#

i mean for make this permanent

rocky canyon
#

as long as u have a reference to it you could just call it
codexReference.Unlock()

#

but a static class or a singleton would make it more universal.. (like a game manager)

acoustic belfry
#

yeah, i mean, for make it permanent

cuz i need it to be permanent after all

rocky canyon
#

ya, id go ahead and make it a static class or a singleton then...
have all the logic you'll need from the codex there in the class
and itd be easier to call it from anywhere and from anything..

acoustic belfry
#

thanks :3

rocky canyon
#

u could have like HasEncountered(Enemy enemy);
HasKilled(Enemy enemy); etc etc

#

u could even simplify it and just have those methods take ints.. if the monsters or w/e will always have the same ID number..
that way it wouldnt even need an enemy class or anything.. just a number

#

HasEncountered(int monstersID) or something..

#

but i think u get it ๐Ÿ‘ just gotta work it all out now

acoustic belfry
#

well, thanks a lot :3

stoic summit
#

hi, with this code, the lerp is completing rotations long before timer is equal to 1. I'm honestly clueless as to why the fuck it's doin this

polar acorn
#

Do the logs show timer is increasing at the rate you expect?

stoic summit
#

yes

#

full code

#

Quicklerp function is junk, just haven't written over it yet

stoic summit
#

makes 0 sense to me

ivory bobcat
stoic summit
#

that's towards the end

#

fully goes from 0-1

#

lerp completes while it's around .2

ivory bobcat
#

Print other data that may be important such as the current position and rotation

#

And normally, you'd use the initial value as the first argument of lerp rather than the current value

stoic summit
#

all .50000 from there down

#

increased steadily before that

ivory bobcat
#
var init = ...
var target = ...
...
while(...)
{
    ... = ...Lerp(init, target, timer);
    ...
}```etc
ivory bobcat
stoic summit
#

mmmm wise

#

yeah I'm fuckin dumb

#

figured out the fix I believe, gonna test it in a second

#

appreciate the help homie ๐Ÿ™

#

yup, works fine now

#

just had to move these outside the while loop so the position wasn't being updated every iteration

frigid sequoia
#

I know you are gonna ask me why would I want this, but, can a class hear to its own event?

bright zodiac
#

sure why not

#

also a bit unclear, proly add more context to it

naive pawn
hot wadi
#

Do u guys often use singleton? I mean, I get on just fine without it, and it does not seem to have a great reputation

sour fulcrum
#

good use of singletons is very useful yeah

hot wadi
#

There are too many cautions for such a basic pattern

sour fulcrum
#

says who

gilded isle
#

Does anybody own a gtag fan game?

naive pawn
naive pawn
sour fulcrum
#

Is there a proper term for doing this kind of thing?

    private float RemapLerp(float targetMin, float targetMax, float sourceMin, float sourceMax, float sourceVal)
    {
        return (Mathf.Lerp(targetMin,targetMax,Mathf.InverseLerp(sourceMin,sourceMax,sourceVal)));
    }
bright zodiac
#

its some sort of normalization.. I mean in a way

north kiln
rocky canyon
#

i also just call it Remapping

rocky canyon
#

i think ive also called it some kind of Scaling before too

naive pawn
#

i suppose that could get confusing with the map data structure though (or not, since c# calls it Dictionary)

#

(fwiw i don't think i'd call it remap lerp - you're remapping linear ranges, using linear interpolation to do it, rather than actually remapping the interpolation)

sharp bloom
#

Why does the FindComponentInParent method check the current active object for the component as well as the parent? Seems like a silly thing to me.

#

If I have two Images for example, and I want to get the parent image from a script called in the child, this method does not return it

eternal needle
sharp bloom
#

Yes but I fail to understand why is this method implemented like that

#

If I wanted something from self, I'd just use GetComponent normally

eternal needle
#

because unity chose to do it like this. im sure if they implemented how you suggest, there would be someone out there complaining they need to call GetComponent and GetComponentInParent afterwards in their use case

sour fulcrum
#

tbh the answer is just an accurate name would be too verbose

sharp bloom
#

Accurate name should be something like RecursiveFindComponent

eternal needle
#

either way tbh, i find that this method is something you should never be calling. drag in the reference you want. have the parent do the logic instead.
there are many options here that dont involve a child randomly trying to search a hierarchy which it shouldnt be doing

eternal needle
sharp bloom
#

Tru

eternal needle
#

you should really try to put yourself in a scenario where you dont need this function. im not sure what you're doing here, i imagine this is dynamically adding children to a parent given that you need to call this rather than dragging in a reference

#

in which case you can still just pass the reference you want when the child object is instantiated

naive pawn
viral flax
#

Very quick question: Should I be using float3 instead of Vector3 in monobehaviour code (even if it uses managed types, thus isn't Burstable) - is there any benefit to their performance?
I know in some cases you can enforce that certain checks are not being used with float3 (e.g. normalize vs normalizesafe), but are there other benefits

sour fulcrum
#

i dont like know this but im assuming you shouldn't be

#

on the basis that if there was a benefit unity wouldn't be using them

viral flax
#

Well, Vector3 is an older legacy option, float3 came later with Burst. Though, the conversions between the two are presumably performance-intensive, so it's one or the other.

eternal needle
#

anything like transform.position or scale are stored as Vector3

viral flax
#

Yes, and the conversions between the two might be (according to the documentation) wasteful. But your code, that doesn't directly read from some of the builtin function, can use float3 just fine. And considering the mathematics library is better optimised than the legacy Mathf, it is in many cases beneficial

woeful coyote
#

I don't think float3 struct itself is more performant than Vector3. It's the methods that operate on float3 (like those in unity.mathematics) that are more performant than those that operate on Vector3 (like Mathf)

grand snow
#

I think it exists purely for the new math functions usable in burst/jobs

#

the mathmatics package has some nice additions though

eternal needle
viral flax
#

Well, if one option is generally more performant than the other, it only makes sense to prioritise it going forward, rather than to rewrite the entire codebase when it's too late. It's not unreasonable to do such 'micro-optimisations', if it's only a matter of habit, since in this case it doesn't cost you anything to write Vector3 vs float3

eternal needle
woeful coyote
#

performance impact of converting between float3 and Vector3 is like negligible. other things will matter way more.

eternal needle
#

theres always the argument where things could be better. "I could follow better design patterns" "I could optimize to save 1 cpu instruction". And it's always hard to argue against it because yes it is better, but it's a waste of time to even think about

sour fulcrum
#

surely on a level where the difference here would matter you should be profiling anyway?

eternal needle
#

my whole point here is that there is no difference or world where this even matters. if theres a reason to use float3, then it is because you're using it with systems that expect a float3 in the first place

#

aka like the things rob sent above

woeful coyote
nimble apex
#

is there a way to register custom virtual joysticks to new input system?

#

i have a working joystick that reads value, but i want to integrate it to new input system

#

but because this joystick cannot be properly invoked by on-screen stick component, i think i need to code it

naive pawn
#

Bounds/Rect both still think with Vector3/2, and colliders and rigidbodies use those (or vectors)

naive pawn
nimble apex
#

ok

bright zodiac
naive pawn
#

that's what a root is, yes

#

getting a root or parents is indeed recursive, but so is getting children

bright zodiac
eternal needle
bright zodiac
grand snow
#

Will be great but I presume il2cpp already improves on this (depending on the cpp compiler)?

obsidian grove
slender nymph
#

are you using 6.1?

obsidian grove
#

yep, knew it was a silly question ๐Ÿ˜…

acoustic belfry
#

hi. i have an issue, this code of a codex is supossed to unlock InfoTabs depending on who calls it, but, the tabs are reutilized in 3 different categories depending on the int cassielIndexType. i mean, in UI are 5 tabs, yet, lets say you discovered 1 Leyend yet 3 Enemies. when cassielIndexType is 1, it must display 1 tab, but when cassielIndexType is 2, it must displays 3. Reutilizing the same 5 buttons

this is the code

    {
        if (unlockedInfo.Contains(codexID)) return;

        unlockedInfo.Add(codexID);

        codexButtons[codexID].interactable = true;
        Debug.Log($"Codex unlocked: {codexID}");
    }```
grand snow
#

you would need to loop over them all to update their visibility ofc

naive pawn
acoustic belfry
grand snow
#

you would re design to have a list of a new type such as List<UITab> and then loop over and both access this "visibility" list and then set its visibility

#

a hashset is just a collection that uses hashing to disallow duplicates and provide fast Contains checks

acoustic belfry
grand snow
#

well yea, a list of your tabs

#

and the tab type can have its OWN list/hashset of the ids that can show it

acoustic belfry
#

... Wat?

grand snow
#

You want to show some tabs depending on some input int right?

acoustic belfry
#

I mean
I want to show some tabs depending on an int and if discovered

#

Cuz the thing is

#

If the player finds something that adds info, like killing an enemy, it must make that tab activate. Issue, im reusing tabs, so when is on the category of A, it should display what discovered of A, if is category of B, display what discovered of B

#

The Hard part is the unlockinh and hiding tabs part

grand snow
#

Then why does what I suggested not work?
Tab A (1,2,3)
Tab B (3,4,5)

2 -> Tab A
3 -> Tab A + Tab B
is this not what you need?

#

perhaps you need to better explain what "tab" even means, is it some UI button? is it actually some other UI that can show many elements?

acoustic belfry
#

True. I investigated english and i think tab is wrong. Is not tab the word

#

Is button

#

The categories are the tabs

#

Tab controls Ints

Ints controls info and Buttons

grand snow
#

Do you mean the buttons can open different things depending on some category?

atomic sierra
#

hi im trying to kickstart my game dev journey, and I was wondering if I should sign up for these short game jams get myself up and running, or shud I sign up for these longer game jams? is there a difference to how much work is required to build your game depending on the length of the jam? or is it just based on how much time you have available for yourself?

grand snow
#

wrong channel

grand snow
#

then you can configure what button a, b and c do depending on the category

acoustic belfry
#

The category is just an int

acoustic belfry
grand snow
#

then use an int but there is a reason why enum exists (so we can give names to magic numbers)

acoustic belfry
#

I know how to hadle the info

#

The issue is the unlocking part ;^;

grand snow
#

then how does "unlocking" work or mean?

#

we just went from changing what a button does to something else

acoustic belfry
#

Cuz is the ingo part is easy
If (category = x)
{
If (index = x)
{
Info
}
}

grand snow
#

whats index?

acoustic belfry
#

The info

The buttons only purpose is change index int

#

The info part doesnt matter

#

I think im overcomplexing stuff

grand snow
#

If this is meant to be some UI list of objects the user has "unlocked" then this should be trivial, check this state when creating/updating the list

acoustic belfry
#

Unlocking is when the player for example kills an enrmy

#

An idea i had was that on each Category Block, it set all the UnlockedCategoryButtons to activate

#

But i dont know how

twilit jolt
#

this might be insanely weird and simple, but it's making me loose my mind cus i can't figure out why it happens, so some help would be appreciated

i have this extremely simple code, that calls a game win function if the growTime gets above 1

if(growT > 1){
    Debug.Log($"Won At {growT}");
    GameManager.instance.WinGame();
}

but for some reason it detects the value, and even logs the value above 1, when in reality it's way below it

sour fulcrum
#

in reality it is that value

#

when that log happens

grand snow
#

haha it must be

hexed terrace
#

1.000399 > 1

sour fulcrum
#

unless regional diff?

grand snow
twilit jolt
# sour fulcrum when that log happens

that's what i'm thinking too, but the value shows normally when i serialize it, and i use it for some visual stuff, and the visuals don't jump around when the win get's triggered

hexed terrace
#

make sure growT is 0 at the start, before this is reached

hexed terrace
sour fulcrum
#

it is that number when that log happens

#

period

#

what changes it?

twilit jolt
#

a per frame addition

growT += growthSpeed * Time.deltaTime;

and nothing lowers the value
so even if it somehow jumps to above one, it shouldn't return to below 1, like it shows on the value property

sour fulcrum
#

are you looking at the right one?

sour fulcrum
polar acorn
twilit jolt
#

i have multiple ones with random speeds, and i forgot to disable the win logic, on the non important ones

#

damn ๐Ÿ˜ญ

grand snow
# acoustic belfry i suposse

What you want is not hard really, if things are set up correctly its trivial to do what you want.
Even if you hand make the UI, if each "enemy element" has an id to specify what enemy it is, you can loop over them all and do what you wish depending on their unlock state.
Open ui to category -> refresh UI to show/hide/update enemy elements

twilit jolt
#

thank you guys for the help btw :)

polar acorn
#

Logs never lie, the issue is always on the monkey's end rather than the machine

#

From there you can eliminate all possibilities that the number is anything but what was logged and all that remains is the simplest answer: it's two different numbers

acoustic belfry
grand snow
#

Its easy and I think you have this funny vision of some weird ass method of doing it that is falling apart

acoustic belfry
#

;-;

grand snow
#

I make this kind of UI all the time and what you are saying is making no sense to me

#

If I have a UI that needs to show things (e.g. "unlocked enemies") then on Initialization I get all the enemy configuration entries and the player data. I make elements for each enemy and init it with that enemy entry. I then perhaps change how it looks based on if its recorded as being unlocked in the player data.

acoustic belfry
#

how

grand snow
#

I can sub to some click event on my enemy element to react to its click and cus I know what enemy its showing, I can use this

#

You write it...

warm palm
#

Turns out the issue was capital letters, I didn't know capital letters affected anything (Because I've never opened Unity or written code in my life until yesterday) and just had to change some stuff from capital letters back to lowercase and vice versa.

acoustic belfry
grand snow
#
public void Init(Config config, PlayerData player)
{
    foreach (var enemy in config.enemies)
    {
        var enemyElement = Instantiate(enemyElementPrefab, enemyElementParent);
        enemyElement.Init(enemy, player);
        enemyElement.OnClick += OnEnemyElementClicked;
    }
}
acoustic belfry
#

huh

grand snow
#

you have some place of storing all of this information like a configuration object or a list of enemy data objects

acoustic belfry
#

i dont...get it

#

what i just do is a lot of ints for record stuff

grand snow
#

then you should change it

rough granite
acoustic belfry
#

i know, the thing is, i do it, cuz i dont fully know how to handle the other ways

also i can do a lot of bools

grand snow
#

If you have any additional information associated with an "enemy" then you should ideally have a way to store this right?

#

e.g. health, sprite

#

Scriptable objects are GREAT for this

acoustic belfry
#

is just in the enemy

grand snow
#

Then move it to a scriptable object that the enemies reference instead

acoustic belfry
#

huh?

rough granite
acoustic belfry
#

what even are scriptable objects, sorry

warm palm
acoustic belfry
#

you mean like a singleton?

warm palm
#

I'm surprised nobody helping noticed that

grand snow
acoustic belfry
#

a file that you call using "instance"

warm palm
#

I'm especially suprised the guy that likes typing in italics didn't notice that

acoustic belfry
#

i mean, i have an static object that stores the player's health, for the next scenes

warm palm
#

anyway, back to my tutorial

grand snow
#

Its important to seperate static data like this to make our lives easier when looking at this information in other places like UI

sour fulcrum
rough granite
sour fulcrum
acoustic belfry
#

i mean, the script is on an object btw, that just exists forever, this is how the player calls it in update for the health

        soul = ValeriaMemories.Instance.memorySoul;```
sour fulcrum
#

i am gonna keep nitpicking your wording, please don't be offended

#

scripts are not on objects

#

instances of scripts are on objects

acoustic belfry
#

oh

#

makes sense

sour fulcrum
#

a static reference to an object != a static object

frigid sequoia
#

A random thougth just came to my mind, like... why does Unity save the enums you set on the editor as the Index of the enum and not the "id" of it, which is like basically the whole point of enums?

rough granite
acoustic belfry
sour fulcrum
grand snow
#

@acoustic belfry we want to seperate out the data like this so your UI can also reference all "enemy data"

public class EnemyData : ScriptableObject
{
    public int health;
    public Sprite sprite;
}

public class Enemy : MonoBehaviour
{
    [SerializedField]
    EnemyData enemyData;
}
acoustic belfry
#

im getting pretty lost.....

sour fulcrum
acoustic belfry
#

o h

#

so in theory, this object exist forever thanks to a singleton.....

this is slighty more complex than i thought

sour fulcrum
#

again this is more of a nitpick but wording is pretty important in troubleshooting

grand snow
#

I earlier said "static data" as we expect configuration data about enemies to mostly remain consistent at runtime

acoustic belfry
#

but why would you need that data btw?

#

no offense

#

cuz im the one confused and dumb

grand snow
#

If i want to show all enemies in some user interface I can look at my list of EnemyData and do it dynamically

sour fulcrum
#

if your trying your not dumb

warm palm
acoustic belfry
warm palm
#

Spoon feed wtf is that

frigid sequoia
acoustic belfry
#

MoonManager (name's related to lore)

rough granite
sour fulcrum
acoustic belfry
#

i mean

#

give you all stuff easily

rough granite
grand snow
# acoustic belfry i have all info i wanna show on my UI manager

yea but you seem to be unable to work out how to simply show unlocked enemies in this so you have clearly designed it badly
you came here to ask for help. I have worked on many games with external data configuration and there is a reason why its done this way...

acoustic belfry
#

just saying what i think it means

grand snow
#

god damn please guys stop

acoustic belfry
#

lets call it Memories

delicate portal
#

Hey what can I do about this?

sour fulcrum
#

scripts cannot be static

acoustic belfry
#

i mean

#

the script that exist forever, this thing, y'know what i mean

grand snow
acoustic belfry
#

i mean

sour fulcrum
#

instance or object is the term you wanna use there

acoustic belfry
#

the script that the singleton has

sour fulcrum
#

the script is just the file with the code in it

grand snow
#

Sorry for being the only one actually wanting to help you ๐Ÿ˜†

acoustic belfry
#

its ok xdn't

sour fulcrum
acoustic belfry
#

i mean, the UI in theory works, everything works, is just the unlockable part that sucks

grand snow
#

Yea as I said, you probably designed it in a bad way that makes this simple task (change some visibility or style to reflect some unlock state) hard

acoustic belfry
#

but i mean, why?

#

this is the code btw

grand snow
#

you tell me because I cant see what you have done soo far

acoustic belfry
#
  {
      if (cassielIndexType == 0)
      {
          if (cassielIndex == 0)
          {
              cassielJournalName.text = "Bitรกcora de Cassiel";
              cassielJournalDesc.text = "El acceso a la informacion almacenada en la Base de Datos de Cassiel. Aqui puedes leer informacion sobre las leyendas que encuentras, la historia de gente que conoces, o como derrotar a los enemigos y sus significados";
          }
      }
      else if (cassielIndexType == 1)
      {
          if (cassielIndex == 0)
          {
              cassielJournalName.text = "Prismas";
              cassielJournalDesc.text = "Infodumping";
          }
      }
      else if (cassielIndexType == 2)
      {
          if (cassielIndex == 0)
          {
              cassielJournalName.text = "Valeria";
              cassielJournalDesc.text = "Infodumping sobre los personajes";
          }
      }
      else if (cassielIndexType == 3)
      {
          if (cassielIndex == 0)
          {
              cassielJournalName.text = "Mortem Trooper";
              cassielJournalDesc.text = "saracatunga";
          }
      }
  }

  public void setCassielStyle(int cassielJournalStyle)
  {
      cassielIndexType = cassielJournalStyle;
  }

  public void setCassielIndex( int index)
  {
      cassielIndex = index;
  }
sour fulcrum
#

piratesoftware

grand snow
#

yea that looks terrible, hard coded data using ints?

acoustic belfry
#

wat

delicate portal
#

anybody knows what can I do about this?

acoustic belfry
#

sorry

naive pawn
acoustic belfry
#

dicts?

rich ice
delicate portal
rich ice
#

shader error, ask in

#

-# guh, new keyboard, # and enter key are swapped

grand snow
rough granite
acoustic belfry
#

oh!

delicate portal
rich ice
#

no clue, manufacturer just gave up half way through designing it i guess

delicate portal
rich ice
#

god damn it again

delicate portal
#

๐Ÿ˜„

rich ice
#

-#

acoustic belfry
acoustic belfry
grand snow
#

Scriptable objects are a custom asset essentially that hold data and references to other assets

sour fulcrum
#

They are like materials where they are assets in your project except you decide what goes in them

acoustic belfry
grand snow
#

I presume you are having trouble thinking how to "reference all of these assets"
You can have a serialize list on your UI script and assign them all there

#

E.g a list of weapon scriptable objects

#

THEN we have access to all of our data

acoustic belfry
#

what exactly ScriptableObjects do?
you mean i just reference it drag and drop like other all objects i have?

sour fulcrum
#

Like materials ๐Ÿ˜„

grand snow
#

Yea because you create assets of the scriptable object in your project

#

Using the right click create assets menu

#

Like when you create a new material we instead create a new "cassiel" instance

#

No idea what that is

acoustic belfry
grand snow
#

Its no safer in a script file

acoustic belfry
grand snow
#

you should be using source control to back up your project

#

e.g git or unity version control

#

then your data will be safe

naive pawn
acoustic belfry
#

h o w ?

acoustic belfry
grand snow
#

yay new assets

acoustic belfry
#

oooh on the scriptable part

grand snow
#

yay data

acoustic belfry
#

is below monobehaviour

grand snow
#

you need [CreateAssetMenu] for that menu option to exist

[CreateAssetMenu]
public class TestScriptableObject : ScriptableObject
{
    public string name;
    public string desc;
}
acoustic belfry
#

btw what diferences scriptableObject and Monobehaviour i know is big, but im gertting slighty confused

grand snow
#

scriptable objects are assets
mono behaviours are components

acoustic belfry
#

oooooooooooooooooooh

grand snow
#

now go my child and fix your data problem with scriptable objects โœจ

acoustic belfry
#

ok UnityChanThumbsUp

#

but i still got confused on the activate-deactivate buttons thingy, the scriptableObject will just for make my wiki code dont suck

but ok

sour fulcrum
#

you didnโ€™t explain the one thingo about data in scriptableobjects

acoustic belfry
#

wat

sour fulcrum
#

Data in them doesnโ€™t reset when you exit play mode

#

ScriptableObjects are good for things that are not going to change throughout the game

acoustic belfry
#

wait what

#

data in them dont reset?

#

then for what do static objects EVEN EXIST?!!

#

i got confused

#

i mean

#

scriptableObject's data is eternal?

sour fulcrum
#

well no

acoustic belfry
#

t h e n

sour fulcrum
#

in a component, if you put a value in the inspector 2 to, then play the game, the code changes it to 9, you exit the game, the value is back to 2

acoustic belfry
#

oooooooooooooooooooooooooooooooooh

#

so makes static values eternal

#

sounds good

sour fulcrum
#

you know what sure ๐Ÿ˜„

#

try them out you'll figure it out

acoustic belfry
#

but yeah, then yea staticObjects are still usefull tho... xd

sour fulcrum
#

static references!!

#

objects are not static ๐Ÿ˜„

acoustic belfry
#

yeah that

#

static references

sour fulcrum
#

๐Ÿ˜„

acoustic belfry
teal viper
acoustic belfry
#

wat

grand snow
#

Yea they should be used to configure data in editor and just read at runtime

acoustic belfry
#

like the info of a wiki

grand snow
#

Such as doing game configuration for things like weapons or spells or a wiki of data

sour fulcrum
#

it's a good example yeah

woven dawn
#

Hey can anyone pls recommend a good tutorial where I can learn Unity C#

acoustic belfry
grand snow
acoustic belfry
#

Makes sense. Well, thanks

grand snow
rustic stump
#

anyone know how i access these settings? they are greyed out for some reason#

slender nymph
#

not a code question. and the built in materials are readonly, you need to create a copy of it and modify that copy

polar acorn
sharp mirage
#

whys this thicker than usual

polar acorn
#

press insert

acoustic belfry
grand snow
#

thats okay, its a lot better than what you were doing before

#

the situation may arrise and then you will be glad

acoustic belfry
#

But also something that i feel slighty odd

Ok, the Information is on the ScriptableObject. How i can make the Journal on the UI manager use it?

#

It would be the same Int tree
Just that instead of hardcoded text, it would be

Desc.text = ScriptableJournal.Desc;
?

grand snow
#

Make an element via Instantiate() for each journal and initialize it:

public void Init(ScriptableJournal journal)
{
  Desc.text = journal.Desc;
//...
}
#

Presuming you have a layout group and or scroll area of similar looking elements

rancid lily
#

How can I check if StartClient() succeeds or not? Function is returning true even though there is no server to connect to

public void onConnectButtion() {
        if(int.TryParse(portInput.text, out int port))
        {
            NetworkManager.Singleton.GetComponent<UnityTransport>().SetConnectionData(
            ipInput.text,  // The IP address is a string
            (ushort) port // The port number is an unsigned short
        ); 
        }
        else
        {
            Debug.Log($"Attempted conversion of {portInput.text} failed");
        }
        
        Debug.Log(NetworkManager.Singleton.StartClient());
        gameObject.SetActive(false);
        lobbyMenu.SetActive(true);
    }
rich adder
rancid lily
#

I'm now looking for a callback which fired if it fails to connect

rancid lily
slender nymph
rancid lily
#

I've figured it out now so no need

umbral bough
#

Hey, is there a way to freeze the rigidbody rotation for a bit without losing the angular velocity?
If I set velocity to 0, I lose the velocity, if I freeze the rotation I lose the velocity, and if I store the velocity in a variable and reapply it after unfreezing it's not accurate as it didn't update.
Is there a built in way to achieve this?

naive pawn
#

well freezing would make it not accurate to the simulation, yeah?

#

you want to make it stop for a sec before continuing with whatever angular velocity it had before?

#

sounds like you would just do that - store velocity, set it to 0 now, set it back to the original velocity later

umbral bough
#

No, close but no.
I want it to continue calculating the rotation while frozen so when it resumes it resumes w velocity it would have as if it never stopped to that point.

naive pawn
#

so like, stopping the graphics but not the actual simulation?

umbral bough
#

maybe, depends on how you see it

#

if I was rotating for 50 on the x axis and froze, I don't want to resume after 5 seconds at 50 velocity on x but instead what it would be if the simulation was running that entire time, so maybe 20

naive pawn
#

so with damping/friction applied?

#

what is the context here?

umbral bough
#

yes

naive pawn
#

what are you trying to achieve?

umbral bough
#

I am controlling a flying object that can flip(with user input), and I want to stop that flip while the user is moving the mouse to pan around, but resume when the user stops giving input.
Not sure if it will feel good or bad just wanna test it.

#

I initially didn't change the velocity at all and that felt weird when user was trying to pan against it, then tried fully stopping it which felt weird when you stopped moving the mouse as there was no rotation at all so I wanna give this a try, lmk if you have a better idea.

naive pawn
#

oh god a UX question, im horrible with these

umbral bough
#

yep, so am I, I just try stuff till something works

naive pawn
#

im usually better at identifying/guessing UX issues than fixing them, so.. may as well try

#

my first thought is that the immediate stop/start would be jarring - so maybe smooth the stop/restart?

naive pawn
umbral bough
rancid lily
#

Any ideas why this is always throwing an error? portInput is a TMP_Text component

Debug.Log(portInput.text);
        if(int.TryParse(portInput.text.Trim(), out int port))  // Set the socket
        {
            NetworkManager.Singleton.GetComponent<UnityTransport>().SetConnectionData(ipInput.text, (ushort) port); 
        }
#

Debug output seems normal

naive pawn
#

what's the error

rancid lily
#

The converstion fails and returns false

naive pawn
#

that's not an error, but ok

#

have you tried checking portInput.text.Length to see if there are chars you aren't seeing

rancid lily
#

good idea. Will do that now though I did Trim()

naive pawn
#

there are some invisible non-whitespace chars too

#

i would hope they didn't get in there but im not ruling it out yet lol

rancid lily
#

yep ๐Ÿ˜…

#

eol? I would have thought that would be trimmed

#

And is there a better way of getting a number of from an input?

polar acorn
#

Ah this fuckin thing

#

The TMP_Text of an input, and specifically of an input, has an invisible non-printing character that isn't removed by Trim

#

Lemme check my post history for what the unicode of that was...

rich adder
#

put the InputField mode to numerics only it has its own regex thing built in

polar acorn
#

.Replace("\u200B", "")

#

It tacks on a \u200B character at the end of the input field. If you're ever getting .text from it, you need to replace that with empty string

naive pawn
#

ah of course, ZWSP

#

....whyyy?!

rancid lily
#

so I just used a TMP_InputField object instead of TMP_text and that works lol

rich adder
#

why do you get text from a TMP_text in the first place lol

#

assuming you had inputfield in the first place ๐Ÿค”

rancid lily
#

I was doing it like this

naive pawn
#

wait, ZWSP is whitespace though apparently it isn't.

polar acorn
polar acorn
naive pawn
#

because i lied it isn't whitespace

#

thanks unicode

rancid lily
#

so has a serializedField for TMP_Text instead of TMP_InputField and passed the text component in directly instead of the input field. I thought that would be more direct and therefor easier

rich adder
polar acorn
umbral bough
rich adder
#

interesting.. first time I've heard, I'm sure you got specific needs for it.. for me feels icky in a sense , kinda goes away from an MVP type pattern I'm used to

rich adder
#

using playmaker

spiral narwhal
#
Addressables.LoadAssetsAsync<GameSettingsSo>(BASE_SETTINGS_KEY).Completed += handle =>
            {
                if (handle.Status is AsyncOperationStatus.Succeeded)
                {
                    DeclaredSettings = handle
                        .Result
                        .OrderBy(settings => settings.LocalisedTitle.GetLocalizedString().Length)
                        .ToArray();
                    InstantiateIfEmpty();
                }
#if UNITY_EDITOR
                else
                {
                    Debug.LogError("Could not load base settings");
                }
#endif
            };

How am I supposed to do this if Unity doesn't allow that? :( Exception: Reentering the Update method is not allowed. This can happen when calling WaitForCompletion on an operation while inside of a callback.

ruby shoal
#

What am I doing wrong here?
I am using playmaker, and I have a polygon collider2d on the object.
However, its as if the game doesnt even detect the mouse. Am I missing something?

rich adder
#

we dont even know how Mouse OVER works in playmaker context

#

this is a coding channel

naive pawn
#

purely guessing, but - it may be using old OnMouseOver events, which wouldn't work with the new input system, which is set by default as of v6.1

rich adder
#

OnMouseOver uses raycast for colliders no ?

naive pawn
#

i thought the OnMouseX messages just didn't work with new input system?

#

i haven't tested, but that's what ive been seeing other people say

rich adder
#

hmm let me test that rq

frail hawk
#

i had that yesterday, i think Chris is right, it only works with the old one

rich adder
#

yeah you're right

#

just tested

slender nymph
rich adder
#

shit.. you would think they now put that on the OnMouse docs ๐Ÿ™„

slender nymph
#

they really should for unity 6.1+ since the input system is the default there

rich adder
#

"we gonna switch you to new input system but tell you nothing about old methods not working in docs for OnMouse"

frail hawk
#

would be something i would expect too

rich adder
#

guess now its a good time to click this

spiral narwhal
#

You could use both input systems

rich adder
#

yes, its just a weird oversight for unity not to mention this change in the new 6.x docs for OnMouse

#

you have to find it in the new input system docs which most newbies wont know about right away

spiral narwhal
#

Oh absolutely

rich adder
#

hell even a nice in-editor message
"we detected you are using OnMouseOver with new input system , this will not work" or some shit

rancid lily
#

Trying to make regex for ipv4 input validaton. For some reason I can type this in the input field, but when I go on regex101 it does't accept. Any idea what the discrepencies are about?

rancid lily
naive pawn
#

you limit consequtive digits to 3 max

rancid lily
#

Right, which is what I want

naive pawn
#

oh i misunderstood your question

rancid lily
#

but for some reason I can type 4 consecutive digits in the input field

naive pawn
#

yeah this is not a code question

rancid lily
#

aight thx

slender nymph
#

pretty sure that's validating individual characters, not the entire string

rancid lily
#

ah, it does say 'character validation'

foggy marten
#

Is there a way to make it so a script file takes all floats written in it with only 2 decimal places? I don't wanna use Math.Round() for every multiplication between such variables

foggy marten
polar acorn
#

It's generally better to just let the math happen with the real values and only round at the end

rich adder
#

floats preserves full precision until you round or truncate it

foggy marten
slender nymph
#

that shouldn't throw anything off unless you are doing something silly like comparing floats using the equality operators

polar acorn
polar acorn
#

Do the math, then round the result

slender nymph
# foggy marten Well, about that...

yeah so the issue isn't that you need to change the math, the issue is that you are doing comparisons wrong. use Mathf.Approximately to compare floats rather than the equality operator

foggy marten
slender nymph
#

then if somehow regular floating point imprecision (which will not be solved by simply rounding the floats) is throwing off that, then compare with an epsilon

#

which Mathf.Approximately is doing for equality

foggy marten
#

Basically, In one of my methods, I have if statements, where it compares the current position of an object and the outer bounds of a box it is in

slender nymph
#

did you know you can use the Bounds struct for that instead of manually checking

foggy marten
fresh rampart
slender nymph
foggy marten
#

Honestly, it's better to explain my problem with the context included

eternal falconBOT
slender nymph
rich adder
#

not seeing anything drastic that would cause memory leaks..

polar marsh
#

Hello I am new in Unity So I know how to use Unity because of Blender but I don't know about coding So I watched Roll a boll Tutorial on Unity learn and only understood some basics like Start, Update, Vector3 and Variables so many things I didn't understand so can anyone tell me what should I do next? Should I watch the same tutorial again Or something else?

rich adder
fresh rampart
#

!code

eternal falconBOT
rich adder
# fresh rampart

check the stacktrace and see where they are coming from, otherwise you need to use the memory profiler or something like that to check

rich adder
#

links for large code

#

this is not likely the code you shown

fresh rampart
rich adder
#

this is explains a lot more than Roll a Ball iirc

rich adder
#

after clearing log window do they show up ? did you try actually removing the script and see if the warning come back after clearing ? etc.
debug starts with simple steps to isolate where issue comes from

polar marsh
rich adder
#

doesn't hurt to also do some focused on c# specific tutorials, unity ones is trying to teach you both the API and C# at same time it might be overwhelming for some

#

things like "what are functions, how do we write the syntax" etc. I havent seen the entire learn course but not sure if it covers those

polar marsh
rich adder
#

I'd recomend you start with simple apps like a small calculator, atm system, or like grades for students etc.

sour fulcrum
#

which is all games end up being if you reduce them enough ๐Ÿ˜›

polar marsh
sour fulcrum
#

Unity might/will have varying prefered ways of doing things but you can use everything there in unity

rich adder
#

except for specific Console app quirks like Console.WriteLine etc.

#

Unity have their own function for that like Debug.Log

#

but the concepts and variables will be the same

polar marsh
rich adder
#

good , thats like the best first line to learn in unity

#

make it a priorty to print everything you're doing so you can see your results

#

Console app is just quicker because you work directly in the "Log window" without worrying UI or cameras etc. Balance it out
now you got online compilers anyway so you can easily do it all in browser like the learn courses on .net

fresh rampart
stoic summit
#

is there a better way to do nullchecks than the wholeass if statement every time? seems really inefficient
but also I'm dumb

rich adder
sour fulcrum
#

Depends on the check

rich adder
#

whats wrong with if statements

stoic summit
#

they make me angry

#

yeah I'm just being dumb then imma say

sour fulcrum
#

You'd have to provide an example or two

rich adder
#

they are literally the base conditional for the language and most logic.. lol

naive pawn
#

if it's a UnityEngine.Object (components, GOs, etc) then you can just use the boolean conversion if you want a shorter version that does the same thing

naive pawn
#

no it's just... a shortcut

rich adder
rich adder
#

just make sure you have the proper plugins. if you install Unity plugin it will install the rest

eternal needle
stoic summit
#

makes sense, thanks homie

rich adder
vapid copper
#

ive decided to go with .net and use apis and make web requests for data. currently its just local but if it were to go live id get a server or something

#

do you have any objections? or think this is a good idea

rich adder
#

Your Unity app should never have Credentials to anything , especially a database connection string etc.

#

anything on client can be decompiled and stolen

vapid copper
#

ah i see gotcha. yea so the way this is setup is that its a different project.

rich adder
#

so yeah a nice WebAPI with .net core is the way to go

vapid copper
#

do you still think hard coding passwords in there is unsafe?

rich adder
#

not as risky if its just living on the server but should never store in code itself but inside environment variables / key systems

vapid copper
#

ah ok so something like azure

#

Ill probably just go with azure for safety eventually

rich adder
#

azure has keyvault or something like that yea , also if you use a VPS to host the api that can also just store it in the OS with ENV vars

vapid copper
#

ok bet

#

thanks man

rich adder
#

np. goodluck ๐Ÿซก

glossy crystal
#

What do I need to learn to build a basic online game (using a client server model)? Iโ€™ve done a few unity projects, but my university coursework and internship so far dont have anything to do with networking so Iโ€™m lost

Is there a good resource or book thatโ€™s relatively up to date I can read/work through?

glossy crystal
#

Thank you

sage mirage
#

Hey, guys! I have a "serious" issue with a null reference, like everything was fine I didn't have wrong syntax or whatever when getting the component of the game objects and basically everything was fine, but at the end I found that the problem was in timing and what I mean is that the scene needed like 1 second or so to load the game objects and I had to create a coroutine for this purpose because I am currently on my project using data persistence approach because I want a game object to persist between two scenes and really the problem I have sometimes it that I cannot find what is causing the null references sometimes when they aren't obvious. What do you think how I am supposed to deal with them maybe some professional advice?

sage mirage
#

Yes of course but sometimes it isn't really obvious I mean it isn't especially when code is getting larger and larger

#

Maybe I have to use if statements

#

to check null

rich adder
sage mirage
#

For example now I had an issue

#

With timing

rich adder
sage mirage
#

I wasn't able to find the null issue

#

what was causing it

rich adder
#

on the NRE message? which line does it say and which script

#

there is no doubt except if you have multiple reference types on that line

sage mirage
#

I know that

#

I know all of that you say

rich adder
#

not sure I get your question then

solar hill
#

if im understanding the issue it sounds to me like youl have to set up a Single Entry point script

sage mirage
#

I always view console for these purposes

rich adder
#

little confused then on hows it not obvious which one is throwing

sage mirage
#

and I dont ignore errors like this

solar hill
#

so wait it shows where its null but not why its null?

#

or

rich adder
#

the WHY is for you to find out, NRE will only tell you WHERE

polar acorn
solar hill
#

yeah im aware

#

i worded that badly

naive pawn
#

the why is just, either it was set to null, or it was never set to anything else

polar acorn
#

The why is always the same - because that variable is null

sage mirage
#

Now, it was first time I was dealing with null reference that wasn't really obvious to me like I had to call a coroutine because like I said I am doing data persistence and the objects weren't loaded at the scene load immediately and I had to create a coroutine to wait for one second for example

#

Because I was trying to get the component of a game object and it wasn't yet instantiated at the scene load and thats why it was null

rich adder
solar hill
#

single entry point

rich adder
#

thats why you typically would use Event

#

an event will tell something else when its "ready"

#

instead of you timing it poorly / guesstimating

naive pawn
#

haha race conditions go brrrr

sage mirage
rich adder
solar hill
#

yeah youre on the right track with the observer pattern it just has to wait not some arbitrary amount of time

#

but rather until the scene is ready

#

guaranteed ready to be exact

naive pawn
#

the objects weren't loaded at the scene load immediately
yet you were trying to access them then.

you might have it in your project, but you aren't utilizing them here

rich adder
#

it would help also if you showed us which line and some context for it

#

there are other events that you can use but without further details its hard to make a specific recommendation

naive pawn
#

in general you should try to design to not have race conditions as well

sage mirage
rich adder
#

yes even that can have a flaw depending when you subscribe to the event . Eg is the event firing before other scripts that care for it subscribing after, and so on

sage mirage
#

And I think that's the most important part of programming like really structuring your code that way, so it will be maintainable, readable, efficient and well structured for you if working solo or on a team where things are getting more confused.

#

Its easy to write code but ๐Ÿ‘† this is the hardest part

rich adder
#

yes exactly , thats the million dollar statement.

#

thats an art in itself

naive pawn
#

that's why software engineering is engineering

rich adder
#

comes with lots of trail n error IMO . Sure you can copy patterns online but it wont be exactly specific to your project, thats best done for you to try what works and what doesnt and eventually make your own bones

solar hill
#

in my opinion

sharp mirage
#

!paste

#

what are the common paste sites called again

rich adder
eternal falconBOT
sharp mirage
#

alr

#

basically my rigid body isnt falling after i made some coroutine code

#

lemme paste the code

#

heres some other code which is sort of linked to the co routine but probably isnt the issue

#

but when i click play i cant move my rigid body or anything

rich adder
#

dont see anything in these two scripts that touch the rigidbody movement ?

#

missing context

sharp mirage
#

ok now its falling wth

#

๐Ÿ˜ญ

rocky canyon
#

magic solution ๐Ÿ™‚

rough granite
sharp mirage
#

it was prolly broken in general maybe cuz my roll timer and roll threshold values were 0 in the inspector

rich adder
sharp mirage
acoustic belfry
#

QwQ

polar acorn
acoustic belfry
#

i dont recall it

#

sorry for dissapoint.....

polar acorn
#

Have you used prefabs in your project at all

rich adder
#

pretty sure they have spawned things before lol

slender nymph
#

there are 15 separate results in their history of them demonstrating the use of Instantiate

acoustic belfry
#

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

#

you meant this!
GameObject nuevoProyectil = Instantiate(balas, balasPos.position, Quaternion.identity);

polar acorn
#

Yes by instantiate we mean instantiate

#

thats why the word instantiate was used

acoustic belfry
#

no i mean, i forgot it was called instatiate

#

i dont see this code very oftern cuz is inside a method i always use

grand snow
#

long day im sure ๐Ÿ˜†

acoustic belfry
#

so i remember the method and not the word instatiate, i just call it, spawn

grand snow
#

hopefully it makes more sense now

#

next time just google "unity instantiate" and you will remember

acoustic belfry
#

ok

#

is just that i asked chatgpt and didnt worked... heh, sorry

thick saddle
#

Hey I'm making a top-down game and for some reason my projectile only bounces off of walls when the wall is not locked in place but when I set restrict the x,y values of the wall the projectile collides with the wall and just stays there

slender nymph
#

show relevant !code

eternal falconBOT
thick saddle
#
private void OnCollisionEnter2D(Collision2D collision)
{
    
    Vector2 currentVelocity = rb1.linearVelocity; //Get the current velocity right at the moment of collision
    Vector2 reflectedVelocity = Vector2.Reflect(currentVelocity.normalized, collision.contacts[0].normal);
    speed = currentVelocity.magnitude;
    rb1.linearVelocity = reflectedVelocity * speed;
    rb1.position += reflectedVelocity * 0.01f;
}
#

this is projectile collision code

#

I don't know if there is any other relevant code but the walls have a tilemapcollider2d and rigidbody2d

slender nymph
#

hint: log relevant info such as the velocity used

cold elbow
#

hello everyone Ive been struggling with an issue for so much time now, Im making a pong game clone, and the provided code is the ball script and a ball spawner script attached to a ball spawner game object, the issue is as soon as the ball spawns the ball stays still and doesn't move at all, ive tried logging the velocity it still prints a non zero velocity in the console so I have no idea what the issue might be, here's the relevant code:

#

omg this is so annoying I cant send it

#

it's too long

rich adder
eternal falconBOT
cold elbow
rich adder
#

good game btw from your pfp

cold elbow
rich adder
slender nymph
#

ideally the entire inspector window when you have the ball object selected

cold elbow
#

wdym

slender nymph
#

which part was unclear?

cold elbow
#

you mean in unity?

slender nymph
#

yes . . .

cold elbow
#

ok

slender nymph
#

ideally the entire inspector window

rich adder
#

simulated is unchecked

cold elbow
rich adder
#

hence the warning unity gives you

cold elbow
#

omg I have no idea how I didn't see it

#

thx

#

it works perfectly

rich adder
acoustic belfry
grand snow
#

how does it look?

#

I just imagined there was some large list/grid that is shown which should be easy to fill with elements automatically

frigid sequoia
#

Does a dictionary allow for duplicates by default? Like two different keys pointing at the same instance as a value?

timber tide
#

keys are unique values are not

cold elbow
#

alright now im running into another issue

timber tide
#

but not hard to make a wrapper and make unique value dict

#

just a comparison

#

Actually no, it would require iterations

frigid sequoia
#

So if I make like a dictionary that basically is a reference to the id of a gear prefab and its prefab, the id string should be the key or the value?

#

Doesn't really matter much right?

grand snow
#

er the id should be the key?

#

the key is used to get the value

acoustic belfry
#

thats why the tree

timber tide
#

Ah, you'd have a Hashset for the values to make a truely unique key/value

acoustic belfry
#

it ain't pulished by sprites for now, so except it to look ugly

#

three tabs for the categories
5 buttons that change depending on the category
a display of Info
of a photo
and of a name

grand snow
#

Is there a reason why these "Button" buttons are shared?

#

Do you press one to view information about the thing?

frigid sequoia
acoustic belfry
#

i mean

#

in theory would be

#

5 x 3 = 15 buttons

timber tide
wraith coyote
#

Somehow i'm facing a situation where lighting does not work out of the box. I wonder why. Anyone come across this before?
(the cube/plane is not affected by the directional light)

grand snow
#

You can just spawn buttons dynamically based on your wiki scriptable objects

acoustic belfry
#

wat

#

but how would you positionate them

grand snow
#

layout group

acoustic belfry
#

wat

frigid sequoia
grand snow
#

ugui has horizontal and vertical layout groups to auto layout children for you

frigid sequoia
eternal needle
timber tide
#

Hashsets are dictionary-lite

#

but you need to map an ID to a value do dict it is

acoustic belfry
grand snow
#

If all those "tab" buttons do is change what is in the button list, you can just rebuild it when you "change tab"

frigid sequoia
#

The idea I have is to basically make the gear, when checking if it's valid in inspector, automatically send a call to the dictionary, for it to generate the id key as the name of the item, check if it's on the dictionary already and if it's not add it and look for the prefab on the folder with the same name as the value

cold elbow
#

The attached picture shows the inspector for both scanners right and left (ball inspector is above in the chat), the issue im running trough is that when the ball goes trough that edge collider it doesnt detect the collision therefore the log inside the if statement doesnt get printed heres the relevent code, the ballcontroller script and the ballscannerScript
https://paste.mod.gg/wnzxyfxlnijx/0
https://paste.mod.gg/dlajkzkbydvl/0

frigid sequoia
timber tide
wraith coyote
timber tide
#

So is it editor or is this deserlization save/load in game

#

sounds editor so you can use Asset IDs too

cold elbow
#

tbh

frigid sequoia
frigid sequoia
#

But I don't really know how to access it

timber tide
#

So what exactly is this ID and what is it for again? Is there a reason you can't just use references as the IDs if this is editor

frigid sequoia
eternal needle
timber tide
grand snow
# acoustic belfry rebuild? how i do it?

update what the buttons say and do each time you change "category"
you could destroy them all and re make them or re use the existing ones (hiding extra ones and spawning extras if needed)

#

This is what I do for UI like this that can be refreshed with changing data

frigid sequoia
#

Mmmmm, ok, so this basically would give me directly the path to that folder in the editor, but I wouldn't be much reliable to look for that on runtime right?

timber tide
#

You need to hardcode the ID into the asset if it's at runtime

#

what people do is usually have some OnValidate method and grab the asset ID and make a property inside of the asset for it

#

Or just use c# GUID library and generate your own

sharp mirage
#

why am i getting this when i try drag the rolling script onto the object

timber tide
#

You cut off the screenshot of the editor there. Show below asset directory there

polar acorn
polar acorn
sharp mirage
#

oh

#

now im back to where i was before

#

very cool

rugged beacon
#

how do i select one prefab to load from resource?
like with text its resource.load(Levels/level2.txt)?

frigid sequoia
#

AssetDataBase.AssetPathToGUID() would return null if the path doesn't exist right?

mighty pilot
#

Creating a train game where you are placing down the rails. Would anyone be able to point me toward some guidance on how I could do the pathing on that? It is based on a grid and the track could loop back around and/or split (with player controlling direction).

rocky canyon
#

probably could use splines feeding the grid coords as positions along the spline

#

have the train follow that.. the rest just sounds like normal tile placement (having bends, splits, str8 pieces and whatnot)

timber tide
#

yeah if it's a grid then I expect you to just have a bunch of railroad assets instead of generating it via spline

#

not that you still cant use the spline tool, but you'd use it to figure out the indices to build for what indices it goes through

mighty pilot
#

Also I do plan to use grid based assets for the visual part. Splines does seem good for smoothing the movement with corners.

#

This is 2D top down btw

timber tide
#

Another idea is using a texture too assuming there is no y

#

1 pixel = 1 index

#

but would need gaps between so you'd probably have some flowfield instead

grand snow
#

If each button gets initialized in some way you just do it again when stuff changes

acoustic belfry
grand snow
#

Maybe each tab has a script that has a serialized list of the scriptable objects it shows?

#

many ways to do it

acoustic belfry
#

simplier?

grand snow
#

that is simple

acoustic belfry
#

no i mean, you said there was many ways to do it

grand snow
#

Oh, well another way could be each tab has an enum to specify its category and thats used to retrieve the list somehow

#

but may be a bit harder for you

#
switch(tabCategory)
{
  case TabCategory.Shoes:
    return shoeList;
}
acoustic belfry
#

this seems easier but what this have to do with the button-spawning/despawning

#

this just makes the tree more organized

grand snow
#

you need to see the bigger picture of how this UI could work

acoustic belfry
grand snow
#

we want it to show a list of information and you can change categories from a smaller list of buttons
therefore we need the category buttons to update whats shown when clicked

#

meaning we need our data to be sorted by these categories and we need to know what to show when the category button is pressed

acoustic belfry
#

yeah

#

like the tree

#

just more organized

#

i just didnt used this cuz.... i dont know why honestly, but yeah

#

state stuff

grand snow
#

e.g.:

public enum Category {Shoes, Cats}

public class CategoryButton : MonoBehaviour
{
  public UnityEvent<Category> OnClick;

  [SerializeField]
  Button button;
  [SerializeField]
  Category category;

  private void Awake()
  {
    button.onClick.AddListener(() => OnClick.Invoke(category));
  }
}
#

often helps if we make a mono that performs the button task and holds extra information

acoustic belfry
#

i dont follow ;-;

grand snow
#

it may seem daunting and complex. I would write a large example but i dont have the energy or will rn

acoustic belfry
#

ok

sharp mirage
sharp mirage
polar acorn
#

If the log says FallVelocity is 0 then it's 0

polar acorn
#

Find out which one it's happening at

sharp mirage
#

if that makes sense

polar acorn
#

It will print the value of FallVelocity as it is at the time that log runs

grand snow
#

perhaps you can do the same, have a category field on your "wiki scriptable objects" and the category buttons show/hide things depending on what category is selected

acoustic belfry
#

oooh nice

obtuse crescent
#

I have started to try things in a different project but i cant get my player controller to work, i keep getting this error code : You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings
Unity input package has been uninstalled for a while and yet its still telling me i switched to it. Can anyone help?

polar acorn
wintry quarry
nova kite
#

omg making a state machine for a navAgent is SO much easier than for the player

#

not having to deal with all the input logic and just have it follow commands in each state

#

i finally understand it now haha

eager elm
#

I use Cinemachine set to Follow. I move my player in FixedUpdate with transform.Translate(). Once the camera "caught up" with the player it starts to jitter. If I move my player in LateUpdate() or I cap the framerate to 60 or 120 it is fixed, but I'd prefer not to do either of those.
Is there a third option?

boreal plinth
#

Hi! I've taken a class on C++, but I've never used Unity. I want to import a function to a script to be used by another script, and usually you would do #ifndef, but I don't think that works in Unity.

I made an empty object, put both scripts in the object, and get the error message of: "NullReferenceException: Object reference not set to an instance of an object
DateDisplay.Update () (at Assets/GAME/UI/Scripts/DateDisplay.cs:37)"

teal viper
# eager elm I use Cinemachine set to Follow. I move my player in FixedUpdate with transform....

Either move your player in regular update, or let physics move it(via rb) and enable interpolation on rb, or implement something similar to rb interpolation in your own logic.

Setting the cinema chine brain to update in fixed update might also be an option, but it might not eliminate the jitter entirely.

P.s. Honestly using transform translate in fixed update sounds like a terrible choice to me. I can't think of any reason to do that.

boreal plinth
#

Oh

teal viper
eternal falconBOT
teal viper
#

Then I suggest going on some C# basics.

boreal plinth
#

I use visual studio

#

Unless you're asking me to update it

teal viper
#

Im telling you to configure it/your environment to work with unity correctly.

#

The bot message covers that.

boreal plinth
#

Ah

teal viper
#

When you're done, it would help if you share your !code properly too.

eternal falconBOT
boreal plinth
teal viper
boreal plinth
teal viper
# boreal plinth

Still not configured. Follow the installed manually guide and don't skip any steps.

#

As long as you see Miscelenious files here, it's not configured

boreal plinth
#

Wow. So all I had to do was capitalize the function name ๐Ÿ˜ญ
Thank you so much for the fast response tho because the new editor did let me know that

#

And it works now

frigid sequoia
#

So, the GearDataBase should be a scripteable object here?

#

Cause I kinda wanted to make it a static clase, but I clearly cannot, sicne I need to modify their values lol

frigid sequoia
#

Could like make the SO kinda like an singleton to access it wherever??