Programming with Unity C# 101

*Deleted

I learned something read this, good work. Now finish it you lazy bum :slight_smile:

Thanks, I’m getting on it. I have an artist to make it pretty too.

Looks great. Good job!

Thanks, anything that seemed off?

hmm…you declare the variable “level” as an int, but in the text you say that you declared “num” as an int :wink:

haha, I was using boring old “num”, and then I decided to update all the pictures with game related variables. Thanks for that. I shall fix that!

Very nice tut man ima look further into it once I get home.

Someone needs to reread their basics.

Underlined can be removed.

Both long and decimal are value types in their own right - so you may want to thesaurus some less confusing terms.

This is where you got tired right?

Underlined can be removed.

That’s enough for now - rework it (the whole thing, not just the things I pointed out) and then ping me then for round 2.

Floats or Singles in C# are 32 bit floating point numbers.
Doubles in C# are 64 bit floating point numbers.
Decimals in C# are 128 bit floating point numbers and are the most precise, but have the smallest range of all the floating point types.

There is a performance overhead (AFAIK) for using anything but a float because Unity is a 32bit process.

Doubles are NOT “numbers with one decimal”. Do those even exist? Doubles are double-precision floating-point numbers, and are “bigger”, or more precise, than floats. A float in C# is a single-precision floating-point number. I would suggest reading up on the basics of the C# language before writing a guide to programming in it.

+1

Nothing wrong with writing a guide while your still n00b as a learning activity - but it requires that you do the necessary reading of the docs.

Not only is OP using doubles and floats in the wrong contexts… he’s creating some really weird variables to illustrate the point.

 float weight = .0001f

I can’t think of any good reason to have such a small weight in unity - physx simply isn’t going to like it.

TL;DR - one misconception leads to many errors. Do the research.

Thanks. I do need to find better terms to describe double and float. I picked up in college that double was merely an integer with one decimal behind it, and never really used it again. It would be a good thing for me personally to pinpoint the differences between float and double. As well as what a double is (although now I don’t think that there is much of a use for a new programmer to use?).

And I completely forgot that long decimal was a data type.

Will definitely make of note of this and put this in. Thank you for explaining the types. I fear that these are something I should have learned a while ago.

I will fix this now. I didn’t have a use for double before, and I misinterpreted the lesson while I was in college.

I’d hardly call myself a noob, but I did miss some important data types while learning. I was trying to use other terms than “num” for interest.

Attachment has been updated.

Not to be rude but you’ve missed vital data types and have flawed knowledge of the ones you do know. That means you’re going to need to sit down, read a couple C# 101 books/tuts, and re-validate all your fundamentals. It’s not going to be fun, but it shouldn’t take a lifetime either.

Can you double-check that the attachment is the updated one?

Not correct, semicolons have nothing to do with lines, it has to do with statements. Don’t confuse the two.

And you say you’re not a beginner, but everything typed in that documented says otherwise, the explanations are half-assed and often weird and confusing. Do “MonoBehaviours” even have a Main method? Also the Main method in C# if you’re akin to create console applications is a “static void” and not an instance method.

You should read a few books on C#, and the people that think about reading this guide should do the same instead.

I think the real problem here is that Unity is being used to teach the basics of C# programming. You wouldn’t introduce someone to C++ with the OpenGL library, and you shouldn’t be teaching an introductory programming lesson inside a game engine.

Maybe I’m wrong, but game programming requires experience with classes, knowledge about the API you’re working with, etc. Showing a beginner a class that’s inheriting from Monobehaviour, which is used by the game engine to update logic each frame, is pretty daunting.

Nahh - in fact before I left high-school I made sure that my ‘programming’ teacher was well aware of Unity for future generations. Game maker is often used as a learning tool. However I wouldn’t say this particular 101 is working on Unity’s strengths.

I am however a fan of learning Unity and C# separately - so as to gain two perspectives on what you’re doing.

Its actually written to be aimed at kids so, that probably doesn’t help the perception its getting :slight_smile:

How about we keep on topic on this tutorial as opposed to my supposed knowledge? The purpose of this tutorial is to give enough information to mid-teens so that they can begin programming.

And I’ll check. It should be updated.

I’m the beginner, yet you didn’t know MonoBehavior has a Main function? This is a watered down explanation to mid-teens, so they can give it a go at programming. I’d rather have feedback that tells me I’m majorly screwing up in my explanation instead of “half-assed” the point is to get the idea to an understandable form NOT to overload a kid. When I was 15, I would said screw this shit if I had to listen to the correctly detailed explanation.

I was going for learning a few basics in the Unity API so that its familiar environment when beginning game programming. I know its not the best way, but I think it would be more interesting than downloading VSE and working with straight console outputs. (I, for one, could not see the relevance between programming and games for a good while with that approach).

And I’m approaching classes the next time I’m free to put more into this.

Congratulations, you’re not the one learning from this tutorial. But I would appreciate feedback tailoring this towards a firm foundation.

Teaching and doing are two different concepts.

Thanks, larv

The Issue isn’t that your aiming at teens, but that your simply feeding them false information.

Also, the ‘f’ after .0001 is required to tell the computer that the value is a floating point value (float) and not an integer or whole number (int).

False and will lead to difficulties down the track.

Simple explanation:

When working with floats, remember to put a ‘f’ on the end of the number - e.g. 3f instead of 3, 0.5f instead of 0.5f. Not doing so can give weird results!

Detailed explanation:

The compiler makes a guess at what value type you mean when you use a literal - e.g. 3 or 0.3. In the former case the 3 is assumed to be an integer - so ‘float x = 3/2’ uses integers on both sides and will return 1 instead of the 1.5f you’d expect. In cases like ‘float y = 0.3’ the compiler obviously knows that your not working with an integer - however to prevent bugs [think finance] it has to assume that you mean double instead of float and will not allow implicit conversion.

It doesn’t?


Dr Seuss wrote books for children - no body would think they were written by children.