.:: Alex Erne :: PHP/MySQL & Unity3D/C# projects ::.
Recent news
* advertisement *
  13 November 2016 - GEOvox and RPG project start :: Posted in Unity3D

I know it's been very quiet the last few months from my side, but that's because of therapy and meds kicking in (with extreme fatigue as a side effect). None the less, I am busy on things and one of them is creating a MASSIVE map with GEOvox for a (hopefully) upcoming RPG I'll be making with my brother.

The maps I'm creating at the moment is a dwarven hold, which will resamble one of the many landmarks from the pen-n-paper RPG we've played back in teh early 90s and which is a creation of my brother. Luckily he still has a lot of lore (on paper) available from that world and luckily I still had the 2D map (made with Campaigh Cartographer) in .BMP format.

While I do realize that RPG projects are one of the most failed gaming projects around, my brother and I both decided to give it a go and see where things will go. If for some reason the project takes to long or will fail, at least we did get a lot of experience out of it and can use it for future projects

Post A Comment! :: Permanent Link
  13 July 2016 - Implementing AdMob in your Unity project :: Posted in Unity3D

I've recently recieved an eMail from Google, stating that the Android Google Mobile Ads SDK will become obsolete coming September 15th. The AdMob SDK versions 6.4.1 and lower will simply stop to work from that data, and if you have used it in your projects (like I did with TetraGems), you will need to upgrade the AdMob handler to version 7.0.0 or higher. Sadly though, there's NO stand alone AdMob SDK anymore and it's been fully integrated into the Google Play SDK.

It's the Google Play SDK that does give some problems though. With the current latest version of the Google Play Services (rev. 31 in the Android SDK Manager) kinda missing in the package, you have to grab the SDK elsewhere. I've found a copy (rev. 28) on the Unity forums and will share it through my dropbox for your conveneince. The contents of the Google Play Services (rev. 28) needs to be copied into your Android SDK installation directory (C:Program Files (x86)Androidandroid-sdkextrasgoogle by default).

Next up you need to check a couple of packages that MUST BE INSTALLED in your Android SDK Manager. These packages are:
  - Android SDK Build-Tools rev. 23.0.3. I've read reports that rev. 24 is broken, and I couldn't get it to work either.
  - Android Support Repository
  - Android Support Library (Obsolete). I'm not 100% certain this one has to be installed, but the Google representatives keep hammering on the forums that it has to be there - odd though for an obsolete package...
  - Google Play services, even while it's not actually installed right now...
  - Google Repository

With the Android SDK Manager now setup correctly, it's time to download the Unity plugin for the Google Mobile Ads SDK from GitHub. I realize that there are enough alternatives on the Unity Asset Store, but I'm a bit reluctant to use those because you have no clue what's been done to those packages. With that, I've tried 2 free ones from the Asset Store and I could not get those to work, while the paid ones are just plain stupid when you can code it yourself!  Having the plugin, you now need to add this one to your current project (either double-click the GoogleMobileAds_305.unitypackage file or use Unity3D's Import Asset function).

So far that's all you have to do. Now all you need to do is add a bit of simple code to get the AdMob plugin to actually work and drop the advertisement on your app. And the code required is very small:

using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;

public class Create_AdMob : MonoBehaviour {
  string adUnitId = "ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX";
  string adUnitId = "unexpected_platform";
  public static BannerView bannerView;

  // Use this for initialization
  void Start () {
    // Create a 320x50 banner at the top of the screen.
    bannerView=new BannerView(adUnitId, AdSize.SmartBanner , AdPosition.Top);

  private void RequestBanner() {
    // Create an empty ad request.
    AdRequest request = new AdRequest.Builder().Build();
    // Load the banner with the request.

Now all there's left is create an EMPTY GAMEOBJECT in your scene and attach the Create_AdMob.cs script to it and you're ready to go!

A couple of notes though....
1) I haven't tested this on iOS since I'm not an Apple fan and don't own ANY (mobile) Apple devices. Please leave feedback if it works as well under iOS as it does under Android.
2) Obiously, the string asUnitId should hold your app's advertisement ID.
3) Do keep in mind that it's against Google's agreement to click your own ads! If you want to test your ads, replace the AdRequest request into

// Test device
AdRequest request = new AdRequest.Builder()

4) I've made bannerView public and static so that you can call it from any other routine and use Create_AdMob.bannerView.Show() and Create_AdMob.bannerView.Hide() so you can toggle visibility of the displayed advertisement.

There's a lot more to this plugin and all is described in it's official documentation. I just figured to describe the easiest way to make your advertisement work with your apps...

Post A Comment! :: Permanent Link
  23 May 2016 - Unity, Linux & MySQL (or the start of a persistent online world) :: Posted in Unity3D

Today I've been experimenting with the MySQL .DLL files, which can be used to allow the Unity engine to connect to a database. Of course, it's not recommended to let a client game connect to a database because of security issues. On the server side of things though it's not a problem, where the clients connect to the server side program, which in turn connects to the MySQL database and submits the results back to the client. This way there's no security risk at all, and (more importantly) will allow to creation of a persistant online world (either small scale multi-player game or even a MMORPG).

I've been thinking about making a persistant online world for a bit longer than the last couple of days (also see yesterday's blogpost). The bookmarks I've made on the use of (remove) MySQL servers are from the time I started working on TetraGems, back in 2013 already. But I never really did something with them because I had no use for a persisntant online world at the time. But ever since I've started on the d20 project, the thought about creating a persistant online world grew stronger and stronger. And with last week's first tests on client-server connections, the next logical step was to see how Unity works with MySQL...

One of the most important plugins for MySQL to use with Unity is not in the asset store, but discussed on the Unity forums. In fact, it's quite an old thread as well! Dispite this thread being so old and the .DLL files that come in the package are as old too, they still DO work with the latest versions of the MySQL databases. The only thing that bugged me of that plugin and documentation was that massive load of useless data it has. Okay, it's an example project where player data is stored, but that's not directly what I wanted to test. I wanted to see HOW it all worked with as few lines as possible. And being a certified PHP/MySQL programmer, it couldn't be that hard to get a simple piece of code going...

 photo Unity MySQL reading_zpst9v6omlk.png

And indeed it's not that hard to get MySQL going with Unity under Windows. I fired up my Wamp Server where I still have the old test database of the I am Blog project (BTW that project is dead now that I'm into Unity ) and I gave it a couple of tries with queries I took from the I am Blog code. First the simple ones and they worked flawlessly. Then a couple with nested queries and those worked very well too! Basically everything I've learned from the PHP/MySQL certification can be used in Unity as well. There is one problem though. Where in PHP you can easily process the code, in Unity distilling the data is less programmer friendly (at first glance I must add - I still have to dive deeper into it) and every query needs it's own.
...while reading this I think I could use a return(myReader) for the MySQLRead() method and process the data somewhere else, allowing me one reading method and different processing methods...

Under Windows it's all working, but what do you expect with .DLL files that originate from the platform..? How about using these .DLL files under the Linux version of Unity..? I copied the project to my Linux machine (which will become the server of my persistant online world) and the Unity editor accepted the code and .DLL files without a problem. The only problem though is(was) the lack of a MySQL server on the Linux machine.
With Wamp server being a Windows Apache/PHP/MySQL server, I was in need of something similar for Linux. I did find a couple of similar packages, but all required me to logon as root on Linux. And being still very much a newbee on Linux I had no clue how to solve that.

When I looked in the Ubuntu Program Manager I found a MySQL working space that'll visualize your databases, which is exactly what I need. I don't need some Apache server package when I only need a MySQL database installed. Of course, the MySQL database server itself is available for Linux as well, and installing those 2 solved my problems. After having meddled with theMySQL working space program and figuring out how everything works, I could import the test database and run the same code under Linux. Aside from a couple of import errors (somehow MySQL imports tables always in LOWERCASE) and chancges to my C# code, the output was the same as I had under Windows.

Now with both being able to use client-server connections AND work with MySQL under Unity, the next challenge comes: figure out what the best coding configuration for the server will be and how stuff is handled there for the clients. I don't want the client to have any checks of the game, but instead it has to get the data from the server...

[NOTE] I will make a full guide/documentation on how to implement MySQL with Unity later on this year (when I've figured out all the things to know of the DLLs included)

Post A Comment! :: Permanent Link
  22 May 2016 - Experimenting with clients & server :: Posted in Unity3D

The last couple of years (ever since I started to play Lineage II back in 2005 actually) it's been a dream of me to make a small-scale MMORPG, but I had no idea on where to start back in the days. That was before I discovered the Unity3D engine. Now that I've gotten used to the Unity3D engine, mastered C# and OOP to some degree it's time to start on that dream...

To get started on the dream, I've made a small client-server script earlier this month and I was able to establish a connection. Sadly though I was not able to send data between the client and server. Digging a bit deeper into the Unity documentation, I discovered that I was using the legacy instruction set that's no longer supported since version 5.1 (Unity is now beta-testing version 5.4).

So I had to dig some deeper into the multi-player components Unity3D supports and it seems that it's actually quite easy in the basics to setup a multi-player game with the new instructions. The guys at Unity have made a very well designed High Level API that takes care of everything you need. It allows regular player-side hosting and matchmaking of games (shooters come to mind) and I  guess that's the main reason for what it's been designed. But with a creative mind you can adept the player-hosting of games into a dedicated server that allows multiple clients to logon. And that's where the MMORPG idea starts to take it's form...

 photo Screenshot 2016-05-18 11.15.35_zps6rfwwnnn.png

In the above screenshot I've been playing a bit with the basic tutorial code and experimented with multiple connections on one PC and as you can see it works pretty nicely. There is one dedicated 'server' there (3rd from the right on the top row) and I have 26 clients connected to it. The communication between the clients and the 'server' goes pretty smooth (duhuh - it's all on one PC ) in performance it's not overly heavy on my old AMD Phemon II 1090T with 16Gb. That would imply that my Linux machine (AMD Phenom II 945 with 8Gb) should be able to host a dedicated server easily...

 photo Capture 20160522 0740_zps4walir97.png

The only problem remaining though is that every screen (inluding the 'server') is showing the same cubes. And while cubes don't take that much performance, imagine a server with 100s of players online having to cope with the full map and each and every textured player. That's mean that my Linux machine won't be able to keep up with performance, and therefor I made an other test.
In the above picture I've changed the 'player' in the Unity editor from a cube to a capsule to see how it'd behave on the server and other client. As you can see, only the Unity editor has it's apperance chanced and it stays a cube on the server and other client. And that's exactly what I wanted to make sure: the apperance is client side only and not broadcasted to the other clients.

With this knowledge I can make players, the game world and monsters/NPCs appear as they should be on the client, while on the server they will consist of only simple things like capsules and untextured structures that all have a collision box. This way I can keep the server running at maximum performance AND keep collision (and other checks) on the server side of the game to avoid cheating.

Of course, this is only the groundworks of my MMORPG. I still have a lot to learn when it comes to modelling and animating 3D objects and figure out how to use a database with Unity3D on the server side. And speaking of groundworks, remember the d20 project I've been busy on the last few months? It's still alive and I'll be using it (in a modified form) for my MMORPG...

Post A Comment! :: Permanent Link
  22 September 2015 - Back to 2dToolkit for 2 VERY GOOD reasons :: Posted in Unity3D

I know that a couple of months ago I said that Burst-a-Bubble would be my last project written with 2dToolkit and instead I'd be using Unity's native 2D. In the mean time I've made a start on that idea and I really have to say that I have to reconsider that thought for performance reasons. A performance that most certainly will be inflicted on mobile platforms, but also on PC systems (Windows, Mac and Linux).

 photo Screenshot 2015-09-22 10.28.39_zpskud6rnuk.png

Above is a screenshot made in the Unity editor using it's native 2D support and below is one made with 2dToolkit. I have enabled the wireframe for the 2D sprites and I've selected the active camera. As you can see there are 2 very significant differences between Unity's native 2D and 2dToolkit when it comes to both the displaying of sprites and using the camera.

 photo Screenshot 2015-09-22 10.29.14_zpshonralyd.png

As you can see from the wireframes, Unity's native 2D support east up a lot of performance on the screen. To make things even worst, all 3D settings also apply to the 2D game created this way. This means you have to manually override them in the settings but still the performance is not optimal then. Then try to imagine this worse performance on an Android (or iOS) machine that's a lot lower-end than most PCs and you can expect some lag to appear when you drop a lot of sprites on the screen.
Then the 2dToolkit wireframes. These are simple and display the as you've made it. You can still apply all those 3D settings to the game on a PC platform, but it doesn't affect the performance at all! Then playing the game on Android, this does totally not affect the performance at all. I have 2 phones (a Motorola Moto G 4G and a LG L5II, of which the LG is clearly a low-end phone) and the game plays smoothly on both of them.

When looking at the camera of both Unity's native 2D and 2dToolkit, the latter one clearly is superior. You can define your resolution as you want it to appear, while for Unity's native 2D you only can set (half) the pixels vertically (WHY?). When not in the predefined resolution will be scaled.
For Unity's native 2D it'll hold on to the set (half) vertical pixels and it scales on the horisontal axis. This means that calculating locations of sprites will become a real pain in the ass.
For 2dToolkit things stay very easy. First off you can tell how the camera will respond to other resolutions. You can set it to stretch, keep either horisontal or vertical axis as 'leading' scale or a couple of other settings I've never used before. Then dispite of the actual resolution, the main screen will keep it's regular resolution. This means in the above example where resolution is set to 1280x720 and the player will take an 800x600 resolution, the visual area of the game will still be seen as 1280x720 for displaying sprites. Anything outside that resolution is either negative (when below the pre-set resolution) or over 720px (when above the pre-set resolution). This makes screen editing a lot easier than Unity's native 2D!

Of course, there are a couple of uncertainties for me as of now. I want to use skeletal animated sprites created with either Spriter Pro or Spine. I fear then using Spriter Pro, the native Unity 2D wireframes will kick in because of how it's handling the sprites. For Spine I'm not sure though. I know it makes an atlas file like 2dToolkit does, but I have yet to make a skeletal animation and test how it responds. My guess (and hope) is that it'll not use the Unity native 2D wireframe but instead use it's own (better?) system...

[UPDATE] I've tested Spine and as expected it's using the same wireframe as 2dToolkit does. This means that eventhough Spine is a very powerful animator, it's taking minimal performance when displaying the sprites within the animations. Not sure though how much the animations will eat in performance, but I guess it won't be that bad though...

Post A Comment! :: Permanent Link
  19 August 2015 - Bullet Hell in preparation of RPG :: Posted in Unity3D

The last week I haven't worked on the d20 project at all, but instead I've made a start on a new (side)project to learn some more ropes in Unity3D. This side project is a Bullet Hell game, and while I'm no lover of that genre, it is the best way to get to know the stuff I need when making my upcoming 2D isometric RPG game (for which I've started on the d20 project )

I know it sounds odd to make a Bullet Hell game in preperation for an RPG game, but let me explain why it's not that odd...
The RPG game I want to make will be something like Baldur's Gate, where you walk across and explore the map. The best way to do this is not by moving the map (and everything on it) around, but instead move the camera (with your character locked inside that camera) over the map. And while walking across the map, everything that's outside a certain range of the camera will not be displayed at all. When you move in a direction, the items on that part of the map will be displayed (just outside the camera, only to be seen when you get closer) and everything you leave behind (once again just outside the range of the camera) will be destroyed. Of course, the plain basic map itself (like the blueprint on which everything is displayed) will not be created/destroyed, OR will be done so in real huge chunks.

Now the Bullet Hell game that I'm making is sort-of using the same principle of the RPG map that I want to make with the only difference that it's a side-scrolling game. This game has a lot of points stored in memory where certain things must be spawned (like enemy ships), which will only be spawned around 500 pixels outside of the camera. When these things move out of the screen on the other side, they will be removed around 250 pixels from the border. This way the performance of the game is assured to be at the maximum while I can make enormous levels with 1000s of ships that are out there for your blood

Though it's only a small (side)project, I'm not sure if I will make this game ever available to the public. For now it's more a learning project for me than something to make a finished game of. I realize I might get wild on it though and add more features and an actual story and then the Bullet Hell might become a real game for release

Post A Comment! :: Permanent Link
  11 July 2015 - 2 new projects :: Posted in Unity3D

I've just started on 2 new projects for Unity3D. These are not games, but more shells to be incorporated with games later on and that's exactly why I'm posting it here and not on the AE games blog...

The first one is the framework for a 2D scrolling camera with deadzones. It's meant for the player to walk along a large map (larger than the camera can who, much like walking in a city and you only see the current street you're in). Youc an move freely within the deadzone which has it's borders on 1/4th from the screen's end. As long as you walk within this deadzone, the camera is not moving, but as soon as you 'cross the border', you'll be at the end of the deadzone and the camera starts to move.

As you can see in the movie above, I've also made the clouds to move slower than the character. I thought I should add this feature for (possible) future platform games to emulate a 3D-view, much like the old Mario games (amongst others) already had included in their game.

Both scripts for this 2D scrolling camera are much alike and use the layer the sprite is on to determine the speed of scrolling. I will fine tune the whole thing to make movement with joystick to match the 'pressure' put on the stick to slow and speed up movement...

The second project I've started on is coding the 'Revises(v3.5) System Reference Document'. Though this might not say a lot, it's basically the d20 fantasy system as used in Dungeons & Dragons 3.5, which also was the basis for the Pathfinder Role Playing System. Since up to now there's no RPG system available yet for Unity3D, I decided it was time to print the whole thing and put it into code.

I'll aim to get this v3.5 SRD (both Fantasy and Modern) to be released for the Unity Asset Store and see if I can earn some money from it. Of course, I also want to release it for the Unity Asset Store to allow more developers to make RPGs based on the pretty well done d20 system (I know I'm not allowed to call it that, but that name is more known than v3.5 SRD )

Along with this v3.5 SRD I will also make a custom version for myself (which actually means I'm doing a 3rd project as well...). This custom version will be more skill than the d20 system is. I'm thinking to incorporate the skill system used in the Alternity RPG system. So far I think Alternity has the best skill based system ever made for pen-n-paper RPGs. Sadly it never got the attention it deserved AND Wizards of the Coast kinda let it die when they took over TSR

I know that incorporating a skill based system in a level based RPG might be pretty contriversial, but I'm pretty sure I can pull this off. Not only because I know both RPG systems pretty well, but also because I've played them both as player and GM...

Post A Comment! :: Permanent Link
  Page navigation
  Page 1 of 3 :: Previous Page :: Next Page
* advertisement *
* advertisement *

This website is Copyright © 2009 - 2018 Alex Erné
PHP/MySQL coding by Alex Erné Copyright © 2009 - 2016 Alex Erné
...all rights reserved...

AE games™ and the AE games logo are Trademarks owned by Alex Erné
TetraGems™, Burst-a-Bubble™ and the Burst-a-Bubble logo are Trademarks owned by Alex Erné