Unity 3D Position Variables (Quick Demonstration!)

  Рет қаралды 5,188

Royal Skies

Royal Skies

Күн бұрын

Пікірлер: 45
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
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 :)
@thedude4039
@thedude4039 3 жыл бұрын
This is gonna make a glorious playlist.
@prinzpablo527
@prinzpablo527 3 жыл бұрын
Since Brackeys stopped posting Unity stuff, this channel is a huge help.
@Thesupperals
@Thesupperals 3 жыл бұрын
@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.
@Ikxi
@Ikxi 3 жыл бұрын
Ohh so you can double check if the variables you put in code are the correct ones that you defined at the beginning? Neat!
@FacePlant34
@FacePlant34 3 жыл бұрын
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!
@sergeysafonov2461
@sergeysafonov2461 3 жыл бұрын
public Vector2 move; //think about it
@vonbismarck9194
@vonbismarck9194 3 жыл бұрын
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!.
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
That means a lot to me, coming from a software Engineer, so thank you :)
@vrmsali
@vrmsali 3 жыл бұрын
You make it sound so simple. Cannot wait to see the next video.
@masonwheeler6536
@masonwheeler6536 3 жыл бұрын
"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.
@sergeysafonov2461
@sergeysafonov2461 3 жыл бұрын
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
@Negasuki
@Negasuki 3 жыл бұрын
Let me refer you back to 0:10 . Thank you.
@masonwheeler6536
@masonwheeler6536 3 жыл бұрын
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.
@simonlu5141
@simonlu5141 3 жыл бұрын
yessssssss, that was the fastest and clear explanation of variables i've seen yet!
@jod4411
@jod4411 3 жыл бұрын
You're the best teacher holy shit
@ZiiTechArt
@ZiiTechArt 3 жыл бұрын
I Appreciate your way of teaching artists coding in Unity, wish i had you when i was getting started.
@focalgain
@focalgain Жыл бұрын
These quick overview breakdowns are amazing. Your a legend for this one thank you
@Ikxi
@Ikxi 3 жыл бұрын
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
@sergeysafonov2461
@sergeysafonov2461 3 жыл бұрын
0:30 - For-Loops are the future! - That is Exactly what I say to my noncoding-friends usually! But with no luck :(
@soft9646
@soft9646 3 жыл бұрын
so funny 😁 i was born with logic 💖
@LordSeddok
@LordSeddok 3 жыл бұрын
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
@DavidBoura
@DavidBoura 3 жыл бұрын
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.
@SKongdachalert
@SKongdachalert 3 жыл бұрын
Zero dislikes, as it should be. Your videos are treasure. 🙂
@JoseRodriguez-gx6yv
@JoseRodriguez-gx6yv 3 жыл бұрын
Amazing video like always
@kirayt249
@kirayt249 3 жыл бұрын
Please continue rpg unity stuff im glad to know ur channel!
@kriegs8315
@kriegs8315 3 жыл бұрын
Yes
@sergeysafonov2461
@sergeysafonov2461 3 жыл бұрын
If I were you I defenitely would add speed factor as public variable
@mozikr9694
@mozikr9694 3 жыл бұрын
so useful,thx
@alishersadullaev8533
@alishersadullaev8533 3 жыл бұрын
Just think of variables as a containers for values you put in them
@Wolfhedgehog
@Wolfhedgehog 3 жыл бұрын
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.
@alishersadullaev8533
@alishersadullaev8533 3 жыл бұрын
@@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 👍
@kayobro1234
@kayobro1234 3 жыл бұрын
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.
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
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.
@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)😄
@erwandelfour5172
@erwandelfour5172 3 жыл бұрын
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() { }
@DavidBoura
@DavidBoura 3 жыл бұрын
//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_Lotus
@Vector_Lotus 3 жыл бұрын
Algorithm Support! Keep up the great work Royal :)
@gamingfriend5207
@gamingfriend5207 3 жыл бұрын
You are awesome
@prophdcc3793
@prophdcc3793 3 жыл бұрын
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?
@leress
@leress 3 жыл бұрын
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?
@ZEDCorbett
@ZEDCorbett 3 жыл бұрын
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.
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
Well cover linking different scripts together soon, but for your example, it may be easier to control both buttons from one script -
@Aryazaky
@Aryazaky 3 жыл бұрын
@@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?
@ZEDCorbett
@ZEDCorbett 3 жыл бұрын
@@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
Unity C# Variables Explained (For 3D Artists!)
2:25
Royal Skies
Рет қаралды 4,2 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 775 М.
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Unity 3D Controlling Position & Parenting (INTRODUCTION)
4:22
Royal Skies
Рет қаралды 8 М.
20 Advanced Coding Tips For Big Unity Projects
22:23
Tesseract
Рет қаралды 207 М.
I made a full GAME in 400 HOURS - this is how - in 19 minutes!
19:00
Controlling Sound In Unity - (In 5 Minutes!!)
5:25
Royal Skies
Рет қаралды 10 М.
How I learned Unity without following tutorials (Developing 1)
18:11
Game Maker's Toolkit
Рет қаралды 2,1 МЛН
Why You're Afraid To TRY -
3:17
Royal Skies
Рет қаралды 4,6 М.
10 Gamedev Libraries For 10 Needs (used by AAA companies)
11:33
Oskar Schramm
Рет қаралды 32 М.
External Painting Software Live Link to Blender with Ucupaint
24:05