New to Unity: Question about actual C++ programming

I’m slightly confused about actually programming in C++ using the Unity Engine. When needed to program do you you just use a scripting language (javascript) or can you use C++?

Thanks for any help :slight_smile:

(Btw, I haven’t bought Unity yet, I’m still debating it)

You usually program in Javascript or C#. If you have a C++ programming background, C# will be very easy to pick up.

It is possible to write Plugins in Unity but you usually do that only if you really have to integrate some other C++ libraries or some extremely performance critical code.

The C# / Javascript side of things is fully integrated (eg. member variables get serialized and can be edited in the inspector) and has a much faster turn around time, which is critical for writing game code.

All right, thanks :slight_smile:
Too bad there isn’t C++ support :stuck_out_tongue:
I guess I’ll learn C# for this engine (and Javascript for that matter)

Is there a lot of actual programming involved, or is there not much need? (hoping there is)

The amount of programming involved depends on what you want to do of course.

What do you want to create?

An FPS (of the same genre as Halo), and probably much more further down the road.

Have you downloaded the program to try it out? I think you’ll find the answers to your questions by running through the tutorials.

I have, but haven’t had time to mess with it yet… But C# looks fine. It will be fun learning a new language :slight_smile: (If I can get the money for the Indie version)

Hmm, looking at this: http://developer.apple.com/games/gameenginesonmac.html

The Development language is C++, so does that mean indeed C++ can be used (only if the source is bought?)?

What I see in the Unity section is

and C++ is referenced

If you truely want to program in C++ for some reason I don’t know if Unity will be your cup of tea. You could easily write your specialized logic in C++ and use it as a plugin, but I am not sure why you would want to. Is there a reason why you just want to use C++? Using it comes with its own set of issues. C# would be easy for you. I tend to use the Javascript implementation since I can choose to dynamically type if I want to, usually takes less syntax to accomplish the same task, and I am not a strong typing type of person :slight_smile: By the way, the Javascript is compiled and has type inference.

Just saw the C++ reference you are refering to in the grid at the bottom. I believe that is only for the source license. I am going to guess that will cost a pretty penny.

In case it is not clear, you can use C#, Javascript, and Boo for more than just interacting with the Unity API. You have access to .Net and its classes, as well as the freedom to create your own classes and class hierarchies.

It there a very good reason to use C++ for you? C#/JavaScript/Boo are much nicer because: much faster iteration time (reload scripts while game is running, no long link times, etc.), garbage collection, safer (no pointers etc.).

And Unity can automatically build GUI for your scripts. Need a script snippet that does something with some texture? Just declare a public variable of Texture type, and you can assign the actual texture with GUI. Need to tweak rocket’s damage? Just declare a public float variable in rocket script, and you can tweak the value with GUI. Even while the game is running.

Some very valid points about iteration time etc.

Another one is C# is plug&play cross platform.
That is when you write your code you can rely on that it will run the same way when publishing for windows.

If you do C++ you will have to first create different projects in xcode and visual studio. Maintain them seperately. Whenever you do a change, recompile it on both machines. And then you haven’t even started dealing with issues where a C++ compiler is not implementing the standard correctly so you will need to spend some time getting it to actually work on both compilers.

On top of that it actually requires you to have Windows. Where as the C# way of doing it actually allows you to, click a button in Unity and it will create the exe with your game for windows. This way you don’t even need a Windows PC unless you want to test your game on a windows machine.

Trust me maintaining C++, a cross-platform code is a lot of work.
Using Unity’s C# or Javascript is the solution to this problem. So if you are writing game code, use C# or Javascript.

If you want to make a game like Halo, you will already have to spend a lot of time programming the game logic. Don’t make your life harder by using C++.

And on top of that. By using C# or Javascript you can publish a web player. The reason is that C# is managed code and can be verified to not execute harmful code like deleting files in the web player.

(The standalone player is of course not restricted in this way)

Yes, I was refering to the graph at the bottom. I want to use C++ because I know the language much better. Either way, I am going nto buy Unity, I don’t care that much if it doesn’t support C++. It will be a great learning experience for JavaScript and C# :slight_smile:

Btw, I didn’t know you were not limited to Unity API, glad to here you arent’

You’ll actually end up spending a lot more time on the specifics of using Unity’s functions anyway, rather than the syntax of whatever language you use, so the language itself isn’t as important as you may think. Knowing how to program at all (which you obviously do) is a lot more important.

–Eric

:slight_smile:

Yeah, either way Unity will be great!