Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ryf9059 · Apr 07, 2013 at 11:34 AM · beginnertutorialresourceswhere-to-start

How can I start unity fast with my C++ engine

I'm a programmer working on games. I just graduated from college a few month ago, and in particular my speicilisation is game programming (computer science branch), so I know a fair amount of stuff regarding programming games (architecture, coding, and stuff). Having been working on my own game engine for a while (a 2D side scrolling game engine) I decide to switch to unity which offers more potential and can save a lot of work.

PROBLEM IS: I have no idea about how unity works, excecpt for the claim that I hear from someone saying I still need to write a lot of code, which is fine for me. But I don't know where to start.

Apart from that. I have a 2D game engine written on my own in C++ that's already playable (features level loading and other manifest stuff, simple AI and physcis, operatable player by input, simple animation system using sprites, OS message handling, DirectX graphics, etc). And this is exactly what hesitates me from switching: I don't know how much overhead there is and I don't want all my previous effort to go wasted. Afaik, unity supports C# but not C++, it will be a lot of work to port all these code into C# (I don't plan to use Unity Pro now so by compiling C++ code into .dll is not an option). Despite all that, I don't even know anything about unity so i don't know if my assumption is plausible.

So my question is. Is there a fast way of starting Unity with the possible usage of my exisitng C++ code? (I could bare porting these into C# if I really have to) I'm only making a 2D side-scrolling game so it doesn't have to be that complicated. But I do plan to use lighting with my 2D textures. And what's the estimation of overhead for switching?

Thanks

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Unitraxx · Apr 07, 2013 at 02:04 PM 0
Share

A lot of the things you implemented for your engine are already in Unity, so I don't think you will have to port a lot of code. Almost all code you write with Unity has to do with the semantics/operation of your game, not the underlying architecture.

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Cygon4 · Apr 07, 2013 at 01:32 PM

It's a pretty widely scoped question, but I've come the same route, so maybe it helps if I cover those "A-ha" moments I've had :)

  • First, as a C++ programmer, likely the engines you know are code-first and if you want map editors with instant feedback, you have to write that for your game. Unity isn't totally different, but it already comes with an editor and puts it in front of everything else instead of confronting you with the code first.

  • It helps if you know component/entity systems (<- good google keyword) like Artemis. In short, in an classic engine, you'd have classes like Actor, Enemy, Wolf derived from each other. In a component/entity system, everything is a GameObject, the wolf would have a ModelComponent, and a WolfAiComponent attached.

  • The typical workflow is this: first you start a new scene and create lots of GameObjects by adding 3D models, lights and stuff to it. Then, when you want something to move, you attach script components to the GameObjects - classes derived from MonoBehaviour that you write in UnityScript or C# and which have a void Update() method where you can put your code to react to input, other GameObjects, etc.

  • Any public variables in your components become editable in the Unity inspector and are automatically saved in the scene. Most importantly, you can create public variables to hold other objects (`GameObjects` or components directly) that you can then drag-and-drop onto the inspector window and these references will be saved with the scene, too.

  • Another important concept are prefabs. You can pick any GameObject you've built in the editor, no matter how many children and components it carries, and turn it into a prefab. Prefabs can then be instantiated into a scene as often as you want. For example, you could create bullet with a Damage component and model, turn that into a prefab, then in Gun component create instances of the bullet whenever the player hits the fire key.

It only gets better from there with custom inspectors & editors, Mecanim and PhysX. You just have to re-learn your approach to object model design if you aren't used to component/entity systems, that imho is the biggest hurdle for a programmer.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ryf9059 · Apr 07, 2013 at 02:23 PM 0
Share

Thanks for the info! Actually I was co$$anonymous$$g from java first then moved into C++ so I know fairly well about the stuff you mentioned. I also get the idea of component/entity system, it's like a multi-layer inheritance thing as I used to read the source code for half life 2 and that's what they did. So we are basically writing script code in this case? Seemed like a lot less work than builing one from scratch like what I was doing.

avatar image ryf9059 · Apr 07, 2013 at 02:24 PM 0
Share

Also, can you build 2D game with the 3D editor? I still want to use the lighting and possibly some tweak with shading on 2D texture as well.

avatar image Cygon4 · Apr 07, 2013 at 02:44 PM 0
Share

Yes, it's more or less script code you're writing, though of course the scripts are first class citizens in Unity and you've got a full program$$anonymous$$g language with threading, sockets, using existing class libraries, etc.

I intentionally didn't write much about the 2D part of your question because I've never tried 2D. Lots of people seem to be using Unity for 2D games and there are kits in the asset store, but I don't know how well they interact with Unity's lighting or if they bring their own lighting system.

avatar image
1

Answer by whydoidoit · Apr 07, 2013 at 11:38 AM

C++ to Unity C# is a pretty big switch - they are syntactically similar but totally different in design principles and architecture. C# is a .NET language that has a very different approach to memory management when compared to C++, plus a zillion other differences really.

If you've already built an Engine, don't consider trying to port it - there would be little point - you'd be fighting the opinionated nature of the Unity Framework. That said, you will find so many useful things in Unity that it is certainly worth building games in it and extending the framework that exists to encompass your techniques. It would be a decision to start again though in my opinion.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Apr 07, 2013 at 11:40 AM 0
Share

You can buy massively high performance 2D plugins to Unity for a few dollars too - it hardly makes writing one worth it except for the experience of doing the work.

avatar image ryf9059 · Apr 07, 2013 at 11:46 AM 0
Share

@whydoidoit I have pretty solid skill with java as well, is C# similar to java in terms or memory management? Also, if I try to start again, what will be the good source for me to look at providing I already have program$$anonymous$$g skill and is only making 2D games?

avatar image whydoidoit · Apr 07, 2013 at 11:52 AM 0
Share

Yes now C# is much more similar to Java in terms of design principles and memory management - yep.

avatar image whydoidoit · Apr 07, 2013 at 11:53 AM 0
Share

Well there are a bunch of tutorials out there - worth Googling - I don't have an immediate go to source for that. I strongly recommend using 2D Toolkit anyway - and they have some good tutorials.

avatar image ryf9059 · Apr 07, 2013 at 02:47 PM 0
Share

Thanks for the info!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

First time using unity and have no idea on how to get started 3 Answers

xpecting (, found 'OnGUI' 2 Answers

Making my first game? 3 Answers

What to start with when using Unity 3? 6 Answers

How long as a rough estimate, does it take to have a good knowledge of unity? 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges