#💻┃code-beginner

1 messages · Page 664 of 1

acoustic belfry
#

thats usefull too... But i feel like is too complex for what im looking for

what my current system does is just, turn a UI element On, add text and image to that UI element, change depending on an INT value (wich keeps rising and rising using the next command)

so i need that each if (DialogueInt = NumerOfDialogue) { } is modificable, and lets you in the inspector add the amount of this blocks as you desire wich each image you desire

Yet i may try to learn it anyway, thx

#

mmm

but has good features like choices and stuff...

Ink honestly looks promising

rich adder
# acoustic belfry thats usefull too... But i feel like is too complex for what im looking for wha...

ink is quite simple once you use it, and there is a reason this exist so you dont have to manually rewrite everything yourself.. dialogue and some basic branching is done via easy Markdown language with their editor inkle..all it does it create some json files that will read branching and all those useful systems with dialogue, but thats optional anyway. Tags are there to execute specific animations/ functions etc.. Lookup tuts on it is pretty good.

#

btw = is assignment , == is comparison

twin pivot
#

i tested it with OnMouseUpAsButton

acoustic belfry
#

ooooooh, sounds good, then i guess i will Ink this instead
thx UnityChanThumbsUp

rich adder
twin pivot
twin pivot
frigid sequoia
#

So... I am using just scripts that attach as components to the entitues to apply stuff like shields, and here comes the problem. Is it fine if I use a different script for each single different type of shield? Cause they need to have some kind of formating on the text and show different icons and that's pretty darn annoying to setup when adding it as a component directly. I was using hardcode and file paths for that kind of stuff

#

Should I refactor the whole thing so it is instanciated as a prefab object that attaches to the entity rather than a component or is not much of a issue if I keep it as it?

#

Cause honestly I prefer to have it attached directly to the object rather than in a hierarchy but... if it's gonna be this troublesome I may as well change it

rich adder
eternal falconBOT
rich adder
# twin pivot I ment ``OnMouseUpAsButton``

just tested and works fine for me

public class shrimp : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    public void OnPointerDown(PointerEventData eventData)
    {
        Debug.Log("pointer down : " + eventData.button);
    }
    public void OnPointerUp(PointerEventData eventData)
    {
        Debug.Log("pointer up : " + eventData.button);
    }
    void OnMouseUpAsButton()
    {
        Debug.Log("mouse up");
    }
}```
#

clicked both buttons on mouse

sour fulcrum
frigid sequoia
#

So let's say I want a SO that basically sets these parameters of the component automatically for this specific type of status effect when instanciating it, so I can reuse the rest without duplicating but instead just creating a different SO

#

How do I do that?

#

Cuase I have seen a bunch of SO videos and I am still not sure how that would help me on this implementation

sour fulcrum
#

give me couple minutes, but the idea here isn’t to help you setup that classes’s data, it’s to move it to the SO completely

frigid sequoia
#

? Like.... the whole thing? How?

sour fulcrum
#

is shieldValue something that changes at runtime?

twin pivot
frigid sequoia
rich adder
sour fulcrum
#

Is that shield color changing per type of shield?

#

or no

frigid sequoia
#

It's for all types of shield, it's just referencing the color coding palette I am using so all of them get changed at the same time if I decide to modify it

sour fulcrum
#

yup no worries

#

just trying to whip up a little example hence the specific questions

#

When you say different formatting on the text, could you provide two examples?

twin pivot
#

since yall are talking about SOs, would it be better to store all the dialogue for a game in a SO instead of just having a string[]

sour fulcrum
rich adder
#

player isn't even in the layer Player

#

which is what you set Raycaster to only detect

twin pivot
#

oh my god i am going to stab someone

sour fulcrum
twin pivot
#

I thought I did that when creating the gameobject

rich adder
#

you're in a type safe language, use it to your advantage

#

make the tile a component and put them in an array if they are gameobjects

frigid sequoia
#

But in inheritage from status effects they have other stuff like current stacks or duration

naive pawn
#

a common script with a serialized unityevent that's overridden in the inspector could work

frigid sequoia
#

But that's not directly displayed there

twin pivot
twin pivot
frigid sequoia
#

Mostly the main issue is description needs to reference the text formating, which is way more confortable from code and that they don't have a reference to the icon

#

I could pass that from the skill tho, just... a bit more messy and confusing I would say

sour fulcrum
#

Ok I'm gonna pitch you a rough idea or so

#

and this isn't neccasarily the right way to do things

#

and is made in the context of what i know and dont know about your project

#

you might vibe with some of it

rich adder
#

not sure why you left that in

sour fulcrum
#

So off the bat, as we've discussed in a previous convo ScriptableObjects are used to keep a MonoBehaviour mostly doing the logic side of things, where the ScriptableObject can store the data the mono uses, this means we can swap out the SO with any instance and the logic doesn't need to care. here's what that might look like

public class ShieldBehaviour : MonoBehaviour
{
    [field: SerializeField] public ScriptableShield ShieldData { get; private set; }

    public void Initialize(ScriptableShield shield)
    {
        ShieldData = shield;
    }
}
public class ScriptableShield : ScriptableObject
{
    [field: SerializeField] public string DisplayName { get; private set; }
    [field: SerializeField] public Sprite ShieldSprite { get; private set; }


    public string GetDescriptionText(int damage)
    {
        return ("Hardcoded thing yayaya: " + damage + " etc. etc.");
    }
}
twin pivot
sour fulcrum
#

So with something like this you have multiple instances of a ScriptableShield and you pass one of them to a ShieldBehaviour to "initialize" it, and the ShieldBehaviour can just point to whatever SO it's been given if it needs to fetch some data

#

should i move to a thread or diff channel btw

frigid sequoia
#

So... let's say I call that from a skill, the skill needs a reference to the SO? And I pass it when instanciating it? Then I would set skillIcon statusEffectName and skillDescription to the value of the SO?

twin pivot
frigid sequoia
#

Caliing the GetDescriptionText I assume

sour fulcrum
#

if you need the skillicon, you ask the logic to fetch the data (eg. myUiImage.sprite = currentShield.ShieldData.ShieldSprite)

#

that way the ShieldBehaviour (the logic of the shield) can just be mostly 1 script

#

and you just change what scriptableobject you've used to create it

#

the shieldbehaviour doesn't care what sprite it has, that's not its job, it just gets it

#

same with that description text, although it really depends on the inner details of that system to decide who's actually responsible for that. i've put it on the SO for now given my current info

#

the idea being you just give the SO the dynamic part of the text (in this case just the damage) and it sends you back whatever it has decided it should be

frigid sequoia
#

I guess this kinda works, yes, would need some adjustments to how I initialize status effects, but not much

#

And I definelty need an superclass for the different types of status effects so I can place all shields togheter....

#

But the main issue I see with SO is.... I don't see much difference on having this on a SO that having it directly on the class that isntantiates the thing u know?

#

I guess it's just another way

sour fulcrum
#

The difference is your not making a bunch of duplicate scripts for no reason

#

it's the data you want to make on a case by case basis, not the code

#

if you get into the habit of seperating your logic and data you'll be way more comfortable

#

speaking of, TextFormatting.shieldColor is just a hardcoded color value yeah?

frigid sequoia
#

I mean, I wouldn't duplicate anything on this case, if a skill cast a shield, it can also store the icon, name, and description of it, it's just a bit messy in code

#

I guess this is chossing if you want to have a bloated code or a folder blaoted of SO lol

sour fulcrum
#

I mean this with 100% respect but it's choosing between worse code and a folder full of SO's that isn't really bloat

#

the datas gotta go somewhere, this is just a better way of organising it

frigid sequoia
frigid sequoia
sour fulcrum
#

Ok so if you will bare with me a minute, we could take our SO use even further with this.

Let's say we did...

[CreateAssetMenu(fileName = "ScriptableColor", menuName = "ScriptableObjects/ScriptableColor", order = 1)]
public class ScriptableColor : ScriptableObject
{
    [field: SerializeField] public Color TextColor { get; private set; }
}
public class ScriptableShield : ScriptableObject
{
    [field: SerializeField] public string DisplayName { get; private set; }
    [field: SerializeField] public Sprite ShieldSprite { get; private set; }

    [field: SerializeField] public ScriptableColor ShieldColor { get; private set; }


    public string GetDescriptionText(int damage)
    {
        return ("Hardcoded thing yayaya: " + damage + " etc. etc.");
    }
}
#

Something like this means

-the color is no longer hardcoded in your script
-the shield SO asset is now responsible for what color is chosen
-because the ScriptableColor is a ScriptableObject asset, even if shields choose to reference different text colors, changing the value on the ScriptableColor asset will change it for every shield using it

frigid sequoia
#

It... would change for any status effect of the type shield, yeah, but not for any other text that uses the shield color color on its text

#

Actually pretty useful, I don't it's in this case tho

sour fulcrum
#

So you do have a valid point for half of that yes, there's two scenarios here

  1. text that would be referring to "the shield color" should ideally have a reference to the shield it's talking about, which means it could pull "the shield" color from said shield.

  2. There are cases where you don't want certain content types to be able to control their own color (eg. you probably want damage or healing to always be a specific color of red and yellow etc.). In that case yes this specifically would not be appropriate, but ill show you a solution to that in a second

gilded oak
#

im trying to translate what im wanting to do in code but its so hard :/

sour fulcrum
#

@frigid sequoia you have some gamemanager singleton that lives forever right

frigid sequoia
#

I have a lot of singletons managing a good chunk of permanent things yeah lol

gilded oak
#

so im basically trying to make it so that my cinemachine camera zooms out as my player character/sphere increases in size

frigid sequoia
sour fulcrum
#

ye dw

#

thats under point two

twin pivot
gilded oak
#

ah, right now i dont have code cause admittedly i looked it up online and copy and pasted the code. tried changing the code to translate to what im doing but still wasnt working at the time

#

so i deleted the code i had

twin pivot
eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

gilded oak
#

dont know how to send code but this was basically what i had except for some differences cause i tried to actually change stuff

eternal falconBOT
gilded oak
twin pivot
gilded oak
#

since im using cinemachine im trying to figure out how to translate that code into what im doing basically, i know ill eventually get it

#

oh

gilded oak
twin pivot
twin pivot
gilded oak
#

the original

twin pivot
# gilded oak the original

youd need to get the scale component of your player gameobject and then use that value as your targetOrthographicSize

gilded oak
#

ohhhh

#

wait i think i actually understand sorta what your saying

twin pivot
#

but at this point i recommend that you start over with learning c# from the basics

gilded oak
#

oh yea ngl was doing that while doing this, probably wasnt a good idea tho

#

been writing stuff in a powerpoint doc of things that come up and what things mean like a vector3 and such

twin pivot
#

I started unity by making a shitty clicker game and honestly I mightve been a bit too ambitious with that start

#

but yea nowhere near as complicated as what ur trying to do

gilded oak
#

well damn

#

that makes me feel both really good and also feel like that i jumped into the deep end without even learning how to swim :/

#

ill check out some c# tutorials then, just hoping i dont get stuck in tutorial hell

twin pivot
#

less deep end and more shark infested waters

gilded oak
#

true

gilded oak
#

oh yea haha

#

reading aint my strong suit but ill give it a try

#

thanks i really appreciate it

#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

gilded oak
#

oh wait, theres videos, nevermind thanks again!

deep moss
#

How do I code like snapping objects using empty child? Like robot arm has an empty child place next to a body and snaps when close. Something like transfom and distance or something

celest flax
#

When making a behaviour tree, how would I go about adding OnEnter() and OnExit() functions to the nodes? For example, I have an enemy that patrols around, and when it sees the player I want it to stop, but because I use rb.velocity to handle movement I need to set the velocity to zero when it sees the player. Is there a good way to do this?

naive pawn
gilded oak
#

thank you, ill try keep at it, i was looking at what project based learning was and it seems like something that i was sort of trying to do but ended up giving up, ill give unity learn a shot tho and if im not feeling it then ill try to do project based learning

strong shoal
#

can someone help me with the lookAt() method

#

bc lookat is rotating in the wrong direction

#

the game is 2d

#

and the weapon should look at the players mouse

wintry quarry
timber tide
#

Usually you can just set the forward of the transform to the look rotation in 2D

wintry quarry
#

LookAt is mostly useless in 2D since the z axis points into the screen

timber tide
#

Otherwise lookat you probably want Vector3.UP?

#

No, it would be vector3.forward

hidden marten
#

huhhh? i have clearly set it why am i getting an error

slender nymph
#

you likely have another copy of the component in the scene where it isn't assigned. search the hierarchy with t:Enemy to find all instances of the component and make sure that they all have that variable assigned

spark berry
#

can anyone help and give me some recommended book , online course or free tutor of making a bullet hell game? TwT I'm a very beginner, confused with game process or timeline (in other words, how to make the different game level or scene combine with time).

naive pawn
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

naive pawn
#

start there

spark berry
#

OHhhh thxxx

#

I just cant find any course of bullet hell game on unity learn XwX

sour fulcrum
#

there's not really courses for genres in particular

spark berry
#

😮 ohhh... how can i start, i can only make really simple game like flappy bird

sour fulcrum
#

add a feature to flappy bird 😄

naive pawn
# spark berry I just cant find any course of bullet hell game on unity learn XwX

and you shouldn't - games are complex beasts with lots of parts
and a lot of those parts overlap between games
fps, first person puzzle games, open world, beat em up, horror games... a lot of types of games have a 3d first person controller. including that in a ton of tutorials would be repetitive.

identify what features and skills you need for your game, and learn those separately. then it's your job to put them all together

spark berry
#

i see. i should learn the parts first and after that i put them together make them a whole game

#

THxxxx

slender nymph
#

is this a code question?

sinful jewel
#

I apologize I just first time on the server if it is not difficult to tell me where it is better to write it?

slender nymph
long matrix
#

Hello guys i want to create a pathfinding for a 2D Topdown game what is the best way?

rich adder
long matrix
#

I tryed to install unity 2D Navmesh but somehow after installing the file i dont see a 2D component

rich adder
#

thats pretty vague , should probably provide more info on that then

long matrix
#

h8man/NavMeshPlus: Unity NavMesh 2D Pathfinding

#

i installed from here

#

to my project

#

assests

#

And i dont have navmeshsurface2D component

rich adder
long matrix
#

I saw on yt

#

and the NavMeshSurface component not working

rich adder
long matrix
#

Hm idk i saw on youtube and they had this component and with my version when i do bake it shows nothing

rich adder
#

well perhaps instead of video follow the official instructions, you either copied / did it wrong or the video isn't up to par.. Always look at official doc methods first

#

other than that not much we can go on without seeing what you did

long matrix
queen adder
#

Hi, so im making a little project about fighting a boss( basically endless attack dodging ) and i want to know if there is a command that can select a random function and play it?

long matrix
#

i have 2 gameobjects 1 walkable and 1 not

#

and a navmesh gameobject with the component

#

When i click on bake nothing happends

long matrix
lofty sequoia
#

what's the setting to turn off auto recompile in unity??

long matrix
#

Hm wait a min

#

There isnt a built command but i have a skript for it

queen adder
#

Oh, thats fine

#

I will try to make it myself then

#

Thanks

lofty sequoia
#

Preferences > Asset Pipeline > Auto Refresh - set disabled

#

god unity sucks

naive pawn
queen adder
#

Ty

long matrix
#

Hey guys do know why the blue area is far from my colliders? and if its k that i get a lot of lines from the navmesh?

#

The colliders are on the walls

hallow sun
#

i would imagine its taking into account the character's width but idk much about navigation in unity

prime pier
#

hey how would i check for a multiple of a number

naive pawn
#

use %, the remainder operator

prime pier
#

okay

naive pawn
#

check if the remainder is 0

rich adder
long matrix
#

I used now navigation collectsources 2d

#

Do you konw why the blue area aint covering the colliders like there's a big space?

rich adder
long matrix
#

hm here are the colliders

#

its a tilemap with a composite 2d collider

rich adder
long matrix
#

Do you mean the NavMeshAgent component

rich adder
#

no

long matrix
#

i dont see radius of agent in navemeshsurrfrace

#

where?

rich adder
long matrix
#

oh i see i turned it down to 0.1 and its better is that good?

#

Oh thats great

#

thanks bro

rich adder
long matrix
#

yes ty

prime pier
#

hi im trying to trigger this to happen every 3 rounds but its triggering just whenever i check it

#

anyone know how i might fix

naive pawn
#

have you tried logging the values

#

perhaps rounds is getting reset

prime pier
#

gimme 1 min

#

it is getting reset every time

#

i can fix

#

thank you

naive pawn
#

though you can just do if (rounds % 3 == 0) directly fyi

prime pier
#

i tried doing that but i kept getting errors

#

that just worked lmao

#

im not too worried ab it its js for college last day of the project

naive pawn
prime pier
#

i was prob just putting it in wrong or sum

#

i thought i did just that tho

#

prob misremembering im dumb af

rich adder
#

also counter seems to never be used in that function..

lusty star
#

HOW
HOW is the code different WHY does it allow me to write the vector3.up in the other one but in another it DOESNT????
ignore the fact they are both called movement those are 2 scripts from diff games

frail hawk
#

maybe you have a class called Vector3

whole osprey
lusty star
#

nah its not that

#

thats weird? i changed to UnityEngine.Vector3.up and it fixed but the weird problem is
what i copy pasted the code from the other one to see if maybe the C# updated or smth but no, when i copy paste it vector3.up STILL works?????

frail hawk
#

then it is what i said, you got another class called Vector3

lusty star
#

i fucking hate this what, what what CHANGED?????

slender nymph
#

next time read the actual error message. you likely were using System.Numerics.Vector3

lusty star
#

can i send a vid?

frail hawk
#

what is the error message how about telling us

polar acorn
#

You can easily find out which by hovering over the error

#

No video is needed

lusty star
whole osprey
#

Yeah, your video shows exactly what is wrong in the error message. It's just what boxfriend said.

lusty star
#

yeah uhhh so you were all right it was this thing

#

thank you

gilded oak
#

was just gonna start the unity essentials tutorials on the unity learn website. i use unity 2023 but its wanting me to download unity 6. am i okay to use my unity 2023.2.20f1 or do i have to switch to unity 6 :/

#

the reason why im wondering is because i use unity 2023.2.20f1 for uni and im unsure how different it is to unity 6

runic lance
#

but 2023.2 is not an LTS version, so you should update to 6 if possible

#

might save you a bit of headache of running into Unity bugs

gilded oak
#

ah rip okay

#

as long as its not too bad switching from one version to another when im working on uni stuff

#

then its all good

formal sky
#

Hi guys, a question
I wan to drag this prefab to Door Object but it keep saying "Type mismatch", change to animator it also still say the same. Any idea how ot fix?

polar acorn
formal sky
#

yes

#

need to unpack first? but the gameobj disappear afterwards no?

#

but that scene obj is a prefab also..hmm

grand snow
#

a prefab ASSET can only reference other assets

#

a prefab INSTANCE in a scene can reference things in that scene and a prefab asset

polar acorn
grand snow
#

You need to set such a reference at runtime with ✨ code ✨

formal sky
#

ah..then for actual export of game...
i need to prefab the scene gameobj and then drag it to the doorobj?

frosty hound
#

!collab

eternal falconBOT
#

: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

split flax
#

Thx

frosty hound
#

Though you'll be hard pressed to find someone who will be willing to volunteer their time for free to mentor you. That's something people do for money.

split flax
frosty hound
#

If you say so. Good luck 👍

split flax
idle grove
#

im sorry but what did i do wrong?

#

following this video ||https://www.youtube.com/watch?v=XtQMytORBmM&t=146s&ab_channel=GameMaker'sToolkit|| and i dont know what i did wrong

🔴 Get bonus content by supporting Game Maker’s Toolkit - https://gamemakerstoolkit.com/support/ 🔴

Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and...

▶ Play video
hallow sun
idle grove
#

it worked

#

i mean, the game read it as actual code

#

but the outcome wasnt the same

#

the character didnt float up endlessly, it just fell

#

i didnt changed any values so i dont know why

#

it is taking MyRigidbody away from the slot for some reason

#

ok now it didnt after the third try

#

godamnit

hallow sun
#

you mean this one? is it having errors here?

idle grove
#

2 times when i was starting the game it simply cleared the my rigidbody space before starting, so the game wasnt reading that the body had script in it

#

but then the third time it just sticked and worked

devout flume
#

I didn't find velocity recently somehow, I got pushed towards linearVelocity, idrk why but yeah lol

polar acorn
#

It was renamed in Unity 6 to differentiate it from angularVelocity

#

Your IDE should just tell you whenever you try to use velocity

#

If you don't get error highlighting, !ide

eternal falconBOT
fading gull
#

I have done some tutorials before, but haven't gone too far into them. say if I was starting at ground 0, where should I start?

teal viper
eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

cyan osprey
#

does anyone know how i can make this inventory system where i can drag items around freely and it pushes other items around?

teal viper
cyan osprey
#

i want it to be like vr games like ghosts of tabor where u can freely place them wherever in your backpack and its not some tile based inventory

#

@teal viper

#

and im also making it a 2d thing

teal viper
cyan osprey
#

@teal viper well there is no collision with the items in the inventory system in that game, but i would like mine to have some collison so that it pushes items out of the way if the user is moving an item

teal viper
#

And use the render texture in a UI raw image if you want.

frigid sequoia
#

If I call an event and one of the listeners is disabled, even if another listener previously on the chain activates it, it is not called or am I missing something else?

sour fulcrum
#

wym one of the listeners are disabled

frigid sequoia
#

Object 1 invokes an event for object 2 and 3. 3 is disabled but object 2 triggers first (in execution order) and activates object 3

#

Does it work like that?

#

Is object 3 getting the invoke?

sour fulcrum
#

nothing about events knows nor cares about unity's concept of an object being enabled or not

#

listeners are in order though yes

frigid sequoia
#

Oh, so I could activate a script by calling it with an event from itself, even if it was dissabled?

sour fulcrum
#

sure

frigid sequoia
#

That's nice to know

sour fulcrum
#

something being disabled is just a Unity thing that in 99% of cases just means

-stops recieving Unity's various reflection based messages (update, lateupdate, ontriggers(?)) etc.
-doesn't show up in certain functions (findobjectsoftype etc.)

frigid sequoia
#

Oh, I think it's not getting called just cause it starts disabled and therefore is not subscribing in awake

#

I guess I should make it begin active and then disable it automatically the first time??

glossy crystal
#

Hello, how much of a difference is having a data representation of a gameobject in memory versus the actual gameobject in memory? I know this obviously varies by what kind of data I'm storing, but my use case is having data attached to tiles, and using object pooling to instantiate the gameobject when the tile is close enough to the player. (There are at most ~2 thousand tiles that can have data/gameobjects associated with them)

teal viper
glossy crystal
teal viper
#

Regarding frame time, if there's no code running on these gameObjects, it's unlikely to make a huge difference. But if you want to know for sure(both regarding memory consumption and processing time), you should profile both cases and compare the results.

fading laurel
#

Hi to all, i had a question, how can disable in Visual Studio 2022 the reload, each time i add a script in Unity VS close all open files???

teal viper
fading laurel
#

For example i had 5 scripts open in visual studio, but i add a new one in unity, when the project reload in unity, reload too in visual studio but close all files opened previously

naive pawn
frigid sequoia
#

The game object IS dissabled, ye

#

I had to make an intilize on those

naive pawn
naive pawn
frigid sequoia
#

Those are practically, synomins, but sure, makes sense

teal viper
eternal falconBOT
naive pawn
# frigid sequoia

what's the purpose of isInitialized here? Awake is only ever gonna be called once

fading laurel
frigid sequoia
naive pawn
frigid sequoia
#

I know they work differently

naive pawn
frigid sequoia
naive pawn
#

not on the same instance, no

#

not sure what scenario you're referring to exactly, but if this object is DDOL'd and the scene is reloaded, only the new instance will be awoken

frigid sequoia
#

Uh, well, one less parameter I need to use them, cool

#

It wouldn't be like superuseless still, cause you could force a call to the awake method anyways

#

Right?

frigid sequoia
#

Oh, no I was thinking more for debugging purposes

#

If I want to for some reason do soft reboot or something like that

#

But ye

naive pawn
#

i generally have a dedicated Clean method for that

#

-# used to be called Reset until i got some random errors because apparently that's a unity message lmao

fading laurel
teal viper
fading laurel
#

Let me try to save a small video and share it

frigid sequoia
#

I want this to be modificable in inspector but ONLY in inspector, making it a private Set makes not show even with the serialized. Am I missing something?

#

Can I not do that or what?

teal viper
# fading laurel

Hmmm... This shouldn't be happening normally.🤔
Maybe some kind of VS setting.

fading laurel
#

I know and i guess i found the answer

teal viper
eternal needle
frigid sequoia
#

Mmmm? What do you mean? All other values show in inspector just with SerliazeField even if private

teal viper
frigid sequoia
#

So.... adding a getter and setter makes them properties?

teal viper
#

Yep

fading laurel
eternal needle
frigid sequoia
#

I assumed it basically was a shortcut for doing this

#

Not chaging anything on the parameter itself

teal viper
eternal needle
#

im not really sure what the confusion is there. you are using a property

fading laurel
teal viper
teal viper
frigid sequoia
#

I was just a assuming it was a shortcut akind to using "?", not that it changed anything at all on how that value is read or stored

#

But okay, I guess

#

Not like you could serialize a getter or setter anyways???

#

I dunno

teal viper
fading laurel
#

I don't think so, this is the second project that i made and the problem persists, and only happened with unity 6

teal viper
frigid sequoia
#

So... what is the "field" tag exactly pointing at here?

#

That I just take the "field" of the property?

teal viper
teal viper
frigid sequoia
#

Like I don't care about anything on that property to serialize other than the field

teal viper
frigid sequoia
#

I guess that makes sense

#

No idea of what those can be tho

teal viper
#

Can be anything. Some libraries introduce their own attributes. You can create one yourself. It doesn't matter. The point is that you need to be explicit with your code where it is ambiguous.

fading laurel
naive pawn
fading laurel
#

ok

crystal kestrel
#

I AM GETTING CRAZY!!! Casn someone help me with onmousedown? Zero reaction. It is not working -.-

crystal kestrel
# naive pawn can't help without more info, [don't ask to ask](https://dontasktoask.com)

you dont need more info 😄 onmousedown in any script is not working. There is no respond for that. I have made new project. Added square + script to change square to triangle on a click, but onmousedown is not working. I have debug mode ON, and no respond in console nothing. using Old input system - nothing, using new input system- nothing, using BOTH input systems and... yup NOTHING

#

I am stupid or it is bugged or something...

naive pawn
#

i absolutely need more info lmao

#

what's the code you're using

eternal needle
crystal kestrel
naive pawn
#

sure, show a sample of one such instance where it wasn't working

#

and does the object you're trying to click have a collider?

#

i notice you didn't mention that in the extra info you provided

crystal kestrel
# naive pawn and does the object you're trying to click have a collider?

ofc it have. I have even made NEW PROJECT, added a square + code ```using UnityEngine;

public class TestClickScript : MonoBehaviour
{
void Start()
{
Debug.Log("TestClickScript: Skrypt uruchomiony.");
if (GetComponent<Collider2D>() == null)
{
Debug.LogWarning("TestClickScript: Brak Collider2D! Klikanie nie bedzie dzialac.");
}
if (GetComponent<Rigidbody2D>() == null)
{
Debug.LogWarning("TestClickScript: Brak Rigidbody2D! Klikanie moze nie dzialac poprawnie.");
}
}

void OnMouseDown()
{
    Debug.Log("TestClickScript: Obiekt ZOSTAL KLIKNIETY!");
}

void OnMouseOver()
{
    Debug.Log("TestClickScript: Kursor jest NAD obiektem.");
}

}```

#

and guess what. Nothing

#

and in console is only one info: Debug.Log("TestClickScript: Skrypt uruchomiony.");

#

that works

#

nothing else

naive pawn
#

so the OnMouseOver also isn't working?

crystal kestrel
naive pawn
#

can you show the inspector of the object this script is on

crystal kestrel
#

wait. i starting NEW project

#
using UnityEngine;

public class TestClickScript : MonoBehaviour
{
    void OnMouseDown()
    {
        Debug.Log("KLIKNIETO!");
    }

    void OnMouseOver()
    {
        Debug.Log("MYSZ NAD OBIEKTEM");
    }

    void Start()
    {
        Debug.Log("TestClickScript uruchomiony.");
        if (GetComponent<Collider2D>() == null)
        {
            Debug.LogWarning("Brak Collider2D!");
        }
        if (GetComponent<Rigidbody2D>() == null)
        {
            Debug.LogWarning("Brak Rigidbody2D!");
        }
    }
}
#

hold on. It worked. But why this time it works?

#

i was trying it about 2 hours ago an nothing

naive pawn
#

ah yes shrodinger's error, disappears when you try to show it to someone else 🫠

#

were you using a polygon collider before? maybe you didn't set it up correctly?

#

try with a boxcollider

crystal kestrel
#

i was trying with box collider, polygon, triangle, square

#

i was trying with everything

#
using UnityEngine;

public class ClickableSatellite : MonoBehaviour
{
    void OnMouseDown()
    {
        Debug.Log("Kliknięto satelitę!");
    }
}

this code was not working, i even send it to my friend to check, but on his PC was the same. Did not work, and guess qhat now

#

now it works as it should

naive pawn
#

sanity check; was it all saved and recompiled?

crystal kestrel
#

ofc

#

i have even reinstall UNITY

#

installed older version

#

readed reddit forum, facebook groups, github forum, asked google Gemini, ChatGPT, Aria AI

echo ruin
#

Did you remember to press play?

crystal kestrel
#

ofcourse i do xD

#

it took me a lot of hours

#

started with my friend problem with his game

#

he is using more complicated code like this. But guess what. its not working, zero information in console xD

hidden marten
#

!code

eternal falconBOT
echo ruin
crystal kestrel
hidden marten
#
   void Patrolling()
    {
        if (!walkPointSet && !invokedPatrol)
        {
            Invoke(nameof(SearchWalkPoint), 4f);
            invokedPatrol = true;
        }

        if (walkPointSet)
        {
            agent.SetDestination(walkPoint);
        }

        Vector3 distanceToWalkPoint = transform.position - walkPoint;

        if (distanceToWalkPoint.magnitude < 2f)
        {
            anim.SetBool("ReachedWalkPoint", true);
            Debug.Log("reached walkpoint");
            walkPointSet = false;
            invokedPatrol = false;
        }
    }

    void SearchWalkPoint()
    {
        walkPoint = transform.position + new Vector3(Random.Range(walkPointRange, -walkPointRange), transform.position.y, Random.Range(walkPointRange, -walkPointRange));
        Debug.Log("Searching Walkpoint");

        if (Physics.Raycast(walkPoint, -Vector3.up, 4f, whatIsGround))
        {
            walkPointSet = true;
            anim.SetBool("ReachedWalkPoint", false);
            Debug.Log("Walkpoint Set = True");
        }
    }

This patrolling algorithm for my enemy AI doesnt seem to workig properly, can anyone help me out

echo ruin
#

You’re not actually setting your references to your collider components

#

@crystal kestrel

eternal needle
crystal kestrel
naive pawn
echo ruin
#

Okay. I’ve never used OnMouseDown, but I’d give it a try. I’ve had scripts not read because I was trying to fetch a component that didn’t exist

hidden marten
naive pawn
#

@crystal kestrel can you show the inspector of the object that should be clickable?

echo ruin
#

It’s there if you scroll up

naive pawn
echo ruin
#

Huh?

eternal needle
# hidden marten i only get "searching for walkpoint" debug. the ai doesnt seem to reach the walk...

i dont see where these methods are called so it's kind of hard to know the flow here. You should log more useful information like specific variables. Just logged "reached walkpoint" tells you if it enters the if statement, but nothing else
Also are you setting this every single frame? iirc, if you set the destination too often, it won't calculate the path fast enough and thus wont move because it never finishes calculating

eternal needle
#

and a collider on the object ofc

eternal needle
hidden marten
eternal needle
#

id probably also replace that raycast with the navmesh raycast because you really just need to see if its a valid point on the navmesh

hidden marten
eternal needle
hidden marten
eternal needle
#

you would use it to get a point on the navmesh but yes it also returns a bool

#

your current raycast really doesnt do much

#

im pretty sure you could also just skip checking if its a valid point, the agent might just choose the closest valid point to set its destination to

hidden marten
eternal needle
hidden marten
eternal needle
#

excluding links, which you use to connect parts of your navmesh*

hidden marten
eternal needle
# hidden marten okay it somewhat works now.. theres only minor bugs which i think i can. Thanks ...

i can see one possible bug because of the use of Invoke. id imagine it could get called many times as the agent gets close to the destination.
agent gets within 2 units of the destination, walkPointSet and invokedPatrol both get set to false.
Next frame, Invoke(nameof(SearchWalkPoint), 4f); is called. Agent is still near the previous walkPoint, so it's still within 2 units and walkPointSet and invokedPatrol both get set to false again. Repeat

#

Id avoid invoke really in any case, maybe replace this with some timer or coroutine.

neon dome
#

Hi all I game is ready for production but google play requires 12 internal testers, how did y'all manage?

hidden marten
static flint
#
    {
        if (isGrounded())
        {

            if (context.performed)
            {
                // Hold down jump button = full height
                rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpPower);
            }
            else if (context.canceled)
            {
                //Light tap of jump button = half the height
                rb.linearVelocity = new Vector2(rb.linearVelocity.x, rb.linearVelocity.y * 0.5f);
            }
        }```
 I am following a tutorial why isn't the small jump working
night mural
cosmic charm
#

I'm trying to do something like this in my game where a banner with a character appears and show a small animation then it disappears, I'm tyring to do that using timeline, but my game is a 1v1 fighting game so the characters spawn dynamically, but when invoking the timeline it doesn't remember the animators, how can I do that?

#

Source: Vampire's Veil
:)

coarse magnet
#

is there a way to make a gameobject disappear after it plays its animation? i want to make a custom transition but i don't want to rely on a timer to make it disappear

naive pawn
vague canopy
#

I'm trying to make an FPS controller and it is moving weird by the Z-axis

#

Here is simplified vers of the code

naive pawn
# vague canopy

could you elaborate on what exactly the issue is? im not sure im seeing it

#

also see !code for posting large code blocks ⬇️

eternal falconBOT
vague canopy
#

Oh

#

So the problem is that when I only input a and d or w and s while not facing perpendicular or parallel to the z-axis(0,90,180,270)

#

There is a slight drag

#

Like this

#

This is how I wanted it to move

#

distance to the cube moving left

#

distance to cube moving right

naive pawn
#

does the direction value seem right? try debugging that ig?

vague canopy
#

lemme try that

tiny bronze
#

Kinda frustraded with Tile Manager at this point, been struggeling for days with various stupid things and today i am done, does anyone have a good tutorial that actually goes over tile manager instead of just the absolute basics and what am i doing wrong in this case?
:
This is the cut i make in Sprite Editor(image1), then in tile pallette it imports 3 of the chairs even though i only cut 1(image2)
for the orange chair it does look 'good', but looking at the other sprites there all off for some reason

#

These are my sprite settings..

vague canopy
#

I'll try to make it so that you can see the inputs as well

naive pawn
#

@vague canopy maybe it's because of the acceleration acting separately on each axis? what if you use Vector3.MoveTowards instead?

vague canopy
#

lemme try that

naive pawn
#

something like

Vector3 targetVelocity = new(speed * direction.x, velocity.y, speed * direction.y);
velocity = Vector3.MoveTowards(velocity, targetVelocity, acceleration * Time.deltaTime);
```and similar for the deceleration
spiral totem
#

i'm a complete beginner who wants to make a badminton game on Unity
due to physics stepping and collision issues with high-velocity objects, i was wondering: would this not be an easy feat?

naive pawn
spiral totem
#

i don't want to make a game to make a game for others
i kinda just want to play around with swings

#

wait i also forgot to mention: i want it to be playable for VR

#

i just want to jump around tbh

naive pawn
#

i mean none of that really changes the fact that a game is hard in general

spiral totem
#

yea

naive pawn
#

there are a lot of things involved

#

but you can work up to it if you have the motivation to do so

spiral totem
#

i see that yea

#

i've come to the current conclusion that i will start with a racket and a shuttle

#

already ran into issues with collisions between the shuttle and racket when my racket is joined to the vr controller

#

the racket inconsistently passes thru the shuttle (and other basic geometry i've tested)

#

i mean, i don't necessarily want to pick up unity dev just to make a small side-project, though i might do that if i have to

#

i'm mainly a roblox dev but i found that i might be able to make the vr badminton thing thru unity

vague canopy
#

I've been trying to fix this for almost 2 weeks alone...!

vague canopy
#

New problem, now the ground check is flickering

rapid laurel
#

Hii, anyone could help me?? I have added a jump animation to my character and it works fine but when he falls through a hole in my map to another floor he stays in the jump animation permanently

#

the other floor is tagged differently but no matters i change to the same tag it doesnt work

vague canopy
heavy light
#

What are you trying to do? maybe I can help?

#

@vague canopy

vague canopy
#

This is the only code that changes velocity.y

#

And characterController.isGrounded is returing true in one frame and false in the next and true again on the next of it

#

1 false
2 true
3 false
4 true
...

vague canopy
# vague canopy

Here, my bool grounded = characterController.isGrounded; always return true while I was grounded

#
grounded = playerController.isGrounded;
Debug.Log(grounded + "//" + velocity + "//" + transform.position);

these are the first 2 lines in Update()

keen cargo
#

Usually what people do is make an empty gameobject, put it as a child of the player and then add a collider to it

#

Ohh wait i see you're using playercontroller

vague canopy
#

Using the built-in character controller

#

yup

keen cargo
#

Let me see if i have anything about that, I'm not super familiar with it myself

rocky canyon
#

built into unity's cc component

keen cargo
#

It seems like a common issue that people have with charactercontroller

One option is to always have some form of force push your player down even while grounded

The other is making your own ground check

frosty hound
#

That's how you're supposed to use it.

#

The issue people have with the CC is all misusing it, not due to its inaccuracy of detecting the ground. It uses a capsule cast, which if you're not providing a velocity for, will not detect the ground.

#

Beginners confuse this with a rigid body with the assumption there is built in gravity. There isn't.

keen cargo
#

Aha i see, yeah that makes sense

sterile radish
median hatch
#

it'll check every frame

median hatch
dim yew
#

is it possible to reference a texture from a script? ie. with a path like "Assets/Textures/hfsijsrdhjhdr.png"

naive pawn
#

probably is, but why not reference it directly?

#

instead of through a path, essentially a magic string

dim yew
#

through the inspector or

median hatch
#

it'll show in the inspector

dim yew
#

i need it to be consistent between scenes

#

is there an easy way to do that with a direct reference without copying a component

steel smelt
#

could also have singletons that act as registries maintained across your scenes

naive pawn
#

(do you need textures though?)

steel smelt
#

What do you mean?

naive pawn
#

depending on the usecase, it might be easier to, for example, reference a sprite instead

#

you could pause it at that moment with an animation event, i suppose? not sure if it'd work fully
maybe a blend tree could work?
try asking #🏃┃animation

dull bluff
queen adder
#

What’s the best way to learn code ?

rich adder
queen adder
#

Thank you

rich adder
#

mainly the microsoft site

#

you want to learn the lanaguage from the creators first, they have good tutorials then apply knowledge in the unity context

high summit
#

Hey guys, new to coding in c# wondering if there is a better way to write this code?

eternal falconBOT
high summit
#

Oh sure

#
        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D))
        {
            if (!newpauselogic.GameIsPaused & !ringcollect.Inspecting & !medicinecollect.Inspecting & !teddycollect.Inspecting & !cutscenecontroller.PlayerInCutScene) {
                iswalking = true;
            }
        }
#

Seems weird posting the conditions in a row like that but it works obviously, just wondering if there is a cleaner way.

keen dew
#

All those & should be && but other than that long conditional chains can usually be avoided with better architecture (but not always)

high summit
#

They should? the code works exactly how I want it though?

#

(Also I'm not sayiing you're wrong, I'm just wondering what the difference is)

#

A quick google told me & should be fine for this as it's for bool values

rich adder
#

wouldnt it be better to check GetAxis ?

#

you'd only need 2 for floats

naive pawn
high summit
#

so my code is good

naive pawn
keen dew
#

& is for bitwise operations so it's both semantically wrong and slower

high summit
#

I'll swap out for &&'s and quickly check all is good

naive pawn
high summit
#

it's basically my 'footstep' script

#

Obviously, I dont want footsteps if you press W/A/S/D while in a cutscene etc

#

or inspecting an item (aka cant move)

naive pawn
naive pawn
high summit
keen dew
#

Why does every item apparently have a separate inspecting script

high summit
#

there is alot of things that could be done better but that's why I'm here

naive pawn
#

does your actual walking handle being frozen during a cutscene/whatever?

high summit
#

Yeah one sec i'll show you what I did to handle that

#

        private void Update()
        {
            RotationSpeed = sensitivityslider.value;
            if (!newpauselogic.GameIsPaused & !medicinecollect.Inspecting & !ringcollect.Inspecting & !teddycollect.Inspecting & !cutscenecontroller.PlayerInCutScene)
            {
                JumpAndGravity();
                GroundedCheck();
                Move();
            }
        }

        private void LateUpdate()
        {
            if (!newpauselogic.GameIsPaused & !medicinecollect.Inspecting & !ringcollect.Inspecting & !teddycollect.Inspecting & !cutscenecontroller.PlayerInCutScene)
                CameraRotation();
        }
naive pawn
#

if it has a dynamic rigidbody or some velocity value somewhere, you could use that to determine whether or not to play footstep sounds - and then also determine frequency based on how fast you're going

high summit
#

This is the FPS controller script, I added in my new made variables to stop it 'walking' if any of these are true

#

So it wont let you, move, or jump, or rotate etc if paused or doing any inspecting or in a cutscene

naive pawn
high summit
#

Yeah I see what you mean, It doesnt seen a seperate condition when they all mean 'cannot move'

#

I think I know why I had to do it this way, I'll explain one second

#

I have this in each inspection script, But the only way I know how to call for that condition is with the script name .inspecting

#

aka teddycollect/medicinecollect

naive pawn
#
public bool IsFrozen =>
    newpauselogic.GameIsPaused
    || medicinecollect.Inspecting
    || ringcollect.Inspecting
    || teddycollect.Inspecting
    || cutscenecontroller.PlayerInCutScene;

private void Update()
{
    RotationSpeed = sensitivityslider.value;
    if (!IsFrozen)
    {
        JumpAndGravity();
        GroundedCheck();
        Move();
    }
}

private void LateUpdate()
{
    if (!IsFrozen)
        CameraRotation();
}
```something like this, eh?
high summit
#

Oh that's neat

naive pawn
#

but.. yeah that is kind of a tall order

#

requires foresight, and hindsight is not really a good replacement for that 😅

high summit
#

Yeah lol, I know it could be done, But I like your way it's nice for cleaning up the code thanks, I know my code will not be optimal, but i'm already about 75% way through this game and it's my first so I dont want to strip everything down if that makes sense

rich adder
#

this would probably cut a lot of spaghetti if you just used an event, maybe even a static one

high summit
#

Okay so this is my 'teddbear inspect script'

#

you can see where i set the state which I later access with & !teddycollect.Inspecting

#

How would I change that to some form of none script specific state which doesn't need !teddycollect.inspecting

#

Then in my movement script I can just use 'inspecting' or 'frozen'

grand snow
#

I dont know your code but the player object should be what tracks if its "inspecting" anything

#

and the other object can be notified perhaps when inspecting begins/ends

formal sky
#

is there a reason why I cant use the .select() for button
error cs1061, no definition of select()
tried changing to OnSelect() does not work either

The using UnityEngine.UI is greyed out for the LHS script

rich adder
#

UnityEngine.UI is greyed out is sus

formal sky
rich adder
#

or ctrl + click it if wont let u screenshot

formal sky
rich adder
#

ok sorry for not being specific, i mean Button the type

#

hence the capitalized letter

formal sky
rich adder
#

seems its a custom class of yours

formal sky
#

hm ah
teammate created a script named button💀

#

ok tks tks

loud crest
#

i need help im tryna make a gtag fangame and idk how to set it up and ive tried tutorials and they havent worked

rich adder
eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

frosty hound
tranquil steeple
#

Ok

late burrow
#

whats the best way to serialize code?

late burrow
#

i made loading any item into the game through json and i also want make loading item function through json as well

eternal needle
#

if your goal is modding support, let the modders handle it because they already know how to do this.

late burrow
#

i mean isnt it better to have premade support for that

#

especially when i wanna focus game on letting users load in anything they want so it should already have loader working

eternal needle
#

you arent going to make a better system than what they currently already use

late burrow
#

of course because they using their own dlls

#

but its not exactly as accessible as json string

#

like i made entire world loader on that so it takes under 1 minute to share it with someone

eternal needle
#

from every past experience ive learned it really isnt worth trying to convince you to change what you want to do.
carry on and hopefully anyone mods the game in the first place.

dusty oracle
#

can someone explain to what the flip is happening???

rich adder
#

maybe describe the issue with words

dusty oracle
#

the ball goes half way into the floor

rich adder
#

also wat about those blue tiles

glossy crystal
#

How should I handle a tile that can turn its' collision on/off during runtime? Divided between: Swapping the layer of the tile from a collision to noncollision layer, or swapping it out for a duplicate tile that doesnt have a collider. Another question would be like, is it bad practice to have tiles with and without colliders on the same tilemap layer?

grand snow
#

If its a door for example, it can just not be in the tilemap but be a sprite renderer so its more easily changed?

#

I presume render order + layers should make this behave

brave robin
solid raven
#

OYE, im new to unity and not much of a programmer but i need help with a task for a fan game that im leading

#

we built a prototype level and want to test it on Sonic Journey, an open source unity game

#

but since my team doesn't have a unity dev, i thought it wouldnt hurt if i could try this myself

eternal needle
eternal falconBOT
#

: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

solid raven
#

Thanks

queen adder
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

frigid sequoia
#

This is a bit of dumb question but if I replace a component by some other that is basically inhereting from the same superclass can I not keep the references or at least copy all the values on the new class?

#

Like let's say I want to replace a general behaviour superclass that all enemies have for a subclass of that one that is specific for that enemy; is there not an easy way to not lose all references, values and stuff when doing so?

teal viper
frigid sequoia
#

I tried that but only allows me to copy the whole component anew

teal viper
#

Then probably no way by default, aside from manually copying all the values. You could write a small utility tool that would do that for you though.

frigid sequoia
#

Yeah, I am also losing a bit of references

#

Just a little annoying that's all

#

Not much issue

naive pawn
fleet solstice
#

Can you not subscribe public static Action events one to another to have them trigger in a chain? The compiler is giving me no errors, but the second event does not get called even after subscribing Event1 += Event2. If I subscribe a method and call Event2 with it, it works fine.

Actually the error I'm getting is that when Event1 is called at runtime - it considers Event2 not to even be subscribed 🤔

sour fulcrum
#

show code

fleet solstice
#
    public static event Action<int, float> BattlegroundHitEvent; //Event1 in Class 1
    public static event Action<int, float> TileDamagedEvent; 
//Event 2 in Class2

        Class1.BattlegroundHitEvent += TileDamagedEvent;
        Class1.BattlegroundHitEvent += Test1;
        TileDamagedEvent += Test2;

    void Test1(int id, float dmg) {
        Debug.Log("test 1");
    }
    
    void Test2(int id, float dmg) {
        Debug.Log("test 2");
    }

This debugs only "1", basically Test 1 fires and 2 doesn't.

eternal needle
#

or you subscribe a method that invokes TileDamagedEvent

#

Class1.BattlegroundHitEvent += () => TileDamagedEvent?.Invoke();

fleet solstice
#

Thanks bunches @eternal needle

eternal needle
#

though actually if those are in different classes, you cant invoke it like that so nvm

fleet solstice
#

Yeah I get it, thanks. Would not have figured this one out probably - could not have imagined subscribing kind of like passes a list of present listeners 🤯. Well, might not be that surprising after learning it. Just the first time I tried subbing an event to an event after doing just methods for ages 😅

fair shore
#
    void Awake()
    {
     Piecesinventoryscript   piecesinventory = FindObjectOfType<Piecesinventoryscript>();
        piececlones = piecesinventory.piececlones;
        inventories = piecesinventory.inventories;
        slots = piecesinventory.slots;
        tiles = FindObjectOfType<Tilespawnner>();
        GameObject[,] tilearray = tiles.spawnners;
        Dictionary<GameObject, List<int>> maindict = piecesinventory.piecedictionary;

    }
  public void OnBeginDrag(PointerEventData eventData)
  {
      List<List<int>> keys = maindict.Values.ToList();
      Debug.Log("Begin Drag");
      for (int i = 0; i < inventories.Length; i++)
      {
          inventories[i].transform.SetParent(null);
          for (int j = 0; j < tilearray.GetLength(1); j++) // Corrected loop to iterate over the first dimension of the 2D array
          {
              
              if (tileValue < keys[j][2])
              {
                  tilearray[j, 1].tag = "Opened";
              }
          }
      }
  }```
I want if statement to be the second value of the arrays inside 2d array(tilearray) smaller than dictionary(maindict) value list index number 2, how do i write that in code?
naive pawn
#

by "smaller", you mean its length, or..?

#

oh wait you're iterating over tileArray, gotcha

#

well translate each part out

#

wait you're comparing stuff between a 2d array and a "2d" dictionary? that's not gonna be very reliable

#

you should probably reconsider your structures

quick pollen
#

Can you use scriptableobjects for saving data over sessions?

#

as an example, if I have an int in a scriptableobjects which saves the amount of levels I've beaten, does it get kept when I exit and press play again?

sour fulcrum
#

no

quick pollen
#

so it only works in the editor?

sour fulcrum
#

correct

quick pollen
#

that kinda sucks

sour fulcrum
#

just how things work

#

you'll likely need to use Json in some form to handle your saving

quick pollen
#

im trying, but im having trouble following a guide

#

because I also need scriptableobjects to keep data over scenes

sour fulcrum
#

Might have to elaborate

quick pollen
#

I basically want to have a saving system for levels beaten

#

I have 6 levels

#

each time you beat a level you havent beaten before, you increase that number by 1

#

that way, you can use the level selector in the main menu to go back to it once you beat it

sour fulcrum
#

yup, not really something scriptableobjects are for though

#

values in scriptableobjects are generally not meant to change during runtime

#

sounds more like you want some form of Manager that exists as a DontDestroyOnLoad object?

grand snow
#

Scriptable objects keeping changes between plays is a fluke and tbh a stupid issue that unity should fix

quick pollen
#

but also

#

I managed to save the data to json once

#

but for some reason i cant anymore

#

like once it creates the file it just doesnt let me modify it? or that the savedata object just is null?

#
    public void LoadData(SaveData saveData)
    {
        save = saveData;
        nr = save.levelsUnlocked;
    }
    public void SaveData(ref SaveData saveData)
    {
        save.levelsUnlocked = nr;
        saveData = save;
    }```
#
    SaveData save;
    int nr;
#

but for some reason save is null then SaveData is called

#

even tho LoadData is called before it

grand snow
#

is SaveData a class or struct? ref is only needed for a struct

#

and sharing your IO will help

hearty hamlet
#

does anyone know why i can only jump sometimes

#

just randomy i can sometimes jump sometimes not

#

nvm figured it out :)

zinc agate
#

can anyone help me? All my prefabs work in my first scene but when i mvoed them to the next scene they are being destroyed but showing these errors in the console

#

The finish point is showing an error because I dont have next level set up yet but I dont understand why the cat is having an issue when it works fine in the first scene

keen dew
#

You'll have to show the code

zinc agate
#

nvm i fixed it xD

#

i forgot to add the game manager in my level

worldly iris
#

hey guys 👋
im currently trying out the charcter controller. but as it turns out, i have no clue of what im doing.
i just want to use the isGrounded bool, that comes with the CC.
what components does my colliding object need to count as ground? i though rb2d and boxcollider2d would be enough, but somehow this doesnt seem to work (or i set the um wrong).
does the object need some sort of "Ground" tag? does the CC only work in a 3d enviroment?

slender nymph
#

the character controller is a 3d collider, it will not collide with 2d colliders

worldly iris
#

damn, thats what i thaught, tyvm

#

and there is no 2d counterpart?

rich adder
naive pawn
void kestrel
#

hello

#

please can someone teach me the basics of unity]

slender nymph
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

void kestrel
#

i know how to use visual studio

#

but im new to unity

#

im very pro in cooding

#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

void kestrel
#

ty man

slender nymph
#

you're meant to read the bot message, not just blindly parrot the command

sterile radish
void kestrel
#

im off to learn

#

thx @slender nymph

sterile radish
void kestrel
#

ty

naive pawn
#

your description isn't very precise

sterile radish
static flint
#

Please help me I am making a 2D platformer```public void Jump(InputAction.CallbackContext context)
{
if (isGrounded())
{

        if (context.performed)
        {
            // Hold down jump button = full height
            rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpPower);
        }
        else if (context.canceled)
        {
            //Light tap of jump button = half the height
            rb.linearVelocity = new Vector2(rb.linearVelocity.x, rb.linearVelocity.y * 0.5f);
        }
    }```

and I am following a tutorial why isn't the small jump working

slender nymph
#

run through your logic real quick and see if you can spot the issue yourself

cedar prairie
#

Any clue why debug.drawray is doing it like repeating itself

#

But only visually

#

Sorry dont have discord on my laptop

naive pawn
cedar prairie
#

Okay but any clue what the issue is

polar acorn
#

Not without !code

eternal falconBOT
cedar prairie
#

Its repeating the draw ray for some reason insted of clearing it

#

Its literally the debug.drawray command in the update function

naive pawn
#

and how long is the delay you specified, if any?

polar acorn
#

So show the code

cedar prairie
#

Its literally just a visual thing idk why

polar acorn
#

Show code

cedar prairie
#

Never mind i didn't realize it needed a decay

static flint
slender nymph
#

you don't need to be super experienced to understand the flow of your logic. you just need to have common sense

static flint
#

My common sense tells me that I have used unity for 2 hours total and I am following a tutorial that isn't on unity 6

#

FREE Code script on my Patreon!!
In this episode we'll be getting our player jumping, double jumping and jumping with a variable height using Unity's 'new' Input System! We'll also look into adding cool feeling to our game with gravity modifiers - making us fall faster or slower!

We'll be working with the Input System throughout this platfo...

▶ Play video
polar acorn
slender nymph
static flint
#

and how do I do that

slender nymph
#

start with the pathways on the unity !learn site

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

static flint
#

thx then

slender nymph
#

they teach you the fundamentals of the engine in a structured way

polar acorn
static flint
#

Ok?

polar acorn
#

The problem you described gets fixed in the tutorial later on

static flint
#

Ohh

sterile radish
wintry quarry
sterile radish
zinc agate
#

im having an issue with setting up my main menu. The exit button works fine but the start button is not working at all

naive pawn
#

try adding a debug log to see if it's being called

slender nymph
#

also get your !IDE configured

eternal falconBOT
naive pawn
#

then check where it shouldve been called from

zinc agate
#

whats an ide

slender nymph
#

the world may never know

rich adder
zinc agate
#

my lecturer never explained this so

#

and i never heard it in any tutorials

rich adder
#

well time to use your own noggin to help yourself

zinc agate
#

no need to be rude

sour adder
# sterile radish okay, here it is https://scriptbin.xyz/suvabeziku.cs

Not at all sure, but you can try checking these.

Is it because of the obstacles? (some collision that disturbs the path). Seems like it's jumping to like max height right the way.

Do you use mass and drag on the RigidBody2D? Should not affect it as it is the same, but may affect final velocity after the dash.

You never set velocity when the dash is done...

sour adder
#

Or some other script that takes movement is interfering maybe.

strong shoal
#

can someone tell me why

#

it isnt working

wintry quarry
acoustic belfry
#

Hey, whats the most popular or better way to make a timer, a.k.a. make the code wait for a while

cuz what i normally do is make a float value, on the update function subtract that float value with Time.Deltatime, and make an if scenario for when that value is zero

But is there a better way to do so?

wintry quarry
acoustic belfry
wintry quarry
#

I mean, just look up how to use a coroutine, that's exactly what they're for

#

You can write code that has delays in it in a coroutine

acoustic belfry
#

interesting, thanks :3

grand snow
polar acorn
# strong shoal

Because an if statement expects a Boolean and you've given it an array of colliders

strong shoal
#

THX

slender cypress
#

what's an easy way to do a loop that goes and:
for(gameobject elem where elem==null in list)?

grand snow
#

er well very simple

#
foreach(var elem in list)
{
  if(elem == null)
  {

  }
}

You could use .Where() from linq but it can create lots of garbage so avoid if possible

sterile radish
grand snow
slender cypress
#

yeee I should get back on basics! But it was mostly a problem cause I tried changing the list i was doing a foreach with! so this was the problem lul

grand snow
sour adder
# sterile radish here is my move script https://scriptbin.xyz/qifenukegu.cs

I tested your Dash script in a test program.

It is working (while in air and on floor) with the following changes for me:

//In Update()
if (!IsDashing)
{ //do movement and jump, my replacement for your other scripts, sets lastDirection
}
//never set rb.velocity elsewhere while IsDashing

//in DashAction
rb.velocity += lastDirection.normalized * dashSpeed;

Another script might be the reason is my guess.

sterile radish
tiny bloom
#

Each time I create a new script in my unity project through visual studio, all opened c# files get closed
any idea how to fix this?

sterile radish
sour adder
#

Well, it was just to not have input in the coroutine.

Also a coroutine runs at the rate of Update() not FixedUpdate(). Not sure how that affects you.

Not everyone agrees but I would skip the coroutine and Dash script and do all reaction to input in Player.FixedUpdate() (velocity set once in the entire game)

solemn sable
#
if(startingSide == 0)
            {
                float randPos = Random.Range(-0.8f, 0.8f);
                startingPos.transform.position = new Vector3(randPos, -0.44f, 0.581f);
                endingPos.transform.position = new Vector3(-randPos, 0.44f, 0.581f);
            }```

i have this little block of code... the problem is that despite having 0.581f as the z value, it get's set to 10.581f
#

also -randPos is not giving what it's supposed to

wintry quarry
solemn sable
#

oh i'll try that

#

yep that works

#

thanks

jaunty trellis
#

Having problems with snappy-movement and was sent here, the "movement" code is inside of the "Replicate" method

winter wedge
#

Maybe use tweening for movement

#

It's smoother and just better

jaunty trellis
#

whats that?

winter wedge
#

It's hard to explain

#

But it makes shit smooth

#

It will update every frame, it's kinda like setting it's destination when the key stops instead of every second the key is held down

#

And updates every frame

iron otter
winter wedge
#

Well

#

Search up tweening

#

And watch stuff on jt

jaunty trellis
#

the function is called every tick. But will do

polar acorn
jaunty trellis
iron otter
winter wedge
brave robin
polar acorn
iron otter
#

then why it would allocate memory for it if the instance of the class is never made

polar acorn
willow iron
#

currently doing the tanks tutorial from unity
from the video in the tutorial it is clear that the tanks are meant to stop sliding after a while.
instead, mine continue sliding forever
no code has been modified
any advice?

slender nymph
willow iron
zenith cypress
#

That is some wild video corruption LUL (huh only seems to happen if you drag the time forward, weird)

steel smelt
#

drag's a setting on the actual rb component. friction is determined by the physics material of both colliding objects

willow iron
#

figured it out, turns out the collider was not supposed to be floating off of the floor

#

Important: Ensure that the Box Collider component slightly overlaps with the ground; otherwise, any force applied to the tank after a collision will persist indefinitely, as if in zero gravity.
missed this bit...

steel smelt
#

not sure what the tutorial setup is but that sounds janky as hell

#

if it works and it helps onboarding I guess

slender nymph
rich adder
#

how are we supposed to know if you haven't posted any code

#

most likely mismatch between physics frames and camera rotation

#

probably putting HandleCamera to LateUpdate

#

also rotating the entire player with physics instead of transform

zealous river
#

try changing interpolate to none

sterile radish
#

hi, im currently making a platformer like celeste but smaller in scope. i was wondwering how i would go on about managing the rooms. should i have a scene for each room or one big scene containing all the rooms in it? how would i generally go on about room management in a game like this?

zealous river
#

You could also create a script where you store an array of Cinemachine cameras, so it’s easier to assign which room to go to when colliding with a “door.”

deep moss
#

How do I code like snapping objects using empty child? Like robot arm has an empty child place next to a body and snaps when close. Something like transfom and distance or something

obsidian gazelle
#

Does anyone know of a good visual scripting add on?

#

Preferably a free one that isn’t deprecated?

eternal needle
obsidian gazelle
undone thicket
#

Hi, could someone help me figure out how to make transparent windows in 2D Unity(version 6000.1.2f1)? I'm searching through the forums, but nothing has worked for me

rich adder
#

also not a code question it seems

glossy crystal
#

If I have like <10 maps that are each 1000-2000 tiles each, but can be travelled between fairly easily (the player character reaches can reach an exit and teleport to the next one), these should all be in the same scene right? Should I have separate cinemachine cameras for each or can I just have the camera follow along?

undone thicket
jaunty trellis
rich adder
wintry quarry
jaunty trellis
#

What do you need to see? here's the input.x and input.y for "Move" (Unity input systems) + the ticktime (time between update)

wintry quarry
jaunty trellis
#

this method gets called once per tick

wintry quarry
# jaunty trellis

you're multiplying mouse input by Time.deltaTima (I think, it's a bit abstracted)

#

you should never rotate mouse deltas by deltaTime

jaunty trellis
#

I see

wintry quarry
#

they are intrinsically already framerate independent

jaunty trellis
#

I rotate yaw with transform.Rotate and pitch with Quats, is that an issue?

wintry quarry
#

There's also a lot of context here that's hard to parse. There seems to be some networking stuff involved here too

jaunty trellis
#

yes, there is

rich adder
jaunty trellis
#

This is essentially a FixedUpdate (tickDelta removed, ty)

#

runing consistently at 0.0083 i think

wintry quarry
#

ok well rotating in FixedUpdate is also a problem

#

That is certain to cause jittering

#

since your rendering framerate is not fixed

jaunty trellis
#

LateUpdate then?

wintry quarry
#

Update or LateUpdate is the place to rotate yor character according to mouse input, yeah

jaunty trellis
#

in what Update should I record the mouse input?

#

so assign new value

wintry quarry
#

Update

jaunty trellis
#

regular update?

wintry quarry
#

but it only works properly if you're accumulating it

#

basically it all depends where/when you're accumulating it and where you're consuming it

jaunty trellis
#

the input?

wintry quarry
#

It's possible to apply the motion in FixedUpdate but only if there's some kind of interpolation that happens (e.g. if you used a Rigidbody.MoveRotation with interpolation on)

#

but if you do that you need to accumulate mouse input in update and consume it in fixed

jaunty trellis
#

never thought about inputs as accumulating / consuming (using CC rn)

wintry quarry
#

If you're not using it right away, you need to accumulate it

#

because Unity gets mouse input once per frame

jaunty trellis
#

and then reset it?

wintry quarry
#

if you overwrite instead of accumulating you will miss entire frames

wintry quarry
jaunty trellis
#

I see

wintry quarry
#

but that's only relevant if you're using FixedUpdate to consume AND there's a layer of interpolation happening

#

otherwise you should just directly read it and use it in Update or LateUpdate

jaunty trellis
#

So fixes: remove tickDelta, update input in Update, rotate in LateUpdate

wintry quarry
#

there's no need to split between Update/LateUpdate

#

if you want to rotate in Late, just read it in Late too

jaunty trellis
#

Guessing all my inputs should be recorded in Update?

wintry quarry
#

it kinda depends what you mean by "record". It seems like maybe you're doing a networked game with the Command pattern for input?

#

Where you send your inputs to the server and do a local prediction?

jaunty trellis
#

yes

wintry quarry
#

Ok so - you have to be careful because if you record button presses in Update, and then you're not actually processing them each frame, you can miss inputs

#

so you need to do stuff like buttonWasPressed |= buttonWasPressedThisFrame;

#

and then consume it when you send it to the server

#

or - use event-based handling and queue up any button presses for the next input packet

jaunty trellis
#

Can I record in Update, accumulate the input (also in input, then when I use it in my method called by the "TickEvent" (once per tick), eat (consume) it?

wintry quarry
#

basically - the behavior is different for input you poll continuously vs one-off things like button presses

wintry quarry
#

The |= essentially "accumulates" for button presses

jaunty trellis
#

the ? what

wintry quarry
#

it's || + =

jaunty trellis
#

I've never seen that before, in my 1 week of unity

wintry quarry
#
bool a = false;
a = a || b; // same as next line 
a |= b;```
#

those last two lines are the same

#

it's a C# thing