If you find yourself confused about "if" and "if else", don't worry, I'll be making a dedicated video explaining "if" statements in detail soon! Anyway, hope this made at least a little sense. Variables are very powerful and important tools- If you'd like a follow-up video with further explanation about how variables work, leave a reply down below so I know how many people are still confused :)
@thedude40393 жыл бұрын
This is gonna make a glorious playlist.
@prinzpablo5273 жыл бұрын
Since Brackeys stopped posting Unity stuff, this channel is a huge help.
@Thesupperals3 жыл бұрын
@RoyalSkiesLLC I'm already stoked to see another video. I can't wait for the tough stuff. Someone in Brackey's Discord Server taught me this really REALLY helpful tip using Visual studios. This tip was: highlighting a name given by Unity in the script (such as Input, Component, or even library names such as UnityEngine), left clicking for a pop up and picking on "go to definition". In there, it brings up another tab which shows you where you are grabbing this "information" from. In other words, I can find out what I'm actually using and how I'm going to manipulate it. I hope reading this wasn't entirely useless and next time I'll keep my yap shut.
@Ikxi3 жыл бұрын
Ohh so you can double check if the variables you put in code are the correct ones that you defined at the beginning? Neat!
@FacePlant343 жыл бұрын
Awesome work as usual! Just little technique to make code look nicer. Instead of writing it as: public float xMove; public float yMove; You can just type: public float xMove, yMove; This applies to all variable types too!
@sergeysafonov24613 жыл бұрын
public Vector2 move; //think about it
@vonbismarck91943 жыл бұрын
Another like for another good video. As a software engineer I can agree we go from 0 - 100 really fast explaining variables and other stuff, all in all you are correct in simplest terms in how to use them and what they are, great work!.
@TheRoyalSkies3 жыл бұрын
That means a lot to me, coming from a software Engineer, so thank you :)
@vrmsali3 жыл бұрын
You make it sound so simple. Cannot wait to see the next video.
@masonwheeler65363 жыл бұрын
"A variable just represents a value that you want to control." As a programmer, that's a very good explanation. I'd just add one other point to it: *scope.* You're declaring these variables on the class itself. Those are generally known as "fields," (analogous to individual fields on a form that someone fills out, each holding one value,) and fields retain their value for as long as the object sticks around. You can also declare variables inside of a method. Those don't remain "in scope" forever; once the method finishes running, their value goes away and if you go into that method again, they have to be set up again.
@sergeysafonov24613 жыл бұрын
Boooring! Let's add scope modifiers too. Yeah! And what about variable types. That's very important too! And .. what about static variables? And what we gonna do with properties, not a fields. Let's explain them too! You do not really want to know about it when you just want to move your cube around watching funny video 3 minute length
@Negasuki3 жыл бұрын
Let me refer you back to 0:10 . Thank you.
@masonwheeler65363 жыл бұрын
Mock it if you want, but scope is something that's important for people to know. I just now had to help out a beginning coder who didn't understand why a variable declared inside one of his methods wasn't visible to the code in another method. Once I explained the way scoping works, he got it and was able to make his code work.
@simonlu51413 жыл бұрын
yessssssss, that was the fastest and clear explanation of variables i've seen yet!
@jod44113 жыл бұрын
You're the best teacher holy shit
@ZiiTechArt3 жыл бұрын
I Appreciate your way of teaching artists coding in Unity, wish i had you when i was getting started.
@focalgain Жыл бұрын
These quick overview breakdowns are amazing. Your a legend for this one thank you
@Ikxi3 жыл бұрын
2:30 LmAO I wanted to ask exactly that just now if it's possible xD Partially these videos are great for getting more knowledge. But at the same time, really nice entertainment! Thanks for all your hard work
@sergeysafonov24613 жыл бұрын
0:30 - For-Loops are the future! - That is Exactly what I say to my noncoding-friends usually! But with no luck :(
@soft96463 жыл бұрын
so funny 😁 i was born with logic 💖
@LordSeddok3 жыл бұрын
You seriously make me wanna think about switching from Unreal Engine 4 to Unity, because the coding part chased me away (although I do know some programming through my studying). In Unreal Engine you can use Blueprints (it's more like dragging boxes here and there and connecting them accordingly, like the node editor in Blender), but I think in the end it's still the same, just think about it as a different language. And when I look at it, having problems to simply duplicate something like an "if" and "else" in blueprint language, I sometimes wonder if I should give Unity a shot... Long term short: Can't wait for the rest! Especially the part where we bring in animations. :P
@DavidBoura3 жыл бұрын
If and Else in UE4 blueprint is the Branch node, with True and False outs. But yes Unity is more beginner friendly for coding. It now has Blueprint equivalent in the name of Bolt.
@SKongdachalert3 жыл бұрын
Zero dislikes, as it should be. Your videos are treasure. 🙂
@JoseRodriguez-gx6yv3 жыл бұрын
Amazing video like always
@kirayt2493 жыл бұрын
Please continue rpg unity stuff im glad to know ur channel!
@kriegs83153 жыл бұрын
Yes
@sergeysafonov24613 жыл бұрын
If I were you I defenitely would add speed factor as public variable
@mozikr96943 жыл бұрын
so useful,thx
@alishersadullaev85333 жыл бұрын
Just think of variables as a containers for values you put in them
@Wolfhedgehog3 жыл бұрын
Never, what about all of the caveats, you need to understand the differences between pass by value and pass by reference. What about all of the variable scopes, is it a static or instance variable? How else are you going to program correctly? /s Seriously both this comment and the video do a great job at simply explaining variables and their uses. Is there more to learn? Yes, but is it necessary? Not unless you run into the rare cases where more in-depth knowledge comes in handy. But that is what forums like stack overflow are for. I am interested to see how he goes about describing control flow to non-programmers. I always just use the "if thing is true, effect happen, otherwise nothing ( or something else ) happens". I will say, I understand where the programmer/engineering friends are coming from, there is so much information that is crammed in our tiny brains that it is cathartic to regurgitate it instead of internalizing it and describing it.
@alishersadullaev85333 жыл бұрын
@@Wolfhedgehog damn dude, calm down, relax, take a break or something, the purpose of this video and of my comment is to try to explain the general meaning of what is variables in programming for NON programmers, we are talking basics here and I'm sure we'll see all other advanced terminologies explained later on step by step, so just take it easy, and as far as I see you are a smart guy so try to use your knowledge in a good way and help this channel to grow 👍
@kayobro12343 жыл бұрын
I'm curious. Why are you still on the Unity white UI? Not like the white UI is unusable or whatever, but didn't they open up the black UI to everybody recently? If it's your preference, that's cool lol. I'm just curious.
@TheRoyalSkies3 жыл бұрын
Sure, I generally keep all my software at their defaults to make them easier for people to follow in the tutorials. If it looks like a different software, sometimes it confuses people lol
@Cybored.3 жыл бұрын
@Royal Skies LLC pretty sure Dark theme is the default now, but you should encourage everyone to use it anyway (eyes will love you)😄
@erwandelfour51723 жыл бұрын
I tried the last code you made at the end but didn't work(no Monobehaviour problem) I had to add this line before "void Upadate" and it works public move_controll_1() { }
@DavidBoura3 жыл бұрын
//declares a var and changes it ingame public class Movement : Monobehavior { public int velocity=1; void Start() { } void Update() { transform.Translate(0,.01f*velocity,0); if (Input.GetKey(KeyCode.V)) or velocity=0 velocity++; else velocity--; } } //right?
@Vector_Lotus3 жыл бұрын
Algorithm Support! Keep up the great work Royal :)
@gamingfriend52073 жыл бұрын
You are awesome
@prophdcc37933 жыл бұрын
Let's just say I was making a game. Now let's just say this game involved clicking two buttons, one that would add 1 to an integer, one that would take away 1 from an integer. I add the script to both buttons and make it so they both do as said, but now they both just function in their own isolated world. Like if I click the button to take away one it just keeps taking away one and doesn't affect the same integer on the other button. How would I fix this so they can affect each other?
@leress3 жыл бұрын
I would have to see your code, but from what you are saying I would ask did you link both button to effect the exact same variable? Did you make that variable local to the button or global to the program?
@ZEDCorbett3 жыл бұрын
Hi. Starting the explanation from zero in case others come across this thread. Pretty much every object in your game is something Unity calls a GameObject. This includes the shapes Royal Skies has been moving about in these examples. GameObjects can be treated as variables. In fact, any new scripts (i.e. "Classes") you make in Unity can also be variables in completely separate scripts. So you could create a sort of master script, put it on an empty GameObject (similar to an empty in Blender), and make two variables slots in the script for your two buttons. Unity will let you drag an object (in this case, each button) into a variable slot on the empty's script as long as the type you declared for the variable in the script matches one the scripts on the object you're dragging (GameObject is technically a Unity script, which makes those fair game). So you can use the master script as a sort of brain to control the other objects as variables.
@TheRoyalSkies3 жыл бұрын
Well cover linking different scripts together soon, but for your example, it may be easier to control both buttons from one script -
@Aryazaky3 жыл бұрын
@@ZEDCorbett I'm new to Unity and for this i used a script that's attached to nothing as global variables container. Then i can access it from other scripts. Am I doing it the right way?
@ZEDCorbett3 жыл бұрын
@@Aryazaky It's doable, but if you're new to Unity, I'd recommended attaching your global script to an empty object. It's the easiest way to get scripts to talk to each other and to objects in the scene. The "MonoBehavior" part of most Unity scripts actually requires that the script be attached to a GameObject in order to run. Here's one example of how scripts can interact with to each other: kzbin.info/www/bejne/gWXYgJ2YatVmf9E