C
C#12h ago
Randomator

What is this "Function" called???

I am programming in unity and well.. I needed to call a bool from another script... The goal: To detect if the boolean named "birdIsAlive" in "BIRBSCRIPT" is true and if so to enable the ESC key for pausing. The issue is solved, but I can't seem to understand why this works. "EscapeKeyMechanism" references the "BIRBSCRIPT" via a gameobject with the script attached. BUT in the "EscapeKeyMechanism" I don't understand why the "if(BirdLife.birdIsAlive)" is able to detect as dot operators can't see booleans.. right..? Or is that not a dot operator..? Help to understand is appreciated.. I'm super new to C# so... ye thanks! :>
No description
No description
8 Replies
ero
ero11h ago
Considering birdIsAlive is a public member on BIRBSCRIPT, any code that has a non-null reference to the script will also be able to access it. There is no "dot operator", what you're doing is a completely normal member access. The type of the member matters not.
Randomator
RandomatorOP11h ago
Wait a boolean counts as a member?
ero
ero11h ago
A field counts as a member. The type does not matter
Randomator
RandomatorOP11h ago
So because a boolean is a field it is therefore a member?
ero
ero11h ago
Sure. Just how myRigidBody, flapStrength, and logic are fields and therefore members
Randomator
RandomatorOP11h ago
ah.. I see! so what do you call this operation then? Like if I were to google it, what would I have to type to learn more about this type of access from one script to another?
ero
ero11h ago
Member access, like I mentioned
Randomator
RandomatorOP11h ago
Alright thank you Sr Ero :)
Want results from more Discord servers?
Add your server