#Seeing variables
1 messages Ā· Page 1 of 1 (latest)
hi
We should send our explanations in one big message
So who would like to explain to him
not multiple tiny ones
Yes sure
I have a feeling you guys would NOT want to see what I did to get my player to move
but yeah I know that public variables can be edited with through the inspector
and that they are able to be accessed by other objects
[SerializeField] .. serializes the field.
Serialization just means converting something into a format that something else can read.
In this case, you're converting your field into a readable and writable field in the inspector window of your script.
You should do this instead of using public because you don't always want other scripts to be able to access everything. In fact, most of time you don't want any fields to be public.
TL;DR [SerializeField] makes your value show up in the Unity Editor (if it is supported), which will allow you to set it there instead of in the code
No, not really.
In the most basic terms, it's basically making a private field act as if it is public in the editor.
So basically you have a float, itās a variable
private float num
Now you look into your script in the inspector and you canāt see it
But how do you see a private variable
[SerializeField] float num
Like that ^^^
For now honestly, donāt worry about it and make them public
You want to avoid "getting" things as much as possible
Like your player ship, you don't want to have to search for the player ship everytime you want to do something with it, that takes A LOT of time.
They explained here why you would want to use that
would i do it like this?
Yes
yeah but i think the default accessability is public so you might need to specify "private"
i thought it defaults to private
Itās private by default
til
i've always specified private just because it looks more consistent but thats just a style thing
okay
so
I am curious about something
how do i make something more easily referencable
That question is a little bit vague
private is implied when not typed
You can drag stuff into the inspector fields
public GameObject obj; //Use the serialise thing if you want
And that will make a field in the inspector, and you will be able to drag any object in there
So then
you shouldnt have to make anything public unless YOU MUST
even then use properties with private set
apparently there is a way to avoid this?
If you want a reference to your game ship,
[SerializeField] GameObject playerShip;
then drag the ship in from the hierarchy into the slot in the inspector
You can do
public GameObject obj;
void Start()
{
Destroy(obj); //the object that you dragged in
}
doing find in Update is absolutely bad
performance and garbage collection wise
and then replace each of those times you use GameObject.Find() with playerShip
I make them public all the time, there isnāt too much of a negative effect
you are speaking over eachother again
this is BAD practice
I dont know who to follow
That's bad practice, especially in a collaborative setting
even still
Even then, it's a terrible habit
Follow Null and Bunniico
Iāve watched this
it's a bad way of thinking
I just watched it and still donāt really see much negative effects
the jist of it is, you dont ever want to be able to use things that you shouldn't be able to
But I know what I wonāt need to use, since Iām alone
you're essentially relying on your own ability to memorize how your own code works
The naming makes it easy to understand
in javascript i believe theres a term for it
I wonāt change āplayerBodyā because I know that it specifically belongs to that
no one is here to convince you, but you can look into. this is bad practice especially if you're doing clean code and want to eventually save yourself from yourself
why is in brackets ?
you can't do it inside of a method
thats just ur decleration
I mean, you guys were making sense
yes but it's better to follow a structured course
specifically official ones that teach good practice
@eternal marlin @cosmic plank Btw how long have you guys been learning for, you are very smart lol
I dont know where you learned to use GameObject.Find() in Update() but it certainly wasn't from me or your father!
somewhere between 4 and 8 years
I basically learn blindly
I'm still not very good at it though
I do it with pretty much anything
ehh i stopped counting years ago
I did too, and that's why it took me 4 years to be able to make the most basic racing game imaginable
That means a pretty damn long time lmao
Though i did it with only documentation.. so that's an achievement I guess
Nice thanks for answering
especially because unity docs are ASS
nah i still learn new things in unity, from veterans around here
i worked mostly on mods in C++ source sdk
Yeah, I mean you could always learn, nothing wrong with that š
i just learned a couple minutes ago what the default accessability was
:3
lol
visual studio i just have to type "p" and then press enter
Honestly this is my first major roadblock
yes theres useful ones like prop tab tab
So far I managed to do this, and only needed to look up two lines
oh my lord
Not a good way to do movement or rotation
ow?
it hurts..
it didnt take me long
That makes me reluctant to show my keypress system
What the
lol
yandere dev code
oh lord why everythingthis ?
I DONT KNOW
yeah that stuff i do not understand yet
thats not me and frankly i'm offended you would think it was
Not that I want to atm
my eyes burn thx
Guys fix my code for me pls pls pls ššš
nah my old code was bad
this except people actually post this on this server
I am pretty happy with the rotation. but something is wrong with it?
Yeah sometimes lmao
so much is wrong I don't know where to begin fixing it
Over complicated and probably not performant
maybe it works but you broke multiple laws of coding
if its greater than/less than the target rotation it rotates towards it by 5
one of the rules: avoid indentation
if you are putting if statements three layers deep, you're doing something wrong
weird
I was always taught to avoid nested statements
exactly, you are nesting a lot
if else statements are what I mainly use for that kind of logic
else statements are kind of awful imo
and that WHOLE script uses if else statements
its against the rules to
its in a thread so it probably wont be seen but still
ah, then I will remove it
how does hatebin work
I pasted the code to it but thats about it
press the save icon, then send the link
i'll look at it and give you some suggestions
there is no link?
the one in ur address bar
hit save
good try
its very well saved
now send link
I did
weird..
good lord.
do you have any weird blocking extensions like javascript blockers
I turned off ublock origin
same result
or that
#1 all variables should be at the top of their domain
look into Input.GetAxis("Horizontal")
It appeared to not work unless it was there
that shouldn't matter
Methods should use CamelCase
variables use camelCase
methods remind me of functions
they are the same
!!!
different names of the same thing
that makes a LOT more sense
yes that is the correct name
sorry for disrespecting the dude Pascal
thats funny
Pascal was the homie
yes , proprieties still Pascal
there are a lot of naming rules and they will vary wildly depending on who you're working with (including yourself)
is the naming system simply for easier reference and distinguishing between names?
it's just coding convention
They are for clarity & consistency
Coding conventions are a set of guidelines for a specific programming language that recommend programming style, practices, and methods for each aspect of a program written in that language. These conventions usually cover file organization, indentation, comments, declarations, statements, white space, naming conventions, programming practices, ...
Interesting
It mattered a lot more back when code editors didn't use syntax highlighting however it is still the standard
also it just looks nicer
yes like some people still use _privateVariable
(you shouldn't use _ to prefix variables anymore)
there's also a lot of spacing issues
hey so why does lookat have a declaration? I figured it would be a method
it does not
LookAt is a method group
oh
I believe an extension of Vector3 and Vector2
so transform.lookat? or something?
transform
best look at the docs when not sure https://docs.unity3d.com/ScriptReference/Transform.LookAt.html
funny thing
Looking at it, and confusing myself
wait
i think i just got it
WOW
declaration is how its declared in unity's code
that just tells you its accessibility, if its static/readonly/etc, and its parameters and return type
right
its telling you its a method inside transform class
transform.lookat();
that would be the correct way to call it, correct?
and then the perameters
yes because transform is already the instance to the objects Transform
I cant remember if it's Transform or transform
lowercase for the instance
right but is it an extension or is it a method within the Transform type
thats to declare something
public Transform myOtherObject
myOtherObject.LookAt(etc..
lowercase is the component every gameobject has
oh ok so it's an extension
its an instance of the class
I meant the .LookAt part
I was asking you if it was a method on Transform or if it was an extension method
hey so vector3.up would be Y axis, right?
it would be Y+
so 0,1,0,
the difference being
Transform.LookAt()
and
Transform myTransform;
myTransform.LookAt()
which one is it?
oh, also
but its instance
what is the error
ur probably not passing a vector3 or transform
playership must be either of those type or grab its transform with PlayerShip.transform
right or just keep it as a transform
yeah that makes sense
PlayerShip.transform doesnt do it, doesnt it?
it does
OH!
im just saying you can just have it a transform type
I just figured out what you meant
gameobject type is usually not useful anyway
you can load in different instances from different objects by calling them like that
and reference them when needed
like i said you can make it closer to the type you'd need it to be
if you made a script called Player and you did cs public Player yourPlayer
you can then drag the object with script Player
but you can still do yourPlayer.gameObject
or yourPlayer.transform
Oh
while being a Player type
i see
if it's monobehavior of course
weird
it didnt actually reference the object without me using the inspector to select it manually
it works now, and follows the player
now to make the character a source of light
its funny how different the difficulty of doing this in 2D is to 3D
doing it in 2D is a lot harder
oh
so If i wanted a 3D grid
as a backdrop
would I just have to copypaste a bunch of privative shapes?
Well unless you want to waste time and want your game to run at 20 FPS then sure
you can use a 3D grid
unless you do ecs/dots
don't say those words they're just a baby
Dots š
I am intrigued
no you aren't, look away
ECS is hawt
okay
A background grid?
thats probably just a pre-made png or a shader
Nice lol
oh well images aren't very hard to put in
all of that is spritework
I am trying to recreate it somewhat but with a voxelated asthetic
(its a twin-stick)
i dont think voxelizing 2D pixel art is very difficult but it is technical
Lmao I already did it once
the player ship in the unity screenshot
though it IS flat
well it would have to be if you're doing a true voxelation
otherwise it's something seperate
I think they are using a program like magicavoxel
magica coxel š
actually I just used a CAD program, recreated the sprite, then extruded it
i mean magicavoxel is made for this stuff lol click to build
yeah but for converting sprites to voxel?
using blender is better for something like that because its fast
besides I find it more fun. Makes me feel like I have a closer attachment to what I am making
iirc it has a tool to convert it but yea
though its complete malarkey in a practical sense.
if you plan a lot of bullet spawns consider learning Pooling
otherwise performance will suffer in those type of bullet hells
oh boy
is it considered self promotion if i try to show you guys JUST what this game actually is
but thats later
i doubt the mods would care
I could show you the steam link, which has a gameplay video on its store page
lol indeed
sometimes particles with colliders will also do the job, depending on usecase
This game literally has enemies spawning everywhere, rapidly
Each with a behavior unique to their type
ok well maybe ECS would be the better use, however ECS sucks ass in unity
rapidly as in the screen is full within seconds
ehh start with Pooling
then work ur way to dots
maybe throw some coroutines to mess with like some async stuff
is it possible for light to hit an object but still pass through it
as if the object is the source of light itself
I want the ship to illuminate the area around it while also being illuminant itself
oh then you want it to be emissive
the material?
there should be a box that says "emission"
oh, okay!
and you can choose its color and intensity
that color can be cycled through like the ship's material color, right?
umm
well the emission color is an HDR color so idk
are you doing it through animation?
nope
you can also throw a light above it
direct editing of the material through visual script since thats what i used while starting the project
thats what I tried at first
you need to be around surfaces you can actually illuminate
oh ok and add emissive to complete the look
this is basically what the ship does
you guys cant see it in a screencap obviously
but thats what it looks like
shareX is a cool tool that lets u capture gifs quickly btw :)
bloom will do that
so you use emission on the material, and then add bloom as a PPFX
yes u need pp to work
i mean personally I don't need PP to work
but sometimes it feels like that in this industry yknow š
hey so I am not sure I am getting something
uh huh
I want to reference the light component
so that I can change it's color through script
[SerializeField] Light mySpecificLight
this one of those cases where_ is good
I dont think I've ever used Component
oh
cause it will give u a green sqiggle
so I want to use Light instead of Component?
you inherit from it but not really use it in editor
Yeah, Component is pretty much useless for your purposes
Wow that was kinda stupid
always double check docs..https://docs.unity3d.com/ScriptReference/Light.html
well everything you put on a gameobject is a monobehavior
so you almost always want to use the name OF the monobehavior
not really
oh
everything on the gameobject is a component
unity is Component based
A component in general terms is something that extends an entity that adds behavior and data
In ECS, components only have data, no logic which makes it a lot more complicated to think about IMO
the unity ones are just scripts, so yeah components made by unity
i see
okay
I am looking at the light documentation
I dont see anything about modifying RGB channels individually
you don't
you have the make a new Color
and plug it in
you should probably just use animations
light.color = newcolor(RGB)?
it'll be a lot easier than keying in your own animations in a script
Color32 myCoolColor = new (123f/255f, 29f/255f, 45f/255f);
I want to learn it this way for now. just for the sake of getting it
and its on a scale of 0 to 1 right
instead of 0 - 255
i think it is 0-255
so i was mistaken
was already looking at it
color32 is for what i sent
color32 yes
color32 didn't work out for me for some reason but color did
there was apparently some sort of conversion error
yeah color was correct
idk why second guessed
it has input for RGB
iirc it converts it or something
I managed to get this script finished pretty fast, too
but I think I am beginning to grasp the object concepts better
So this code works but what can be improved?
color32 apparently takes bytes instead of floats
yes thats 0 to 255
new Color32(77, 77, 122, 255);
does it convert ints into bytes?
byte . 0-255
yeah, i get that
its a struct in c#
oh
I mean its a very important thing in computer science in general
lol
I mean
i understand the byte
i just didnt know if it was a datatype on the same level as floats and ints
like
private byte varName = 0;
or something
right
i was in a computer class for a little before i dropped out and i never really did learn what a signed vs unsigned number is
if you write to textures you do stuff like that
(referring to this)
I was never taught what unsigned and signed numbers are
i think its when the first bit means if the number is positive or negative right?
is there any way to improve on that code?
this one
there is always ways to improve
well, yeah
but whats the best way to improve now
aside from doing those tutorials
i HATE tutorials
what u needing to improve exactly ?
if it works just keep going
no reason to refactor until necessary
Well, I still to some degree lack the object oriented nature of c#, but thats something I want to pick up on as I go on
Tutorials just dont work for me
and i know thats my own fault
well I did link you to a few structured pathways
idk u learn how u learn, just find the things u encounter or hear here and watch different mediums
oh
so i noticed some desync between the ship color and the light color
though they SHOULD be identical
here's the funny part
I used visual scripting for changing the material
use ++ instead of += 1
it's the same thing lol
exactly, but one is shorter
haha yeah that would be bad
ā¦.
my nightmare is real
Itās been a while since Iāve coded so I dropped that. I remember that it exists now though.
it's rampant in #š»ācode-beginner
Anyways so as of now you can move the ship freely. It tilts to the left or right depending on which way it has to rotate. And it glows. Also the camera works
everything's rampant in #š»ācode-beginner
I want to learn how to make it fire bullets
Many tutorials
But youād use Instantiate() and AddForce() mostly
you really wanna be using rigidbodies on bullets?
in that sense i mean
One way
nothing wrong with it if done correct
seems a little overkill for something that can be done by just moving Forward * Time.deltaTime * Speed
physics = fun bouncy bounce
Raycasts: Eh, not cool for bullets
Rigidbody: Can be expensive, but cool š
Transform: Cheap, but not as cool as physics
Well yeah
Yep, and also when you get too close to a wall it can get weird
when fast at least
raycast has it's annoyances like manually adding bullet drops or a bullet tracer that isn't instant
Oh well in actual game the bullets are intangible and disappear at the first thing they hit
Maybe a small spherical collider?
spherical colliders are slower than squares i think
Really?
What do you think is hardest to program from scratch
-Simple physics calculations
-Collision detections
-Rotations
intuitively that would make sense
Isnāt sphere colliders just like a math equation
yeah but a circle is more complicated than a square
therefore it would be slower, which is a bad thing in a bullet hell
Well itās a bit different when it comes to collision I think
You can extend a box in any way
wait
i'm wrong
spheres are EASIER because they only have to calculate the distance
but a sphere-shaped mesh collider would probably be terrible
Oh course lol
Itās Friday tomorrow, Iāll finally be able to work on my game again
(I can only work on weekends and Friday)
mesh colliders are def expensive indeed tho
A sphere collider but you can stretch it
your limbs are kinda like capsules
Yeah my game uses ProBuilder, and thereās simple shapes like rectangles, they all use mesh colliders, Iāll need to switch it to box
Trueā¦
just switch them yourself
youll get prob a slight boost
it should auto detect the shape if its squared
What if colliders irl where like primitive shapes š¤
or use convex
I do
That helps? (For those type of shapes)
But honestly Iāll just switch to Box
it helps because yeah sometimes it's the only way to use mesh collider with rigidbody
Yeah I will lol
Yes thatās what I do
Also
One problem with them, Pipe shapes
They sadly cover up the opening
š
yeah it's a pain with that
Yep
And my game is completely a physics game
So I guess pipes wonāt be able to be rigidbodies
technically the universe made of an infinite number of tiny sphere colliders
that explains why Life is balls..
Yeah technically
Oh yeah so how much vertices does a human body have
about 7 x 10^27
Nah I think more
Lmao
Donāt we lose skin vertices all the time though, so you donāt Have a consistent vert count
well yeah
irl everybody has a mutable mesh
Yep
so you can only estimate how many verts someone's mesh has
very expensive computer running us
Veryyyy
Yeah but star materials are too emissive
i pity the artist who had to make the LODS on all the planets and stars we haven't been to yet
Yeah
they could've just made a white dot billboarded sprite for most of them š¤¦āāļø
Also is there a lot of GetComponent calls when doing certain things? Like hitting a rigidbody to add force to it
Fr
nah they def use ECS
Oh yeah probably
also i bet they batch up the colliders
Also APPARENTLY thereās no limit to lights, I assume we are Forward rendering?
well technically the lights are culled whenever someone doesn't see them
But I mean, there is raytracing
So can they be culled?
The rays bounce everywhere
yes I believe so
Oh wow
if the end point of a ray is not perceived, it's not rendered
Oh right!
its very efficient, which is weird because most things are horribly inefficient
Oh AND APPARENTLY thereās no limit to how much Audio sources can be played at once š¤Ø
Yeah
And cells are prefabs, they get Instantiateded at each otherās position
Technically there's only one audio source since all of the audio heard by the audio listener
and the audio is just air waves very quickly
Right, there is one audio listener for every player
only the player can hear their own audio listener
It gets disabled dynamically so only the player's own listener is enabled at a time
Thatās a pretty smart system
i can't imagine the poor GC
And is render distance⦠Math.Infinity ? š¤
technically it's not infinite
Yeah very sad
Oh yeah
It's expanding at 73km per megaparsec
And itās so long it probably ends somewhere in space where you canāt see that far
(or once every 3.26 million years)
it's not unnecessary, we do it for VR
Oh yeah true
Forgot about that
Also whoever made our way of machine learning is very bad, humans just get dumber each time š¤
man that is a SCARY name for a wikipedia article
idk it feels more like a 2am conversation
Hi everyone, welcome to TierZoo, the web show which seeks to analyze the meta to determine the best current builds. I talk about the special abilities and build strats of various prominent animal classes and show people things they may have overlooked when specing their character.
Okay but actually my goal is to get gamers interested in zoolog...
its basically how this channel talks
i regret choosing human but i at least got lucky and joined the NA server
Human bad š
?
Idk everyoneās saying something like that
yea the mario bros movie trailer came out today
Yeah
i watched the trailer, it was meh, but chris pratt should not be mario