C# Classes in Unity! - Beginner Scripting Tutorial
Mô tả
Watch this video in context on Unity Learn: https://learn.unity.com/tutorial/clas... How to use Classes to store and organise your information, and how to create constructors to work with parts of your class.
Danh sách bài giảng (1 bài)
Bài 1: C# Classes in Unity! - Beginner Scripting Tutorial
Video bài giảngBài kiểm tra Quizzes (0)
Chưa mở khóaĐánh giá từ học viên
Nhận xét và trải nghiệm thực tế từ các học viên đã đăng ký tham gia khóa học này.
Dựa trên 10 lượt đánh giá từ học viên
Đăng nhập để đánh giá khóa học
Bạn cần đăng nhập và tham gia khóa học để có thể gửi đánh giá và nhận xét.
Tất cả đánh giá 10
One of the most important principles of OOP is single responsibility. Try to make "as many scripts as you can" following the single responsibility rule. Try to make one script take care of one task only. For instance, for my player I have one script to control its particles, another to control sound effects, another to control animations, another to control movement, another to control death, and so on...
That way it's easier to:
1 - Find bugs and fix them
2 - Add new things, a.k.a scalability (really important creating games)
3 - Organize things
4 - Being able to take off things without breaking everything
5 - It will be much easier to come back to old scripts that you don't see for ages
6 - People will think "This guy knows his OOP!"
Instead of building a Jenga tower, you just lay
I don't understand constructors... As a visual learner of how what code does what in real game, I don't understand why you have three projectiles (there's only one type of projectile in the examplew which is the watermelon) and what the whole point of the script example is, it seems so detached from the example game.
So it's a bit like how Instantiate has different parameters based on what variables you give it? That's cool!
i was confused as to how he could pipe projectileA into the same class twice.
prA, prB, prC in one, and
prA and fuel into the other.
He is putting 50 into both projectileA slots, so i wondered what would happen if you change one of those 50s? Which one will it do first?
BUUTevery time he calls it, hes storing it into a different variable (myStuff/myOtherStuff)
So if you change the numbers going into both, it doesnt matter, because youre calling on it with different variables, so theyre actually 2 different things entirely. I guess thats what instance means..
Anyways just thought id share cus that confused me initially.
Wow, one of the best lecture
/tutorial I ever watch, some confusing things are solved immediately. Thank you very much.
I just came here to understand how to call classes dynamically and for example leave my recoil class unopened/unused and therefore the parameters in it set to 0 or alike when i call my laser class but i still want to include the recoil class when i shoot a gun or launch a missle. Somehow tickboxes appear in this Script, but i really don't know why