blog:2020:0612_introducing_nervcode

NervCode: an innovating coding environment

I currently have an idea in mind that I starting to think could really be worth something. And thus, I would like to work on this idea a bit to see if this can bring me somewhere.

The base concept is simple: I want to write a game. But I don't want to write a “game”. :-)

Yes I know, the previous statement is confusing, and even self-contradictory from a ground level perspective… But we need to get a bit higher than that, and think about the actual meaning we have here:

What I really mean here is: I want to write a game, yes, I want to write some kind of video game… because I like the technologies around this industry: I like the 3D engines concept, the shaders, material, languages you can use to build video games, the fact that you can run video games on consoles, that you can do so much in a game with just a gamepad in your hands, the photo realistic rendering, the networking and multiplayer capabilities, the immersive sensation you can get out of VR games, and so on…

This is what I really like about games… but at the same time, I don't want to write a “game”, because, with time, I'm starting to realize that, I don't like “playing video games” that much. I think this is actually a bit sad, but I sort of “can't immerse” myself into the games anymore… Instead, I'm constantly thinking: “Well, great Manu, but the time you're spending here just playing could be use instead to build a game! Then you could sell that game and become extremely rich… and after that, yes, you could spend the time you want just playing video games, but right now, that's not a good timing: you just don't deserve it yet…

And, somehow, I think this is a fondamental issue with video games: people play video games because they can immerse themself into them, and “dream” for a while. But… if you think very hard about it: is there any concrete reason why you would need to play a game ? The answer is simply “no”. You don't need to play video games, you can live perfectly well without them, and the time you spend in video games will not bring you anything “that is worth it” in your real life. In other words, playing video games is just a lost of your time in some sense.

The moment you truly realize that, you're done: you won't be able to play as before anymore. Everytime you try, your mind will just start objecting you should really do something that is more important in your real life instead. And that's enough to cut your pleasure into pieces… snif.

So that's why I don't want to write a “game”, ie. something that people will play with, and then just discard, because they finally understand it's not worth it to spend more time on it. [And what's the benefit of that experiment afterall ? Zero. Nada. Nothing at all. All you can do is to tell your friends “oh, I finished that game the other day, it was really great.”]

⇒ No, definitely, what I want to build is rather a *useful application: something people want to use because it's helping them somehow in their real life. Do you think for instance people working in their office would write hundreds of documents with Microsoft Word, and then decide one day: “oh, well, it's not really worth it actually, I should get back to some paper and pen, that will save me a lot of time in my life” ? I really doubt it.

So, I believe writing an application (and not just a game built only around some “artificial values”) is the key: it has to be useful and provide some value in the real life. But we could still write a real application using the game industry technologies! This is definitely something I would want to do :-)

Naturally, the question that comes next is “What kind of application should I write then ?”. I've been thinking about this question for a long time already, and I have a few ideas in mind:

One could build an “game/application” where real money is at stake. I mean *not* just a game where you *only pay* to get some new warpon or outfit, but rather the opposite (ie. the attractive part for humans): games were you can receive real money thanks to your actions in the game itself.

You already have a few example of some “games” getting close to that definition: for instance some MMORPG where you may sell your valuable items to other participants and get some money back (but I'm not sure you can ever convert the “virtual credits” you will receive back to “real money”): but that's just a trick anyway from my perspective: you cannot “get rich” or even just make a living out of this… Simply because this doesn't fit with the “business model” of the game anyway: the game creators want you to pay for virtual stuff, not you to get money, so you can be sure there will be mechanisms in place to protect that model.

⇒ So, rule number one: if you are to make money in a game, it must be because this fits the business model of the game company: if they don't tell you “you can become rich playing this game”, then you won't get any significant money out of it.

So if such a game can work, where does the money comes from ? A game cannot “create money” by itself, so the money must come from outside. And I see 2 valid options for this:

  1. All (or some) gamers would regularly inject some money into the game,
  2. Some “clients” would inject money into the game because the gamers are producing some useful work for them.

In the first case, we could for instance design some kind of giant “lottery” game: every participant would inject some credits in a game session and the complete with the other participants to collect most (or all) of the credits the others injected themself to be allowed to play.

… But I feel such a game would be really stressful lol… Not something you will want to do everyday: I was already thinking games such as Rust were too stressful for me… So imagine if you put real money in the competition here: that will instantly become completely unfair lol beginners would keep hiding all time until they get kill and lost their credits while “giant whales” would team up to crush everyone on their path collecting more and more money. I've been thinking about this concept anyway, but so far I don't see how to reach an acceptable equilibrium here…

In the second case, we rather have a business as usual situation I think: some people are using some tools and with those tools they produce work and value, and clients are willing to pay to get the results of that work.

⇒ To me that option sounds like a more reasonable choice to start with: we could build a non-stressful environment that would help people focusing on the task they need to perform to get thinks done.

And thus, what I have in mind is.. to start with trying to build a software that would be useful for people like me (ie. developpers!): why not trying to write code from within a Video Game ?

I know this may sound crazy and counter-productive when you start thinking about it: developpers are used to they regular/simple text editor, writing code is a nightmare without a keyboard, “navigating” in code could be extremely confusing, etc… but still, in my guts, I have the strong feeling it could be something people will want to have.

I mean: spending your day working in your office in from of you screen typing code is boring most of the time… but what if you were rather building “visual structures” on a virtual island with the beach behind you and the sun shining above your head, and collegues also building other structures nearby, and those structures having some real value because these would be a representation of the code of some real application your company would sell ?… Wouldn't this be worth it ?

So, this is it. This is my idea. And I'm still looking for a better name for it but for the moment I will simply call this project NervCode

In some sense, what I intent to do here is to turn coding into some sort of “visual art”: you could build a function here, another function there, use them in class nearby, and all of these could “look nice”, so you could get some pleasure actually writing code :-).

As mentioned above, there would be many problems to fix to make such a system usable, but hey, problems are meant to be fixed, and when there is a will, there is a way! So let's not worry too much about these for the moment.

Instead, let's start thinking about what should be a basic elements we need:

  • We might eventually consider multiple languages, but to start with, I want to focusing on C/C++ code writing.
  • First thing first, we need to be able to write an “hello world!” program :-)
  • So, one of the key element would obviously be the possibility to write a Function
  • A function should take some input arguments and may provide an output
  • So we could for instance provide a representation of a function as a “box” in a 3D environment.
  • That “box” should have a name (ie. the function name)
  • And one could edit the function input list and/or output “type”.

⇒ Actually, this could be similar to the blueprint coding mechanism that one can use in Unreal Engine (except that we are extending this further to be able to write really arbitrary programs).

  • Writing text would be the complex/not fun part in this environment. So I'm thinking we could embed a voice recognition system users could optimize for their own voice, to spell names, or say custom commands.
  • And of course, the whole system would not work without a backend server: we need a server to store the “projects” that the user creates in a form that can be used to create actual code files.
  • Eventually we will need to be able to import existing sources in this project format.
  • At some point, the project should also support multiplayer: Many people should be able to work on the same project together, so we will need some kind of avatar in that case that other people will see in the virtual world.
One interesting aspect of things here is [I think] that humans are good at “building maps” in their head: when you arrive at a new area you don't know, at first you have no idea where you are/how to find your path, but if you spend some time in that area you start remembering landmarks that will help you quickly find your way. Writing code would be no different in that case: if you spend some time on a project, you will eventually remeber that the “networking classes” are near that big tree on your left, and that the “storage manager” is setting between the 2 large rocks on your right, etc etc: you could “build a map” in your head to help you navigate in your code.

First I think I should focus on the core aspect of this project, not the visual “details”. So I will start with a simple, empty world, with just a checker board plane as ground, and this virtual world should only contain the player camera that will freely move around.

Then I will investigate how I can just “create a function” with a simple box representation.

So let's get started!

I didn't mention it before, but I going to use Unity to create this project… I would really want to start from scratches, but at the same time, I want to go fast on the development, and eventually I would like to support multiple platforms (game consoles included) so starting from scraches would certainly take me too long anyway.
I also considered using Unreal Engine obviously, but generally speaking I feel that one is getting too big/too complex/too slow to develop (with C++ everywhere), so I won't take that path either for this project.

So, first question we reach when trying to create a new Unity project is: “what type of project should I create ?”, with Unity version 2019.4, we have the choice between: “3D”, “High Definition Render Pipeline” and “Universal Render Pipeline” (discard the other not interesting options).

NOTE: Projects that you make with HDRP are not compatible with the Universal Render Pipeline (URP). You must decide which render pipeline your Project uses before you start development; HDRP features are not cross-compatible between HDRP and URP.

Moreother, the previous page also states that:

HDRP does not support OpenGL or OpenGL ES devices.

So, bye bye “Android app” in that case… not so good :-S.

The Universal Render Pipeline (URP) is a prebuilt Scriptable Render Pipeline, made by Unity. URP provides artist-friendly workflows that let you quickly and easily create optimized graphics across a range of platforms, from mobile to high-end consoles and PCs.

⇒ So that sounds like what we are interested in in this case, so let's go this way.

The Built-in Render Pipeline might have been another reasonnable choice here since URP doesn't support “custom post-processing” yet, but I don't think this is too critical for me here :-)

OK. Project created.

I got a lot of “EBUSY” errors when creating my URP project, but continuously clicking “Retry”, and eventually got the project to start properly (? not really reasurring I admit, but we'll see…)

Next question is of course: “What is this new Universal Render Pipeline thing and how are we suppose to setup Unity projects with this ?”. ⇒ I should get back to the Universal Render Pipeline Overview page and try to read the sub topics ;-).

  • Reading the Features page I get the feeling that URP is still some kind of work in progress and is globally a bit more limited than the default built-in render pipeline. Which makes me wonder if it was a good choice to start with this…
  • And reading another unity forum discussion I now really feel I was a bit over-zealous and I should really stick with the defautl render pipeline for a while.

⇒ Conclusion: time to re-create the project as a simple “3D project” I guess :-).

Now that we have selected the regular 3D project type (with Builtin Render Pipeline). It's time to start building a very minimal scene:

  • Adding “a simple ground” is easy: we just use a Plane object for this.
  • Later I will add a checker pattern material on that Plane, but for now I will just provide a few cubes on it to provide some usable landmarks.

So we get the first NervCode screen capture ever:

first_nervcode_view.jpg

Great, but now, when we “play” the game I would like to be able to move the camera at least. So let's add a simple script on the camera to handle that. Done (Note: using the “nvFlyCamera” script I had in another unity test project)

Next thing is, I don't want the camera to go through the objects in the scene, so I need to add collision support. ⇒ So this means that instead of using my simple “nvFlyCamera” script I should use the mechanism similar to the RigidbodyFirstPersonController provided in the Standard Assets/Characters package. So let's retrieve that. OK

I got some minor problems at first when trying to use the RigidbodyFirstPersonController: my capsule/camera was getting stuck against the few cube models I placed on the ground. Eventually I figured out I had to change the ShellOffset value to a very small value such as 0.01 [and not 0.1 as indicated in the source comments: such a big value would freeze the controller completely on game start for me.

What I'm really dreaming about to be honest, is to be able one day to lay down on my sofa with a gamepad and write complex code directly from my game console… so clearly, I want the gamepad to be the default user input system. So, is this working already with the “minimal navigation system” I introduced above or do I have to do something about it ? Let's check that…

Hmmm… unfortunately, it is only partly working out of the box: I can move my camera controller around, but I cannot change the camera attitude. Let's see why.

OK: I added the following input manager actions and this did the trick:

gamepad_right_stick_actions.jpg

Now that we have some minimal navigation support I want to continue with trying to build the final application. Starting with the windows desktop application player. Let's go!

All right! Built went just fine and is working as expected:

windows_app_folder.jpg

Now let's move to the WebGL app…

⇒ All good here also: I uploaded the resulting project on my web server and I could then run the app without any trouble :-).

webgl_app.jpg

One important thing to note here though, is that the WebGL compilation/build stage will take “almost forever” :-) So you have to be really patient

I think this one is going to be slightly more tricky than the previous 2 builds… And indeed, first thing I get is an error because no JDK is found on my computer, let's fix that.

Hmmm, well, it seems that the recommended option is to install everything with Unity itself as indicated below:

unity_external_tools.jpg

And indeed, we can in fact install the required tools from Unity Hub. I already have them somewhere else on my computer, but just to be save, I will follow the recommended process and install the additional modules with unity hub directly.

Then I was able to run the build successfully, and this produced a 17MB apk file. Let's try to install that on my phone…

Hmmm okay, so it was a little bit tricky to install manually (because there are many user protection layers to ensure you don't install crap) but I eventually got the application to run :-) it's just that, I can only “rotate” the camera when touching the screen, not move it around or jump or anything else. [To be investigated later I guess]

So, let's say this is good enough for a start: we built a very minimal project on windows, webgl and android already so this is not bad :-) Next time I will start investigating how to create a few simple shapes from user command inputs.

  • blog/2020/0612_introducing_nervcode.txt
  • Last modified: 2020/07/10 12:11
  • by 127.0.0.1