How hard is to move from Unity3d to custom built game/engine.

Hi there,

For past few years I have been working with game engines (GameMaker and Unity3D).
I have been coding in JavaScript and mainly in C#.

“So our routine is to add Model/Sprite to our project, drag it from Project to scene/editor and whoala, we have new GameObject, where we can write transform.Translate and move it and script it the way we like”

  • Now, After all those years, I want to to create game, that I know cannot be achieved in Unity3D the way I like. So I want to create game from scratch using C++ and OpenGL.

My Question is, to you guys who worked with custom built engines, or made the game from ground up without Unity, how hard and challenging would it be for me to move from GameEngine - to creating game from sratch without one? Or how hard was it for you?

Since from what I understand, there is no scene, no gameobjects, no components, no camera, nothing.

What is your experience with all this? :smile:

I tried creating my own game using C++ and OpenGL before I moved to Unity. I don’t understand why would you want to downgrade?

Because of the game I want to make. I need open world game, with a lot of AI. And yes this AI matters its not like in Skyrim that I switch off the guard standing there whenever Im more than 200m away.

But in Unity, the rigidbody2D takes up 50% of power with 200 objects. The Polygon colliders take up A lot of power too.
Where I can do 200 AI with the same mechanics in Unity,someone else can make 10 thousand objects with almost no performance loss in his OpenGL built engine.

But ofc it would be stupid to not use engine when I`m making android game or some shooter or whatever.

you will never, ever achieve that.

Unless you’ve been coding in c++ for AT LEAST 10 years, then maybe you’ll get somewhere, however the fact that you’re getting bad performance with 200 rigidbodies tell’s me you’re not ready for the challenge of writing a c++ engine from scratch.

6 Likes

I think it would be way easier for you to find a solution for Unity that doesn’t rely on rigidbodies or uses other workarounds, than to write your own game/game engine from scratch.
Just take into account the hundreds of people that work on the Unity Engine for many years now and try scaling this down to just a subset of the Unity features you need. It won’t be that many people, and it won’t be that many years, but it will still take you an enormous amount of time.

The single greatest ability of Unity is to actualize ideas faster than just about any other engine out there, and then you can get it to run on your toaster. Use an engine that requires you to recompile every time you make a small change in the code and you’ll figure out why some people like Unity.

ALL polygon colliders are like that though. I highly doubt you can find any engine that uses physics on that many objects though. Most of the time they are all using pathfinding tricks instead of actual collision detection.

1 Like

When I say “Game Engine”, I do not mean to develop software that makes games. I know what engines is, and that is of the most difficult engineering challenges in computer science.

  • I was rather talking about making game from scratch without using engine, but some people call it “engine itself”, what I meant was not engine as Unity engine, but to run, compile code and have game I built, or how that works.

Okay I maybe overstated that sentense. I am talking about 500-1000 game objects AI that move with rigidbody, rotate, check surrounding objects around them fire bullets, get collision from it, create explosion effect etc.

I have tried to move 2000 rigidbody objects. Adding polygon collider dropped FPS greatly for example.

What kind of game would have so many things active same time? your open world game running them all the time fully featured and always activated? thats not how open world games do them so it sounds like you are trying to give up on Unity cause of wrong design.

Simply put, very hard, there are some decent rendering templates out there which you are free to use. There are a lot of obvious benefits, extremely lightweight. I was surprised when I used LWJGL exactly how much you can get away with compared to pre-made engines, by the time I’d finished my crappy home brew engine demo it had 132 different segments and I really should of documented it because it was confusing as hell.

I’ve attempted (made) three AAA engines, by myself and it just NEVER ends… It’s one of those things you’ll have to attempt several times just to know how the engine should be modularised. Most of the math / concepts is out there to use already… But if you get stuck you’ll have to be able to do it yourself.

Only attempt it if you’re certain that Unity and / or any other engine has completely failed you. Having performance issues? Ask around and try other engines first.

You need Streaming / tiling and plenty of it :)…

I know, open world games deactivate AI, objects as player moves away from it, so Imperial City is “Winterhold” in Skyrim is deactivated in Skyrim when player is in Reach. I am perfectly aware of that.

But let`s take game like Sins of Solar Empire. You can have fleet up to A lot of ships, + small squadrons of ships.
And if you have other 6 opponents on huge map, the number of active objects, that run their battle in system you are not in, is very huge.

Yes, they have deactivated meshes, textures, they update maybe only every second frame, but they are there and they run.

And that is what I am trying to achieve, but only my advantage is I need this only in 2D.

Now I have full game working here, with procedurally generated galaxy, and ofc distant systems in which player is not in are “deactivated”, and I`m checking every few second that if ship has spawned in that distant system, I tell it to deactivate.

But even here I HAVE to have fully active surrounding systems, at least the ones that player can jump to any time. I want realisticly simulate battles, factions taking over another etc.

Unity is still probably your best bet. Things to think about…scale back the design when possible, and deactivate things when you can.

Example, just because you have 500 rigidbodies etc… going doesn’t mean they really have to be going. Example, the scripts themselves might be plenty fast, but you don’t really need to calculate the actual battles happening at certain distances from the player. So just calculate “simulations” instead. Heck, if you have things in other areas that aren’t even loaded, you can still do it once you do indeed load into an area. Look at classic Animal Crossing. All sorts of things happened while you were gone even though the console wasn’t even on. You can do something similar for things aren’t anywhere near the player. The player won’t know the difference I promise.

1 Like

Hmm maybe what I need is another, more experienced person just helping me a bit out. No, I have never worked on such a big project as now, so optimization wasn`t my concern. I have learned in Unity and in c# past month more than I learned in past year.

But when I hear from other game developer this:

" The galaxy I generated had 100 star systems, 200 planets and at each planet there is a 36 vs 36 ship battle taking place at exactly the same time. So in total there are 14,400 ships being simulated in full detail."

And he made it on notebook with 2GB ram and 50fps, now I wonder “I think 200 objects shouldn`t lag even with bad optimization”.

Just thought I’d mention something…the word “simulated” is being used there. It isn’t saying that you can see the battle directly. Rather, the code is doing it. Generally code can be pretty quick, though actually rendering things out maybe not so much. Also, I don’t see there that it is talking about full physics either, rather just simple battle mechanics, though I could be wrong about that.

If you had to make the graphics pipeline and the asset import pipeline, you’ve made an engine. It wouldn’t be an engine you could cleanly separate from the game, but it’s an engine.

I’m going to be the boy who cried bullshit on that and say none of it is being simulated anywhere the level of detail you think it is. I have no doubt it is being systemized and being reduced in complexity significantly to get those kinds of numbers.

1 Like

Okay maybe the video is better :smile:

This is a stress test he made. Yes there is 30 fps, but Fraps are taking 20.

https://www.youtube.com/watch?v=ZKxJgAIykhw

If you watch this, you will se the battles are actually taking place in real time, no simulation.

While all the battles are probably running at the same time, they arn’t all being rendered at the same time. He zooms in/out of sectors.

I doubt he’s using physics either which means you can do a lot more with less.

If you are a very very good C++ programmer and have many many time you can, if not continue using Unity.

In this video you see that only few battles are visible.
These are just some simple additions and multiplications.
You can run millions of them at the same time. You know how many ships shoot on what ship. You know fire speed and hit rate. You multiply that and know the damage. No physics or rendering or anything.

Of course in C++ you can run much more such battles in parallel. But you can create a C++ dll for Unity that calculates your battles if you really need any millions of them.

Yeah, as others already said,

  1. There’s no need for physics in this kind of simulation
  2. You’re only seeing one battle at a time
  3. He can greatly reduce the complexity of simulation when you’re not watching a battle directly

But I can turn off sprite renderer in Unity too, but it is the “Rigidbodies” collision update or Quaternion.Slerp or rigidbody2D.AddForce that is drawing the most power.

I can turn off Sprite Renderer, Audio Source, trail renderer on ships that are far away.
But things like this has to work:

//-------------------------------------------
Polygon Collider (Collision checking for bullets)
Rigidbody2D
AddForce in FixedUpdate
Quaternion.Slerp in Fixed update(this eats a lot)
Instantiate bullets
Check collision
(Check nearby objects around every 2sec)
//-------------------------------------------

These codes eat the processing power I need, And this stuff has to run, here, on other RTS games like Sins of Solar empire, even if the language is different. And with current CPUs capable of billion calculations per second. Come on.