# Unity When to learn c++?

This topic is 1753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Let me start off by saying I know the "Should I learn c++?" question has been done to death. I'm aware of the pros and cons stated by multitudes of folks on the internet. However, the answer to my question, alluded to in the title, has come up empty me in a google and forums search so I figured I would start a thread on it.

QuestionWhen should I start to learn c++?

That's the brief version, and if you want to, you can stop there and give a general answer to when someone should venture into the land of c++. And I'd like to thank you in advance for any reply or advice you can give. However, for those who wish to know more specifics of my case, I'd like to provide some of my personal history that may aid in determining what advice to give me. I hope this does not become a giant wall of text.

I have grown up around computers, my dad did some programming in fortran, pascal, basic, and some CNC languages when I was a kid. So we've always had a computer around that I was able to mess around on. I started with some pascal myself, then later ventured into javascript when I wanted to do some web stuff. In the early 2000s, I was enrolled in a computer science program at a college near me. They started us in Visual Basic and a little c++, though in c++ I didn't get much past cin/cout. I had to drop out due to financial and personal reasons. Later, I was able to go to a different college and finish a degree, but since the closest they had to CS was electrical engineering, which didn't really hold my attention, I ended up getting a BS in physics. I use python regularly for computational physics problems, and I feel comfortable enough with python that I feel that if I'm given something to program, even if I'm not familiar with the modules to do it with, I could delve into the documentation and find a way to do it. It may not be elegant, short, or efficient, but I feel I could find a solution. I am by no means an expert in python, there is far too much that I don't know in python to convincingly claim to be, but I feel I know enough at least to be dangerous, as the saying goes.

Lately though, I have been dabbling in C, mostly just taking old programs I've written in python to see if I can make them work in C, and get the same results. Ostensibly to see if there is a computation time benefit to learning C, but mostly to start learning it just because I'm a little curious about it and have the time. I have done a little game programming in python, mostly just the standard hangman, tic-tac-toe, and text based games. I haven't dabbled too much in pygame because I don't like it, I don't know where my dislike for pygame stems, could be the obnoxious colour of the pygame website, could be the overuse of underscores in method names, I'm not sure, but I'm just not a fan.

Obviously, with this history, I'm not just starting out learning to program, and I'm comfortable enough to say that I could probably pick up c++, so I'm not worried about can I learn it. I also know that at 30, with no real formal training in CS, and at this point, no real portfolio to speak of, at least that I'd be proud enough to share with a prospective employer, me becoming employed at a AAA studio, and actually needing c++, is really unlikely to happen.

Since I doubt that I will realistically ever need the lower level and efficiency of c++, is it even worth it to try to learn c++, or would I be better off just messing around with c# and an engine like Unity or something of the sorts? Furthermore, since I'm already trying to learn C for scientific computing purposes, would it be better to just learn c++ for that since that's just a superset of C anyways?

Thank you for taking the time to read this.

-Jared

##### Share on other sites

I'd say... anytime you want.

I started with Java/C# and web development, and when I decided to make a game I decided to use C/C++ since I considered it as the "main" language for programming games.

It's been nearly a year or two that I started, and I'm quite glad I did.

I still haven't got nowhere near getting a complete game, where I probably would have if I sticked to XNA (unfortunately deceased) or Unity, but I got to learn so many things about computers, graphics, languages and hardware in general, how they work, and this helped gave me conviction that I can manage to get anything, anywhere.

Lines I used to see often in C# such as:

MyClass mA = new MyClass();
MyClass mB = mA;


Now give me some shock before I realize "Oh, it's C#".

So, for knowledge I think it was a good thing, but for production value x time spent, not so much.

If you want to develop games and only focus on developing games, I'd recommend to stick to using an existing engine or learning C++ just for using the minimum required for these.

Another thing is, there's just too much about C++. Learning the syntax might take less than a day, it's techniques and such less than a week, but that alone isn't much, really. Learning C++ I think it's learning how things work and studying constantly for new things, how a certain app works, how you use a certain library, etc

As for C or C++, please disregard C completely.

In the past year that I started learning it, I was completely fixed on the idea that I wasn't going to use strings at all. I had (still have) the idea that with better functionality comes worse performance, so I always used char pointers (array of chars to represent strings), among other things.

After various questions and tutorials I've read around, I noticed how silly that was. In some (most, actually) cases the C++ classes and containers were even BETTER than my C implementations.

Now, the language has been upgraded to C++11, so there's a bunch of new stuff and I'm still going through the same thing. Should I use the new features, are they better? Are they worse?

I'll keep coding in C++, and I'll be slowly changing towards C++11 as I see these new features aren't so bad as I think (and I'm pretty sure they aren't).

##### Share on other sites

Since I doubt that I will realistically ever need the lower level and efficiency of c++, is it even worth it to try to learn c++, or would I be better off just messing around with c# and an engine like Unity or something of the sorts?

Is it worth it is a personal question.  Is it worth it FOR YOU?

Good game programmers will learn many languages. C++ is generally one of those languages. Other frequently used programming languages include Java, C#, Python, Perl, JavaScript, SQL, PHP, Ruby, ActionScript, and shell languages. Markup languages you will likely want to learn include things like HTML, XML, JSON and YAML.  Neither is an all-encompassing list. Some languages are good to know in depth, others will require just a cursory understanding; talented professional programmers will end up knowing twenty, thirty, fifty, or more programming languages over their entire career.

The order you learn them is not very important, although some are much easier to learn that others.

If you intend to work on game consoles and game engines you will need to know C++ before you get the job.  If you intend to develop any high performance software, including game servers, you will need to know C++ before you get the job.

If you intend to work on web games in JavaScript or Flash or Java Applets you might never look at C++ code.

Furthermore, since I'm already trying to learn C for scientific computing purposes, would it be better to just learn c++ for that since that's just a superset of C anyways?

Let's clear that up for you.

C and C++ do not have a superset/subset relationship.  There was a time in the 1980s right after C++ was created that you could run C code through a C++ compiler, but those days are long gone.  Any significant C code is incompatible with C++ code and will generate large numbers of errors in a C++ compiler.

Implicit conversions through void pointers, boolean values, tentative definitions, implicit casts, VLAs, designated initializers, and many other differences make code that is valid C not compile in a C++ compiler.  The simple act of making an object with malloc() through C idioms will result in a compiler error in C++.

C and C++ are different languages.  They had a common ancestor but diverged almost 30 years ago.

mostly to start learning it just because I'm a little curious about it and have the time.

That's all the reason you need.

##### Share on other sites

"me becoming employed at a AAA studio, and actually needing c++, is really unlikely to happen"

I dont work in the industry (Still a student), but I would have to say I disagree with the above statement.

I have no idea what your physics degree consisted of, but I guess you have a solid understanding of motion, forces, vecotrs, etc. In addition, you may have all sorts of maths knowledge which applies to 3D games / graphics / physics engines. At the very least, you will easily be able to learn the 3D math stuff - and at a *MUCH* better level than a student. Maths is a key skill in the games industry without a doubt. Mathemetics For 3D Games Programming and Computer Graphics by Eric Lengyel is a good place to start looking/comparing your skill sets.

Personally (as I did in formal education) I would start with C (Being able to make some console apps/games) and then learn C++. C and C++ are similar and most books dont go in to classes from chapter one (Unlike Objective C, for example, which is a class heavy language).

From their, the world is your oyster. You can apply your degree and aim to develop some physics systems. Can learn Direct3D/Open GL and go down the graphics route. Learn sound programming, networking, etc.

No Games Programming degree/Computer Science degree can teach everything. Mine teaches C++ and thats literally about it (and we have a decent employment rate within the first 6 months). The best games programming degree in the UK (Teesside if im not mistaken) hasnt tought any content that I havnt been able to do in 4/5 months of studying Direct3D11 by myself (And I would say that learning something yourself is more important than the degree - indeed, everyone I have spoke too says the first question in an interview centers around things you do outside of education. Plus, imo, teaching something yourself gives you a much more rounded knowledge whenever you finally get it. Uni has wayyyyy too much hand holding to be good for you).

My mate did Computer Science (Newcastle) and, well... I wasn't impressed tbh. Defenatly not for games programming anyway.

So yeah, why not? If your looking for a career change, then your not in a terrible position. Most junior jobs state that they are looking for people with "Computer Science (and games programming) or maths related degree" - You do have a maths related degree.

Finally, learning c++ and games related programming can take time to do correctly. C++ is a hard language. Its of course worth noting that learning C++ as a second language is MUCH easier than it being your first. C#/Java (I did objective C. But I'm a mini mac fanboy ) I have heard is a good start if you want another langauge first .

Edited by Dbowler92

##### Share on other sites

C and C++ do not have a superset/subset relationship.  There was a time in the 1980s right after C++ was created that you could run C code through a C++ compiler, but those days are long gone.  Any significant C code is incompatible with C++ code and will generate large numbers of errors in a C++ compiler.

CAVEMAN is 70,000+ lines of C code, compiled in MS Visual Studio C++ 2012, warning level 4 (to suppress inline-ing notifications), zero errors, zero warnings.

##### Share on other sites

The simple act of making an object with malloc() through C idioms will result in a compiler error in C++.

object, or just a buffer?

buffer works fine:



int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{

unsigned char *p;

nCmdShow=0;
lpCmdLine=0;
hPrevInstance=0;
if (!initprog(hInstance)) { Zmsg("Error initializing program","Caveman v3.0"); return(1); }

p=(unsigned char *)malloc(1000);
free(p);

titlescreen();
runprog();
Zshutdown();
PostQuitMessage(0);
return(0);
}


Edited by Norman Barrows

##### Share on other sites

would it be better to just learn c++ for that since that's just a superset of C anyways?

C and C++ do not have a superset/subset relationship.

For C++ to be a superset of C, then any valid C program must also be a valid C++ program.

Such is not the case. Earlier I listed just a few examples of things that are present in C that will not work in a C++ compiler. A web search can find many more differences.

Yes it is possible for people to use a constrained portion of the C language, add a bunch of casts that would be unnecessary in C but are required in C++, and write code that can compile in both.  But it is also possible for me to write functions that I can copy/paste into Java, C#, python, and other languages. That establishes that the languages are similar, but not that it is a subset.

For example, in that code listing:

p=(unsigned char *)malloc(1000);

That cast is not a C idiom.  There is no reason for a C programmer to write that cast.  It was written only to shoehorn the code into a C++ compiler.

Frequent variable names in C include "new" and "old", that would break in C++.  Occasionally when I work in C I will have names like "template" only to remember that the name is a keyword in C++ and shouldn't be used.

That's not to say you cannot write large programs that are constrained to work with multiple languages. With carefully-crafted constrained writing people have done exactly that. Just as people have also written constrained books like Gadsby without the letter E, or The Exeter Text that only uses the vowel E; yet you wouldn't claim that because of those books the English language does not have those vowels. Just because someone chooses to constrain their writing to a subset of the language does not mean that the properties of their constraints apply to the language as a whole.

##### Share on other sites

C and C++ do not have a superset/subset relationship.  There was a time in the 1980s right after C++ was created that you could run C code through a C++ compiler, but those days are long gone.  Any significant C code is incompatible with C++ code and will generate large numbers of errors in a C++ compiler.

CAVEMAN is 70,000+ lines of C code, compiled in MS Visual Studio C++ 2012, warning level 4 (to suppress inline-ing notifications), zero errors, zero warnings.

msvc++ will use a C89 compiler to compile any files with a .c extension (if you mix in c++ code it will most likely fail to compile, if you tell the compiler explicitly to compile it as c++ it will most likely fail, and if you rename the files to *.cpp or *.cc it will most likely fail to compile (unless you explicitly tell it to compile the file as C89 despite the .cpp file extension)

gcc will do the same thing for C,C++,Objective-C, Objective-C++, Ada and Fortran (Fortran most definitely is not a subset of C or C++)

Edited by SimonForsman

##### Share on other sites

That cast is not a C idiom.  There is no reason for a C programmer to write that cast.  It was written only to shoehorn the code into a C++ compiler.

so then i'm not doing c code, i'm doing c++ without the oo extensions? now i'm confused...

trying to remember when i learned c, and what compiler...

it was for school, systems i think, you had to write a vm, a compiler, a  linker, and a loader in C, and you had to learn C on your own. they taught you pascal and figured you could figure out the rest. kinda weird, because while there i was also taught stuff like forth, smalltalk, lisp, motorola 68000 assembler, fortran, cobol, god the list just goes on. worked out ok though, i got an A in the class.

ok, the C was on a sun sparc workstation running bsd unix and x11 windows. does that sound right?

and an Emacs editor, and GNU C (i think).

then for games, i switched from borland pascal 7 to i guess borland C (or c++ ?) v4 (?). then i switched to watcom. then microsoft.

but as i recall, i switched to C for games before the C++ extensions came along.

so would borland c 4.0 be c or c++ ?

seems to me i've been writing exactly the same code since i switched from pascal to C (++ ?) for games.   its not like the stuff stopped working when the c++ compilers came out. or perhaps they needed a mod or cast or two, been a long time.

Edited by Norman Barrows

##### Share on other sites

msvc++ will use a C89 compiler to compile any files with a .c extension (if you mix in c++ code it will most likely fail to compile, if you tell the compiler explicitly to compile it as c++ it will most likely fail, and if you rename the files to *.cpp or *.cc it will most likely fail to compile (unless you explicitly tell it to compile the file as C89 despite the .cpp file extension)

i use .cpp and .h, and in the compiler settings i tell it to compile as c++ code (for the stronger type checking).

• ### Similar Content

• I'm looking for any team / people that need a programmer for their project. I'm looking to expand my portfolio which you can see Here. I'm more experienced with Unity but I can spend the time to learn new Engines if that's your preference. I have worked on Unreal Engine 4 before but I might take some time to re-learn it, if the project requires it. Feel free to DM here or use the contact info on my website.

• I'm working on a system for my game that will allow the player to stack pick ups in a queue. As one pick up expires, the next automatically activates. I'm having an issue though where if I pick up the first one, it activates fine, but if i pick up a second directly after it, it overrides the first one, activates the second one, and then once it has run it's course, everything goes back to normal gameplay, no first pick up. I'm not sure why this is happening. Hopefully someone can spot what I'm doing wrong in my code.
Here is the code for the pick up manager:
// Update is called once per frame void Update () { if (pickUpQueue.Count != 0 && !pickUpActive) { pickUpActive = true; pickUpQueue[0].ActivatePickUp(); } DeactivatePickUp(); } void DeactivatePickUp () { if (pickUpQueue.Count != 0 && pickUpActive) { Destroy (pickUpQueue [0]); pickUpQueue.RemoveAt (0); pickUpActive = false; } } And here is the PickUp:
public override void ActivatePickUp () { ball.GetComponent<Ball>().Speed = 2.0f; //increase ball speed... ball.GetComponent<Ball>().StartCoroutine(timer); //...set time that power up is active }
There is also a Base Pick Up:
public void OnCollisionEnter2D (Collision2D collision) { Vector2 tweak = new Vector2 (Random.Range(0f, 0.2f),Random.Range(0f, 0.2f)); this.gameObject.GetComponent<Rigidbody2D>().velocity += tweak; //if the pickup makes contact with the paddle or ball.... if (collision.gameObject.tag == "Paddle" || collision.gameObject.tag == "Ball") { GameObject.FindObjectOfType<GameManager>().GetComponent<PickUpManager>().pickUpQueue.Add(this); Destroy(gameObject); //...and finally destroy power up object } } As a side note, I am trying to find a solution to this that will work for all of my pickups. Some pickups are ammo based, some are timed.
• By D34DPOOL
Edit Your Profile D34DPOOL 0 Threads 0 Updates 0 Messages Network Mod DB GameFront Sign Out Add jobEdit jobDeleteC# Programmer for a Unity FPS at Anywhere   Programmers located Anywhere.
Posted by D34DPOOL on May 20th, 2018
Hello, my name is Mason, and I've been working on a Quake style arena shooter about destroying boxes on and off for about a year now. I have a proof of concept with all of the basic features, but as an artist with little programming skill I've reached the end of my abilities as a programmer haha. I need someone to help fix bugs, optomize code, and to implent new features into the game. As a programmer you will have creative freedom to suggest new features and modes to add into the game if you choose to, I'm usually very open to suggestions :).
What is required:
Skill using C#
Experience with Unity
Experience using UNET (since it is a multiplayer game), or the effort and ability to learn it
Compensation:
Since the game currently has no funding, we can split whatever revenue the game makes in the future. However if you would perfer I can create 2D and/or 3D assets for whatever you need in return for your time and work.
It's a very open and chill enviornment, where you'll have relative creative freedom. I hope you are interested in joining the team, and have a good day!

To apply email me at mangemason@yahoo.com

• Is there a way to automatically change the start position of an animation? I have a bunch of animations set up on 3D models in unity. The issue is that I need to move the 3D models, however when I do so the animation start positions are not updated and I have to do it manually.

Changing the transform of key frames is time consuming with the amount of animations I have, so I was wondering if there was a way to do it automatically?
• By MoreLion
hey all! We are looking for members for our Unity horror game!
Here’s the story:
After a deadly virus plunges the world into chaos killing 85% of the human population there are now what they call “zones” these zones are watched very closely by the surviving government, people are checked every day for the virus, even if you touch the spit or any human waste or fluids of the victim who is infected, you will die. But one day, people in the west zone start to go missing, 1 woman goes outside the walls to uncover the mystery, is there more to the virus than meets the eye?, That is where your story starts.
This game is not a long development game, I have loads other game ideas,
I will also allow you to have a bit of creative freedom if you wish to add or share a idea!
And no, it’s not a zombie game lol I feel like zombie games are too generic, in this game you will encounter terrifying beasts!
There is some concept art one of our concept artists have made
If interested email liondude12@gmail.com

• GOVERNOR is a modernized version of the highly popular series of “Caesar” games. Our small team has already developed maps, written specifications, acquired music and performed the historical research needed to create a good base for the programming part of the project.

Our ultimate goal is to create a world class multi-level strategic city building game, but to start with we would like to create some of the simpler modules to demonstrate proof of concept and graphical elegance.

We would like programmers and graphical artists to come onboard to (initially) create:

A module where Province wide infrastructure can be built on an interactive 3D map of one of the ancient Roman Provinces.
A module where city infrastructure can be built on a real 3D interactive landscape.
For both parts, geographically and historically accurate base maps will be prepared by our team cartographer. Graphics development will be using Blender. The game engine will be Unity.

More information, and examples of the work carried out so far can be found at http://playgovernor.com/ (most of the interesting content is under the Encyclopedia tab).

This project represents a good opportunity for upcoming programmers and 3D modeling artists to develop something for their portfolios in a relatively short time span, working closely with one of Canada’s leading cartographers. There is also the possibility of being involved in this project to the point of a finished game and commercial success! Above all, this is a fun project to work on.

Best regards,

• So I have hundreds of moving objects that need to check there speed. One of the reasons they need to check there speed is so they don't accelerate into oblivion, as more and more force is added to each object.
At first I was just using the Unity vector3.magnitude. However this is actually very slow; when used hundreds of times.
Next I tried the dot-product check:  vector3.dot(this.transform.foward, ShipBody.velocity) The performance boost was fantastic. However this only measures speed in the forward direction. Resulting in bouncing objects accelerating way past the allowed limit.

I am hoping someone else knows a good way for me to check the speed with accuracy, that is fast on the CPU. Or just any magnitude calculations that I can test when I get home later.

What if I used  vector3.dot(ShipBody.velocity.normalized, ShipBody.velocity)?
How slow is it to normalize a vector, compared to asking it's magnitude?
• By Ds ds
Hi, my name is Andres, I'm a programmer with a technician degree and a Diploma in C#, looking for a project in Unity to start my career in game development. I don't do it for a paid but a recognition and start a portfolio, preferably a 2D game. Thanks for read, have a nice day.

• Hi there! Is the first time that I'm posting here so I'm sorry if I'm doing it wrong ha.
So here it comes, my doubt is, I'm doing a game with different levels, each of these levels in one different scene. Each scene contains to cameras that you can change pressing a button. Everything works fine.
The only problem is that I would like it to look a bit more professional, and I would like that if you finish the level with camera2, the next level start the same way. I've been thinking about using dontdestroyonloadon both cameras, but obviously this cameras need to be attached to the player to make the movement work, what do you recommend? Sorry If I've explained it in a messy way, and feel free to dm me for anything. Thanks in advance!

• Hello everyone
I am a programmer from Baku.
I need a 3D Modeller for my shooter project in unity.I have 2 years Unity exp.
Project will paid when we finish the work
If you interested write me on email:
mr.danilo911@gmail.com

• 48
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631374
• Total Posts
2999661
×