#💻┃code-beginner

1 messages · Page 402 of 1

rich adder
#

InventoryManager knows nothing about the two, UI slot only knows about UISlotsManager and registers itself with an event UISlotsManager listens to (mouseclicks, onDrop, the usual stuff)

#

UISlotsManager also gets info from events on InventoryManager

wooden socket
#

well im back

#

I followed what you guys said earlier and did some more looking into C#, and im slightly confused on a specific aspect

#

I want to pass a function from one script to another, and I even looked at my other UI script and im still a small bit stuck

#

in my screenShake code, its all the logic needed for the screen to shake, I just want to call the shake screen function when the bird object collides with this object

#

is there anything im doing wrong here?

tawny thicket
#

how do i switch a model

dense plume
#

Looks fine on this end, what is the shake camera function on the other side?

wooden socket
#

okay lemme send that

dense plume
wooden socket
#

idk why u think I didnt try that lol

#

!code

eternal falconBOT
rich adder
wooden socket
#

here ya go

polar acorn
wooden socket
#

i said that

#

is there anything im doing wrong

tawny thicket
dense plume
wooden socket
wintry quarry
wooden socket
rich adder
dense plume
polar acorn
#

Is it working

#

if not, then probably

#

if yes, then no

wooden socket
#

when i tried it, the screen didnt shake

rich adder
#

we need a flow chart for this channel , of "have you tried debugging it first"

quartz nimbus
#

why isnt unity accessing my UI I have the using UnityEnging.UI; on but its not accessing my object resolutionDropdown

wooden socket
#

to be fair, I could make a new script for the shake

polar acorn
wooden socket
#

wait it would be easier if its jusyt one mb

quartz nimbus
#

wdym didnt create it

rich adder
#

what is reslutionDropdwon ?

stuck palm
#

@swift crag i dont think im doing this hash thing correctly. I'm getting replays that work, but the hashes are apparently mismatched.
https://gdl.space/iyidasejad.cs

rocky canyon
#

you dont have anything in ur script that defines what resolutionDropdown is

hexed terrace
tawny thicket
rocky canyon
#

Quadrakill QuintupleKill!

hexed terrace
#

if you hover over the red error, it will tell you it doesn't exist

gotta learn how to use VS and read the info it gives you

polar acorn
swift crag
#

so, walk through both game states and log anything that mismatches

quartz nimbus
rich adder
polar acorn
stuck palm
swift crag
#

You want to find out what isn't matching

rich adder
#

you missed a step

dense plume
#

Declare this resolutionDropdown at the top as a Dropdown type object

quartz nimbus
tawny thicket
rich adder
#

follow the tutorial but better

stuck palm
polar acorn
tawny thicket
#

oh ok

#

cool

swift crag
polar acorn
#

like, you could have just done that in the time it took to ask that question

rich adder
#

trial and error a dying breed or what..

wooden socket
swift crag
stuck palm
polar acorn
dense plume
wooden socket
#

heres my virtual camera object

#

I assume I should put the script on the object that actually is being collided with right?

polar acorn
#

see what it has to say

wooden socket
#

oh shoot

polar acorn
wooden socket
#

well now the object shakes! but not when its being colldies with

#

just on its own

polar acorn
#

you probably need to start the AmplitudeGain at 0

wooden socket
#

okay i changed it

polar acorn
#

There should be a field in the inspector for it

wooden socket
#

lets see

#

okay so I made it 0, and when the objecy is collided with I get this error

polar acorn
wooden socket
wintry quarry
#

Doesn't seem like you assigned ShakeCamera

#

assuming it's the lightbulb line

wooden socket
#

i do that in the inspector right?

wintry quarry
#

yes

wintry quarry
#

which is a prefab

#

so you can't

#

You would have to assign the reference at runtime (when spawning the pipe)
Or use the singleton pattern again like you did for the ScoreManager

wooden socket
#

well, it did work

#

the pipes shake lol

wintry quarry
#

then presumably your pipe is not a prefab

#

it's in the scene

wooden socket
#

mhm

#

now, im going to try and add sfx to when it collides. Im going to try and do it all on my own, and if there is a problem I will report back

#

thank you for the help so far. ur making a mans dream come true <3

polar acorn
wooden socket
#

true!

#

lol

wooden socket
#

okay im back BUT it should be easy and not a code thing

#

I added code so it plays a sound when it collides with the pipe, but it isnt playing the noise

#

the audio listener on the camera is on, the clip is even inside of the inspector slot

#

nvm it works, i had to add something small

#

lol

queen adder
#

Does anyone know what the issue may be here? Im trying to make it so if Box Collider Collides with another there should be a message in console 🤔

#

but for some reason cant get it working Kirka_shrug

eternal falconBOT
polar acorn
eternal falconBOT
rich adder
#

did you click the link

hexed terrace
#

!vs

eternal falconBOT
#
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

hexed terrace
#

The steps are clear ☝️

swift crag
#

Follow all of the steps. Do not skip any of the steps.

queen adder
polar acorn
queen adder
#

uhh nvm I think I got it blehhcat

stuck palm
#

@swift crag after serialising both the recorded state and current state, i can see some non-negligible discrepancies. could that possibly be because of script order execution or?

swift crag
stuck palm
#

everything related to characters and projectiles i hope you mean lol

swift crag
#

You could do this by setting script execution orders for everything, or you could explicitly run update methods on everything

stuck palm
#

cus i've got like 200 scripts 😭

swift crag
#

and, in fact -- if you want to be able to do rollback eventually, you'll want to do the latter

#

Although, actually, if everything is using FixedUpdate, you'd be calling Physics.Simulate() manually anyway

#

so FixedUpdate would be getting called

stuck palm
#

honestly for now, i'll just do script execution order stuff

stuck palm
swift crag
#

That stuff doesn't matter, no

#

although, you do probably want to update the UI after the game state is updated!

#

otherwise it'll be a FixedUpdate behind

stuck palm
#

that is true

#

okay, thanks for the insight

swift crag
#

(But you probably want to update the UI in Update anyway)

swift crag
stuck palm
#

i'll do character simulation first, then projectile simulation, then whatever else i need to check what is important here

#

i guess i'd need to update the kinematic character controller after the character

#

because the character decides the velocity basically

queen adder
# eternal falcon

this aint working, Any Ideas? also the "Unity API Reference" doesn't show up under help 🤔

swift crag
#

Show your External Tools settings, as well as the Package Manager window.

swift crag
#

I thought you followed the instructions you were linked to.

swift crag
polar acorn
# queen adder yuh

So what did you open for the step that had you change the external tools settings

swift crag
#

The instructions very clearly instruct you to go to both of these places

summer stump
queen adder
swift crag
queen adder
swift crag
#

Okay, both look fine.

#

Close Visual Studio, click "Regenerate project files" in the External Tools window, and then double-click a script asset to re-open Visual Studio

languid spire
#

best to delete the .sln and .csproj files in the project

swift crag
#

yes -- those are the files that Unity generates

#

they shouldn't need to be deleted, but, you know,

#

I've seen it be a problem before.

languid spire
#

well the .sln is not always regenerated when switching from VS Code to VS

#

or vice versa

rocky canyon
#

i rename and move projects around a lot.. i always delete my .csproj inbetween

oak tapir
#

i need some help i put a code in unity or whatever and i tested it and i can walk but when i do when i stop pressing the w key to go forward it keeps going forward for like 1 second

queen adder
#

but im back in visual studio and I dont think we working still blehhcat

polar acorn
queen adder
#

umm, I dont think so??? 😭

swift crag
#

Do this, then regenerate the project files again #💻┃code-beginner message

If the issue persists after that, screenshot your entire Visual Studio window.

queen adder
swift crag
#

That isn't your entire window.

#

When you don't know what you're looking for, you should err on the side of providing too much information

queen adder
swift crag
#

ah, I see

queen adder
languid spire
#

yep and the .csproj

swift crag
#

Yes, along withg the "Assembly-CSharp" project file.

queen adder
polar acorn
#

Ignore

languid spire
#

Ignore

polar acorn
#

You already know there's compile errors

queen adder
#

aight this is my visual studio now 🤔

languid spire
#

Still not configured

short hazel
#

Select View > Solution Explorer and take a screenshot again

swift crag
#

you're looking for the "Miscellaneous Files" indicator here: that means Visual Studio doesn't think this file is part of a project

#

and yes, that's the next place to look

short hazel
#

Right-click the Assembly-CSharp project and select Reload With Dependencies

queen adder
#

Oh shit

#

wait I think we are working

#

theres color

polar acorn
#

Yes, there you go

#

At least... somewhat? The error still isn't underlined

#

But it's highlighting Unity stuff at least

queen adder
polar acorn
#

Now, onto the second point:
You got a function in your function

queen adder
polar acorn
summer stump
#

OnTriggerEnter COULD be in Update if you remove the word private. But Unity will not call it from there

So remove it from Update

polar acorn
#

unless you are absolutely certain you should be doing that, it's usually a mistake

queen adder
summer stump
#

I guarantee you that

polar acorn
queen adder
#

uhh this is what they did thonker

#

and it seems to work blehhcat

#

I guess

summer stump
polar acorn
swift crag
#

Can you quit spamming the emojis before I have an aneurysm

summer stump
#

The issue is that you put it INSIDE of Update

queen adder
summer stump
#

See how it is very different

swift crag
#

notice how this is not inside of an Update method

swift crag
#

I can't wait for summer break to be over.

polar acorn
# queen adder
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 168
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-06-27
queen adder
#

Mine -

polar acorn
queen adder
#

am I just stupid??? 😭

summer stump
#

Again, you are looking at the wrong part

polar acorn
#

And they did not

summer stump
#

It is INSIDE OF UPDATE

queen adder
#

OH

#

I SEE

#

😭

summer stump
queen adder
polar acorn
summer stump
polar acorn
summer stump
#

Nice

polar acorn
#

but I have added emotes solely to use in this server

summer stump
#

I knew it

queen adder
#

Never been so happy to see some gray text SCpray

#

thanks chat ❤️

polar acorn
oak tapir
#

how do i make the green thing aline with the plane? cause when i press play and i walk on it i cant walk on the plane i just walk on the green thing

swift crag
oak tapir
#

wdym like the whole thing?

rocky canyon
#

dont scale ur root objects

swift crag
#

No. I want to see the scale of the "Scene" object.

#

It's the object named Scene.

#

Show me its inspector.

rocky canyon
#

its probably whacky.. you heard it first here 📺

oak tapir
#

k hold up lemme screen shot

rocky canyon
#

booya

swift crag
#

There's the problem.

oak tapir
#

what i do?

swift crag
#

You have a non-uniform scale on a parent object.

#

When you do this, it causes skewing of child objects that are rotated.

rocky canyon
#

dont scale ur root objects...

#

scale children objects..

swift crag
#

As the child rotates, it lines up with the X/Y/Z axes of its parent differently

#

causing it to distort as it rotates

rocky canyon
swift crag
#

The Box Collider component cannot deal with this properly.

rocky canyon
#

if ur parent is 1:1:1 rotations and sizes will be fine for the children

swift crag
#

it winds up separating from the visible cube (which does skew "properly")

rocky canyon
#

if u scale the parent to something weird the children grow up to be something weird

oak tapir
#

so hoe do i fix?

#

how

swift crag
#

make its scale uniform

#

e.g. [3,3,3]

rocky canyon
#

don't scale the root object ... if u need that collider thats on it to be scaled weird

earnest shore
#

I'm trying to use courtines to make the player only able to jump once every 10 seconds. Anyone know why this isn't working ?

    {
        StartCoroutine(JumpCooldown());
    }

    IEnumerator JumpCooldown() {
        // if jumped, wait for a second 
        if (Input.GetKey(KeyCode.Space) )
        {
            ball.AddForce(jumpForce * Vector3.up);
            yield return new WaitForSeconds(10);
        }
        // otherwise wait for a frame
        yield return null;
    }

rocky canyon
#

make it a child and scale that instead

swift crag
oak tapir
#

how do i make it a child?

swift crag
rocky canyon
#

u already have children.. u should know how..

swift crag
#

If you don't know what any of these words mean, you need to stop what you are doing right now and go use !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rocky canyon
#
  • parent
  • child
    • grandchild
earnest shore
swift crag
swift crag
#

Consider a coroutine that just resets a field back to true

#
bool canJump = true;

IEnumerator JumpDelay() {
  canJump = false;
  yield return new WaitForSeconds(3f);
  canJump = true;
}
earnest shore
#

i see

#

thanks!

swift crag
#

If you run this with StartCoroutine(JumpDelay()), it'll instantly set canJump to false, wait 3 seconds, then set it back to true.

earnest shore
#

yep

gloomy nebula
#

issue building? compiler is closed

swift crag
#

I don't know how you would "close" the compiler

#

are you talking about the console? your code editor?

gloomy nebula
#

yes thats what i meant sorry

swift crag
#

That doesn't do anything.

#

Look in the bottom right corner of your editor. There will probably be a blue bar with some text on it

#

e.g. "Compiling scripts"

gloomy nebula
#

lol, im just really tired sorry, brain isnt working and i just want to build this

swift crag
#

that means Unity is busy doing something

gloomy nebula
#

ive restarted unity

swift crag
#

well, you just interrupted it!

#

screenshot the entire editor window

gloomy nebula
swift crag
#

looks fine now

gloomy nebula
#

i press build, same error and this pops up for half a second

swift crag
#

Ah, then you're getting a compile error

#

Show the console.

gloomy nebula
swift crag
#

Always look at the first error

#

The other errors will just be "the build failed"

#

your code has a using directive for something in UnityEditor

#

None of that stuff exists in the built game

rocky canyon
#

red ❗ are a no-go

swift crag
#

It was probably added by mistake.

#

Try removing the using UnityEditor... line from the script.

gloomy nebula
#

vsc would usually tell me theres errors in the console with a big red notification, didnt realise i had errors since i didnt check, thats on me!

rocky canyon
#

yup, no worries

swift crag
#

It's totally fine when working in the editor

#

It's (very very roughly) because of some code like this

#
#if UNITY_EDITOR
public class Oops { }
#endif
#

#if is used to conditionally include parts of a script

gloomy nebula
#

i havent got the using UnityEditor line

swift crag
#

this only includes the Oops class if UNITY_EDITOR is defined

swift crag
gloomy nebula
#

im so blind.

#

apologies haha

elder raptor
#

I don't understand why but my character randomly starts rotating around 360 degrees when I stop moving. Any idea why? Must be a simple issue but I've been coding for almost 20 hours now and I have burnt every brain cell 😔

https://hastebin.com/share/juticosaxu.csharp

swift crag
#

no prob (:

gloomy nebula
#

worked just fine, thank you so much

remote osprey
#

How can imake something like this work in unity?

List<GameEvent> events = data.BeginTurnCardEffects.Select(x =>
{
    ITarget target = null;
    if (x.needTarget) { target = GetTarget(); }
    return x.CreateEvent(data, target);
});
elder raptor
gloomy nebula
#

why doesnt my icon change?

verbal dome
languid spire
#

Because that icon if used for the built game not the project

gloomy nebula
#

i deleted the old build and then built it again yes

elder raptor
#

Sometimes windows Caches the old Icon for some reason, happened to me once and a restart showed the new icon for me.

languid spire
gloomy nebula
gloomy nebula
swift crag
stuck palm
#

does changing base class script execution order change inherited clases script execution order?

wintry quarry
#

No idea but it would be good to know.

#

My guess is probably not.

slender nymph
swift crag
#

this reminds of a tangential thing: it'd be nice if there was a way to completely scramble all of your unity objects so that things with the same execution time now run in a different order

#

to help catch really weird execution order issues

stuck palm
#

are these just orders or like ticks or something

eternal needle
wintry quarry
swift crag
#

Imagine someone randomly shuffling until the errors stop

#

Bogosort!

stuck palm
#

the discrepancy is getting shorter now

#

but its still there

#

not sure if this order is optimal

eternal needle
remote osprey
#

What's the best way to enqueue events?

#

I feel like i'm reinventing the wheel a bit with my event classes

eternal needle
remote osprey
#

Yes, but i'm implementing my own event classes

#

and it's been difficult

#

I'm watching a UnityEvent tutorial on youtube but i don't know if it has applications outside the inspector

eternal needle
#

Then share the difficulties. Queueing up events alone doesnt seem to be the problem

#

Unity events are pretty much just for inspector

olive osprey
#

Hello, can anyone help me resolve this error?

It happened right after I installed the package for In App Purchasing

System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
at Mono.Cecil.PE.ImageReader.ReadImage()
at Mono.Cecil.PE.ImageReader.ReadImage(Disposable1 stream, String file_name) at Mono.Cecil.ModuleDefinition.ReadModule(Disposable1 stream, String fileName, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at ApiUpdater.MovedFromOptimizer.Program.CollectMovedFromTypeNamesFromAssembly(String assemblyPath, StreamWriter outputFile, IAPIUpdaterListener logger)
at ApiUpdater.MovedFromOptimizer.Program.RealMain(String[] args)
at ApiUpdater.MovedFromOptimizer.Program.Main(String[] args)

not quite sure what it means.

remote osprey
#

i'm gonna take a dinner break then I'll come back with more questions 🙂

queen thicket
#

im have a button setup with a onclick but my function wont show up when i try to find it ik im prob jsut dumb but can someone help

rocky canyon
#

did u drag in a gameobject w/ the script or did u drag in the script itself?

queen thicket
#

wdy,

rocky canyon
#

did u drag in one of these

#

or one of these

queen thicket
#

yes i draggewd that one in

olive osprey
#

Drag the gameobject into the spot where it says none on the onclick function.

rocky canyon
#

thats wrong..

olive osprey
rich adder
rocky canyon
#

u cant drag the script in there like that

#

u have to drag in a gameobject w/ the script attached to it

#

the script doesn't exist just because its in the project folder

queen thicket
#

thers no object to drag in another gameobject

olive osprey
#

@rocky canyon are you able to help me with my error im facing?

rocky canyon
#

the slot

rich adder
rocky canyon
#

this one.. drag a gameobject in there

#

if u dont have a gameobject w/ the script make one

#

¯_(ツ)_/¯

rich adder
#

components need to be on a gameobject

olive osprey
#

youtube and google are great tools.

#

but they dont always work....

rocky canyon
#

yes they are, and no they dont

olive osprey
#

cause I cant find the fix to my issue lol

rich adder
#

you have to learn how to fix things yourself

#

isn't that the whole point?

olive osprey
#

sheesh

#

nice

rocky canyon
queen adder
queen adder
stuck palm
#

the game freezes up for a bit when i try to load from disk, is there a way to make this async or coroutine to let it load replays in the background?

rocky canyon
rich adder
#

cause its lowlevel

verbal dome
#

Probably using unsafe code 🤷‍♂️

#

I just found it by googling "unity read file async"

stuck palm
#

could i fuck something up with this method

#

public unsafe void

#

never seen that keyword before

verbal dome
stuck palm
#

so it lets me use pointers

queen thicket
rocky canyon
#

you need to restart ur editor / pc

#

somethings fkd up

rich adder
queen thicket
#

thats a script not a scene obkject'

rocky canyon
#

unless thats just bad screen recording im seeing

rich adder
swift crag
rich adder
#

would love to test it with big file

queen thicket
#

and how do you mean that

stuck palm
rich adder
#

no clue, my first time seeing this. the link i sent seems to be doing it inside Update so idk whats going on

queen thicket
#

What does that mean im very new

rocky canyon
#

this is how u assign a script to an inspector slot

stuck palm
#

interesting

rocky canyon
#

u dont drag in Apple.cs you drag in a GameObject w/ the Apple.cs script attached to it

#

as said 4 times already

rich adder
#

@queen thicket Scripts that are Monobehaviour are components. Components need to be on a gameobject to do anything.

rocky canyon
#

☝️ this

queen thicket
#

what i was poinng out was that it dosent show my function in the onclick thing id think thats what you guys are talking about it onbyl shows monoscript when i want it to show speedpotion functions to

rocky canyon
#

we know what we're talkin about..

rich adder
#

thats just a textfile by itself 🤷‍♂️

polar acorn
queen thicket
#

ok well i was confused because before i had done it just like that and it worked perfectly

rocky canyon
#

Create a New GameObject

  • Name it SpeedPotion or w/e
  • Attach the speedPotion script to it
  • Finally.. drag that gameobject you just created into the slot
swift crag
#

press X to dougb

rich adder
#

wish had nitro still

naive pawn
#

dougbt

polar acorn
#

At no point could you ever drag a script object onto a UnityEvent to run a function defined by the script

swift crag
naive pawn
swift crag
#

This is like trying to drive the blueprint for a car

queen thicket
#

ok

rocky canyon
#

writing calligraphy w/ a squid

rocky canyon
#

you also can't reference scene objects w/ a prefab

#

unless that reference is Inside the prefab already

queen thicket
#

ok well then this tutorial im following is not doing a good job

rocky canyon
#

sooo.. you should put that gameobject u made inside the prefab.. and then try assigning it

rocky canyon
queen thicket
#

i did the first one aswell

rich adder
#

you probably followed it wrong

stuck palm
#

thank the lord for linq

#

.Last is easy

polar acorn
rocky canyon
#

he made a prefab and dragged that into the slot

queen thicket
#

what did he make the prefab from?

rocky canyon
#

the gameobject w/ the script attached to it

queen thicket
#

ok ty for helping someone who has no brainpower what so ever

rich adder
rocky canyon
#

watch from 5:36

stuck palm
rocky canyon
#

his script is ON the same gameobject

#

as said here

rich adder
#

for loops are always best in that case

queen thicket
#

wait nvm my code is (idk if i can swear but you know what i mean)

verbal dome
#

But yes one should be wary of Linq methods

rich adder
rocky canyon
#

trying backing up, and taking it a bit slower.. and pay attention to every move he makes

queen thicket
#

nah its just ||shity||

rocky canyon
#

it happens...

#

we all write shit code at first

#

it gets better the more you practice

queen thicket
#

this si my problem if you need the error its NullReferenceException: Object reference not set to an instance of an object
speedPotion.use () (at Assets/Scripts/speedPotion.cs:15)
UnityEngine.Events.InvokableCall.Invoke () (at <10871f9e312b442cb78b9b97db88fdcb>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <10871f9e312b442cb78b9b97db88fdcb>:0)
UnityEngine.UI.Button.Press () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:530)

final kestrel
#

Working on inventory is fun til you try saving and loading

rocky canyon
#

ohh.. that IDE doesn't look too configured to me..

queen thicket
#

not at all lmao

#

not at my home pc

#

just decided to pull the repo

rocky canyon
#

eeeek

#

would help to have it configured !ide it doesn't take long

eternal falconBOT
queen thicket
#

ikr it sucks having no intelliscense

rocky canyon
#

line 15.. theres a Null Reference..

#

somethings not assigned correctly

rich adder
dusty shell
#

pushing my entire project folder to git is normal right?

rocky canyon
#

saving and loading is the best thing i ever done

swift crag
#

notably, the Library folder is excluded

final kestrel
swift crag
#

!vc

eternal falconBOT
#
Using version control in Unity

Unity Version Control

git Git

Get the latest .gitignore file from here. It should be placed at the root of your Unity project directory.

queen thicket
dusty shell
dusty shell
rocky canyon
#

if u push ur Library folder get ready to wait a few hours

rich adder
dusty shell
#

Lost all my old projects so it seemed logical at the time

swift crag
#

if that was your first commit, i'd just nuke the .git folder, re-init the repository, add the .gitignore file, and commit again

#

it's probably easier than rewriting the commit in that situation

queen thicket
rocky canyon
# rich adder thats probably why. Once you build your own system by scratch by yourself, you w...
    public void Save()
    {   
        // ERROR CHECKING
        if(!Directory.Exists(Application.persistentDataPath))
            Directory.CreateDirectory(Application.persistentDataPath);

        // create json // pretty print cause line breaks for readibility
        string jsonObj = JsonUtility.ToJson(_saveData,true);

        // write data
        File.WriteAllText(saveFilePath,jsonObj);
        FlashSaveActivityIcon("Save System: JSON-W");
    }``` w/ JsonUtility ofc 😉
naive pawn
#

(rename it to just .gitignore in the root of your project)

queen thicket
#

im good enught with file handeling and stuff and i could make some devius spegethi code but i jsut dont know the unity stuff

dusty shell
swift crag
#

Serialization requires you to turn your giant blob of C# objects and references into a neat little file

#

It is non-trivial.

rich adder
#

Null reference are not "unity stuff"

rocky canyon
#

i skimmed the first one and the second one

wooden socket
#

hey guys! My game is pretty close to completion from what I can tell. I have a really dumb question and I know I asked it before kind of but im still confused a small bit

queen thicket
#

its not in his tutorial i made it myself 😢

shell sorrel
#

there is no magic bullet for good save systems, you really need to consider what data needs to be saved vs just reconstructed state

wooden socket
#

okay so, I want to take the value of lives from another script and put it into a different script in an if statement. do I use parenthesis and if so where.

rocky canyon
#

theres only two possibilities.. either you dont have a PlayerMovement assigned (which i don't see it getting assigned anywhere)

#

or theres no variable called runSpeed

queen thicket
#

wait what do i assighn it as

rich adder
rocky canyon
#

make it [SerializedField] priivate PlayerMovement movement;

queen thicket
rocky canyon
#

and then you can drag in the component in the speed script

wooden socket
queen thicket
#

== 0

rich adder
wooden socket
#

I also put public LivesManage lives; at the top

#

OH

queen thicket
#

lmao

rocky canyon
#

and u sure ur comparing the right thing?

#

shouldnt it be lives.lives == 0

#

rather than the Type

eternal needle
#

One is a variable of type LivesManage and the other is a number.

wooden socket
#

oh wait

#

i gotta make it an int

rocky canyon
#

my heads about to explode

wooden socket
#

im sorry 😭

rocky canyon
wooden socket
#

okay good lol

queen thicket
shell sorrel
#

Also need to compare not assign, and is it static or a instance field

rich adder
#

you can't make everything static , you have to learn how to make references and connect them

mild onyx
#

ok this time i swear i followed the tutorial exactly and i have 6 problems from 3 lines of code

wooden socket
#

okay ill look into it rn

wooden socket
#

I FORGOT ABOUT THIS SITE

#

THANK YOU

queen thicket
queen adder
#

Trying to add a score system to my game. Does anyone know what the errors mean? 😭

rich adder
polar acorn
rich adder
#

naming a method "Score" is strange..

rocky canyon
#

ur IDE woulda told u taht 😛

summer stump
rich adder
#

method name should be similiar to an action or something

rocky canyon
#

no d on the end

queen thicket
#

it dosent 😢

rocky canyon
#

why don't u configure it real quick?

queen thicket
#

erm what the sigma its still giving me the error 💀

rocky canyon
rich adder
rocky canyon
#

now u need to assign it man

#

see the None u need to put the gameobject in there that has the PlayerMovement script

#

and by now u should know how reference work (sorta)

queen thicket
#

ok my dumb ass frogot about that one cheif

rocky canyon
#

very important

#

you'll do it every single day of coding

mild onyx
rich adder
naive pawn
#

attributes use brackets, not parens

rocky canyon
#

( pretending to be [s

#

shameful

mild onyx
#

huh

mild onyx
dusty shell
rocky canyon
rich adder
rocky canyon
rich adder
#

its an Attribute

rocky canyon
#

yours wrong

rich adder
#

Where did you see to use (

mild onyx
rocky canyon
#

but u should assign it internally in the script when u can

rich adder
naive pawn
mild onyx
rich adder
dusty shell
mild onyx
rocky canyon
naive pawn
rich adder
naive pawn
#

you need [AttributeName], not (AttributeName)

rocky canyon
#

ya, if the script was meant to be on the same gameobjec thats fine @dusty shell

naive pawn
rocky canyon
#

but his script was on a different gameobject

rich adder
#

oh wops myb @rocky canyon

mild onyx
dusty shell
mild onyx
#

thank you that guy

polar acorn
# mild onyx I DONT KNOW WHAT THAT IS

"Hey man what is this thing?"
"That's called an 'Attribute', here's a picture of it"
"I DON'T KNOW WHAT AN ATTRIBUTE IS SIR I AM NOT A COMPUTER PERSON"

naive pawn
rocky canyon
#

ya, but i dont think his Movement script should be on his speedPotion

dusty shell
rocky canyon
#

doesn't make much sense for this situation

rich adder
#

camelCase classes 😢

queen thicket
rocky canyon
#

i was talkin to JoJo

queen thicket
rocky canyon
#

you should rest

#

for real

mild onyx
queen thicket
#

na

rich adder
queen thicket
#

i gotta get it done

rocky canyon
#

lol.. okay then

naive pawn
polar acorn
queen thicket
#

otherwise my dad will go and get the milk

rocky canyon
#

is that some gen z cryptic lingo?

rich adder
#

I remember my first beer too

eternal magnet
#

guys is unity easy to code games in?

rich adder
remote osprey
naive pawn
#

depends on what you consider "easy"

rocky canyon
#

if u have a moderate IQ level its prettty ez

eternal magnet
queen thicket
rocky canyon
#

lmao.. craziness

naive pawn
#

it's a skill, you have to actually put effort into it

rich adder
eternal magnet
rocky canyon
#

its all RELATIVE 😉

eternal magnet
#

ok so what unity version should i start coding at?

remote osprey
eternal magnet
#

60000.0.7f1 or 2022.3.34f1?

rocky canyon
eternal magnet
#

how can i change install loction, arch linux

rocky canyon
#

60000 could have issues u might not be able to deal w/ learning

rich adder
eternal magnet
#

would hdd work?

rocky canyon
#

sure

rich adder
#

yeah but ill prob b slow

#

ssd always better

rocky canyon
#

not too bad @rich adder

eternal magnet
rich adder
olive osprey
eternal magnet
#

my dad said if i started learning programing that he will buy me better gpu and bigger ssd

rocky canyon
#

but once its loaded up its not noticeable to me.. from my SSDs

rich adder
remote osprey
rocky canyon
eternal magnet
#

do i need windows to test games in windows or testing linux version is enough?

rocky canyon
#

depends on who ur target platform is for

eternal magnet
rocky canyon
#

then u probably want to test on windows from time to time

#

if u can

#

and Mac.. but i can't even do that

eternal magnet
rocky canyon
#

my friends aint rich enuff

rocky canyon
#

no issues

eternal magnet
rocky canyon
#

gross

eternal magnet
rocky canyon
#

lol.. sorry im just not a Mac fan

eternal magnet
#

but my windows gpu is 10 years old i have gpu passthrough

rocky canyon
#

i don't care if my games work on mac

eternal magnet
#

its about arm

#

windows is moving to arm as well

#

and i only have x86 pcs and laptops

rocky canyon
#

not me im not

eternal magnet
#

i wish it was easy to run arm windows games on android

#

as how easy it is to run x86 windows games on android

rocky canyon
#

i dont understand really why you'd want to run any games other than mobile games on android

#

just get a Surface and be done with it

eternal magnet
#

it would be very intersting to make android game like the ads you get but at the same time have pc version and maybe steam version

naive pawn
eternal magnet
#

technly i can run mac os but without gpu

rocky canyon
rocky canyon
#

if u use the new input system u can probably make an input action map that would work for both PC and Mobile

naive pawn
rocky canyon
#

id do that for ya guys 🙂

eternal magnet
rocky canyon
#

webGL builds are harder for me than regular builds

#

hard af to get them working as good as good as standalone build

#

compression issues, graphical glitches / artifacts / weird shader issues.. or just incompatible

frank zodiac
#

so is triggered when i press the key or is it started?

#

im confused abt this new input system

rocky canyon
#

performed i think

frank zodiac
rocky canyon
rocky canyon
frank zodiac
rocky canyon
#

i need to debug my test class and see for sure what happens

frank zodiac
rocky canyon
#

i didn't really help but no problem 👍

#

lol

wind raptor
#
[Serializable]
public class SomeClass
{
    public SomeClass()
    {
        // when does this get called?
    }
}

public class SomeOtherClass : MonoBehaviour
{
    public SomeClass SomeClassInstance = new SomeClass();
}
wooden socket
#

okay so im still a bit confused. in a script that has the lives counter, I want it to play a transition that I made in a different script when lives == 0

worn egret
#

Hello i need help, I try to do that my player slide on the wall :
if (isSliding == true)
{
rb.velocity = new Vector2(rb.velocity.x, Mathf.Clamp(rb.velocity.y, -wallSlidingSpeed, float.MaxValue));
}

I know that isSliding is true but my player drop on the floor normaly, my rb.velocity is false ? (the if is on void update)

swift crag
swift crag
#

For a Value-type action, it fires whenever the value changes. It might also fire when the input returns to zero (I don't use events for value type actions)

#

I just directly read the value as needed.

wooden socket
#

I know I can reference the transitionController script, but Im getting this error

naive pawn
#

that's its constructor

#

new Classname() is the constructor call

frank zodiac
#
bool interactable;


public void OnInteract(InputAction.CallbackContext callbackContext)
{
    if (callbackContext.started && interactable)
    {
        Debug.Log("Interacting");
    }
}

private void OnTriggerEnter2D(Collider2D collision)
{
    if (collision.CompareTag("Interactable"))
    {
        interactable = true;
    }
    else
    {
        interactable = false;
    }
}

theres nothing wrnog with this code but the interactable bool wont set to true

swift crag
#

well, if you enter another trigger, you'll get interactable set to false

dense plume
#

Make sure the tag exists

swift crag
#

even if you're still overlapping the interactable trigger

dusty shell
#

Does unity have like complex assets?

swift crag
#

that seems wrong

swift crag
dusty shell
rocky canyon
#

yes

#

dozens

frank zodiac
dusty shell
rocky canyon
#

i recommend KCC

swift crag
#

Oh, like stuff from the asset store

frank zodiac
naive pawn
rocky canyon
#

chcek it out

dusty shell
naive pawn
#

...the game?

rocky canyon
#

no.. u wont find those unless there are some paid ones

#

u have to take a base controller and build it up

wooden socket
#

wait

#

thats a bad ss

dusty shell
wooden socket
#

lemme send my code

rocky canyon
#

but no.. u wont find a 1:1 apex controller

dusty shell
wooden socket
#

what could I use instead of void?

naive pawn
#

i don't think messages can be coroutines

shell sorrel
wooden socket
#

ah true

#

lemme make a coroutine

rocky canyon
#

nothing.. thats what OnTriggerEnter2D is

shell sorrel
#

best you can do is define a seperate coroutine and start it within that message

polar acorn
shell sorrel
#

would keep most of the code in the OnTriggerEnter and just move the SetTrigger, WaitForSEconds and load to a coroutine and start it from there

rocky canyon
#

OnTriggerEnter --> StartCoroutine(TriggeredCoroutine());

wooden socket
rocky canyon
#

u could pass those into the coroutine if u needed too.. but what passerby said is what i was thinking..

wooden socket
#

okay ill do thagt

rocky canyon
#
    void OnTriggerEnter2D(Collider2D other)
    {
        StartCoroutine(HandleTrigger(other));
    }

    IEnumerator HandleTrigger(Collider2D collider)
    {
        yield return new WaitForSeconds(1f);
        Debug.Log(collider.name);
    }```
wooden socket
#

okay now do I type yield HandleTrigger?

naive pawn
#

wdym

#

you don't yield the coroutine

wooden socket
#

how would I call the HandleTrigger in the OnTriggerEnter function

sage mirage
naive pawn
#

and then start it as a coroutine

frank zodiac
wooden socket
#

wait lemme show u what I have

naive pawn
frank zodiac
#

and yeah i did right it

naive pawn
wooden socket
#

ok

sage mirage
frank zodiac
sage mirage
#

I am currently making a short psychological horror game, and I really have to watch tutorials on how to make interactable items and doors etc

stuck palm
#

hoq can i make attributes?

#

like [Attribute]

#

i think thats what its called

shell sorrel
#

they are easy to make but using them requires using reflection

#

for the most part its as simple as making a class that extends from System.Attribute

#

your constructor args become the args you can pass into the attribute on usage

swift crag
#

making them is trivial

#

but yeah, using them requires reflection

shell sorrel
#

using them requires more work

swift crag
#

accessing the constructor args is also mildly confusing

#

i thought you could just assign to fields on the class at first

shell sorrel
#

whats confusing, i always just have constructor args that have it to set a bunch of readonly fields

#

i use them in a few cases in my project, like register action types with the behaviour editor

#

and for stuff like building the debug/cheats menu

swift crag
#

I wonder if I'm just mis-remembering another error I made

shell sorrel
#

can get the attribute info back easy with either .nets GetTypes GetMethods etc

#

or via unitys TypeCache if its for editor stuff

stuck palm
#

what is reflection

shell sorrel
#

a meta coding feature

swift crag
#

reflection lets you ask questions about types

#

like "what fields does this type have?"

#

It's how Unity calls things like Update

shell sorrel
#

lets you do stuff like see what fields a type has, or what methods it has and invoke one etc

swift crag
#

notice how it's not protected virtual void Update() or something

#

as long as you have a method named Update, it works

shell sorrel
#

reflection is not very performent

swift crag
#

I guess that's the simplest way to explain it: accessing things by name

shell sorrel
#

its best to avoid in alot of cases

swift crag
#

"who calls this method?"
"I DON'T KNOW"

#

speaking of, pro tip

#

if you do need to use a method name, do this:

shell sorrel
swift crag
#
Invoke(nameof(Foo), 3f);
shell sorrel
#
    public class CheatAttribute : Attribute {
#

and tell the IDE this means implict use

swift crag
#

neat

shell sorrel
#

all of my other reflection usages are editor time only, and for tooling

swift crag
#

My main use of reflection is a horrifying class that checks for missing references

#
            while (parentType != typeof(object) && parentType != typeof(MonoBehaviour) &&
                   parentType != typeof(ScriptableObject))
            {
                fieldInfos.AddRange(parentType.GetFields((BindingFlags)(-1)));
                parentType = parentType.BaseType;
            }
#

yum

shell sorrel
#

but yeah my cheat menu builder uses a ton of it and is complciated since it needs to build ways of setting up the proper UI per type, and for executing methods with args and passing stuff to properties

#

@stuck palm what is your usecase, and is it wanted on types, or fields or methods

stuck palm
#

oh i wa sjust curioous lol

#

dont actually plan on making any

shell sorrel
#

think of things like the Range(0f, 1f) etc

final kestrel
#

If you could rate... How hard is integrating inventory system with save load system for beginners like me? I started to question if I have negative iq or something

shell sorrel
#

Without much experience programming hard. But things get easier at a fast rate as you gain experience

swift crag
eternal magnet
#

why does default loction has to be in /

swift crag
#

it gets easier if you simplify your design, such as by...

  • having a fixed set of items (more like "key items" in Pokemon, for example)
  • having non-stacking items
  • keeping the items simple (no upgrades and modifiers)
eternal magnet
#

i only have 120gb ssd it cant fit anything

#

it become 0bytes free from unity packages

final kestrel
eternal magnet
#

changing loction redownloads what it has downloaded

swift crag
#

did you mean to type something else

final kestrel
swift crag
#

I am exploring that kind of thing now

#

I have around three years of Unity experience and a decade+ of general programming experience

final kestrel
#

cos what I understand from serialization is that I have to use the most basic types to be able to serialize them.

swift crag
#

That's why key items are relatively easy. You could even just write a list of item names.

eternal magnet
remote osprey
#

You only need consistency and patience.

wooden socket
#

collision count is in another script

remote osprey
#

Don't worry, I'm a total begginer at Unity and I've been feeling overwhelmed since I started it

#

You got it!

wooden socket
#

how can I solvle this error 😭

swift crag
swift crag
final kestrel
swift crag
wooden socket
#

does this look good>

#

WAIT

final kestrel
#

Why do people keep their keys and values in seperate lists instead of dictionaries btw?

wooden socket
#

i think I fiixed it

naive pawn
remote osprey
eternal magnet
final kestrel
wanton crow
#

if you have the programming experience, i would go for a manual serialization strategy,

  1. create a map somewhere of keys to prefabs
  2. when saving, loop the items and write the keys to a file
  3. when loading, loop the keys of the file and instantiate the prefabs by looking up the key in the prefab map
  4. bonus: assume all the values not in the save file are "default" prefab values and save the "changed" values to the save file to apply them to the prefab after loading
swift crag
wanton crow
#

thats how i do it anyway

swift crag
#

Unity serialization lets you store data in scenes and prefabs and assets

naive pawn
final kestrel
swift crag
#

Json.NET is used to turn C# objects into JSON, and then from JSON back into C# objects

#

They both do similar things -- turn objects into data and back

#

You need something to be Unity-serializable if you want it to appear in the inspector

wooden socket
#

i keep getting null reference exceptions

swift crag
#

find out what is null, then figure out why it's null

final kestrel
wooden socket
#

well, null is an object isnt referenced

#

but idk how thats possible

#

heres line 25 which is what its talking about

final kestrel
#

the OnAfterDeserialize method I meant

wanton crow
#

if you are doing a load/save game system, just note that it is completely separate from the Unity scene editor serialization

polar acorn
wanton crow
#

the two are not related other than that it can both involve serialization

final kestrel
swift crag
#

The example in the documentation is for reconstructing a dictionary out of two lists

#

Unity can't directly create the dictionary for you

#

But, given the lists, you can figure out the rest

final kestrel
#

Ah okay. Thanks. I must do more research on this

#

Shit is hard when you dont even know what you dont understand hehe

wanton crow
#

True Knowledge 😁

wooden socket
#

lemme look into it first

polar acorn
wooden socket
#

well hmm

#

i did this though

polar acorn
wooden socket
#

would i put the value in it in the same line?

polar acorn
wooden socket
#

a value called collision count

#

wairt

#

nvm

#

idk what to do

polar acorn
#

Well, which BorderController do you want this variable to hold?

#

You never answered that

wooden socket
#

BorderController is the other script

polar acorn
#

Okay but that script could be on thirty trillion objects for all this code knows

wooden socket
#

I want the value called collisionCount to be passed here

polar acorn
#

which one do you want

wooden socket
#

collisionCount

polar acorn
#

Which specific instance of the BorderController class do you want your variable borderController to hold

queen adder
#

^ when I drag the 0 down it goes under the road

swift crag
#

also, this is not a code problem

wooden socket
#

its just a script

swift crag
#

Show us the BorderController script.

wooden socket
#

!code

eternal falconBOT
queen adder
wooden socket
polar acorn
#

If there's no instance of BorderController then it is completely identical to if you had simply deleted the script

eternal magnet
#

hm i was going to do Godot

#

but unity seems easier

polar acorn
#

A script is merely a blueprint for an object. Until you actually make one, the script is worthless

wooden socket
#

OH i gotta make an object

#

mb

swift crag
wooden socket
#

but its on a object

polar acorn
wooden socket
#

the script

#

borderController