Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
0

WordPress for Unity

A topic by myBad Studios created May 09, 2018 Views: 4,129 Replies: 31
Viewing posts 1 to 20 of 32 · Next page · Last page

Hi All. 

I just published my first ( of many :D ) product on Itch.io and it's something that I am super excited about. For the past few years, in between contract jobs, I have been building up a collection of features that bring WordPress into Unity games and the other way around.

Initially I was very proud to be able to say that all my assets required 0 configuration on the server end. Just install the plugin in WordPress then get back to Unity, drag a prefab into the scene and hit play. Done and dusted. As time went on, though, not only did I start giving people server side options but I also started adding code to build their websites for them!

So at this point I can generate your game's website, let you use the website login details to log into your game, let your game use the website's database for whatever you are doing, automatically make all games cloud based and cross device synced, then let you put the game up for play on your website but require that people buy it from you directly on your website first and then I go and prevent them from pirating your game on top of all of that. Just check out the product page to see all the currently included features.

This system has come a very long way from just logging you in and saying "You are logged in. good luck with the rest of your game!" and now it is available on icho.io in a "Buy everything I've done so far and get everything I will ever do added on for free"-version. I also include a full game template with all the assets integrated already so you can see how to use them in practice, not just in theory!  :D

I hope you guys like it!

Ryunosuke

P.s. in celebration of my first product on itch.io I am giving away 10 copies of THE Dialogue Engine to the first 10 people to buy this asset. THE Dialogue Engine was the first dialogue kit to be released for Unity, released almost a year before the Asset Store was created and still going strong. It's features are way too many to even list on it's own product page so I won't even attempt to list them here :D 

https://mybadstudios.itch.io/wordpress-for-unity


Admin

This is interesting, does that put a web browser inside of a unity game that will show the wordpress website, or does it work in another way?

(2 edits)

No, this is not a web browser for Unity. This is a means of directly connecting your Unity project with the WordPress database via the WordPress API. This means that you use Unity to create your game as normal but you use WordPress as a means of identifying you for logins, store your high scores and save game content etc directly to your WordPress database.  

This essentially means that all your games become cloud games since you can start playing on your web browser at work, continue playing on your phone while on the bus and then at home you can continue on your PC. Your progress, achievements, high scores, unlocks, everything is automatically synced since everything saves to one location and everything fetches it back from there again.

You can see an example of it in action here: http://guild.site/bad-dreams 

It's a free-to-play game that showcases how this asset logs you in via WordPress, displays your actual Gravatar avatar, stores your score and a leader board, has a shop where you can unlock stuff and then save your unlocks / upgrades / stock / currency online. Also, the kit includes virtual currency and obviously that is showcased also. Kill zombies, get cash, spend the cash to upgrade your weapons, get more cash for killing more zombies more easily, upgrade some more :D

I struggled to figure out how to showcase the serials and anti-piracy stuff since using it means you simply cannot play the game if you didn't pay for it... and yet I wanted to make this game free to play. So I used the third mode of the serials kit instead. Instead of forcing you to pay in advance or after a few levels I leave the game free to play but I give you in-game advantages IF you actually went ahead and bought a serial via the WooCommerce integration I added to the kit. Yes, you CAN buy virtual currency for the game via my WooCommerce store, sure, but that's optional. Just wanted to showcase that.

Then there are the achievements you can unlock and the candy crush style "you have 5 lives. If you die it will take 30 minutes before you get another life. Come back later" timers on display as well. All of this running on a WordPress back end with a Unity front end. 

This, of course, means an entire array of options that can be set via the WordPress dashboard. Each individual part of this kit has it's own configuration tab under the WUSS main menu and allows you to do all manner of things. 

For one, it lets you see exactly what data any player has stored on your server and allows you to edit or remove it. Remember: install once and then you can run as many games as you want off of this single website. Now imagine you have 3 games and 100 players each and all their progress and unlocks etc is saved to your site. Via the dashboard you can view and edit that info per user as and when required.

On the flip side of the coin you can also save game data for other users to use in game. Examples may include chaning how many hitpoint an enemy boss requires to be defeated or how many coins you get when you unlock chest 3 or what character is unlocked when you reach spot x or where spot x is, even. Stuff like that can be edited after launching the game and all changes are live instantly and don't require the game to be downloaded again for your updates to take affect.

Another nice little feature is being able to kick or ban a user from being able to log in to the game. Just click on ban to ban and unban to unban. One click. Alternatively, set the days, hours and minutes to kick the person off the game for and their status is automatically restored when the timer runs out. 

Generate serials for physical copies sold in stores, one click. Generate serials to use with WooCommerce sales or to hand out manually, one click. Assign a serial to a user/ friend/ whoever, one click. Revoke the serial (you guessed it) one click. View all available serials per game / view all allocated serials per game / view all the games a specific user has a serial for... check, check and check.

And then of course there is the WordPress shortcodes that generate game posters, banner links to product descriptions, shows the currently logged in person's status (banned or good standing) for the game, the leaderboards (also available as a widget).  Check out the available shortcodes here: http://mybadstudios.com/wordpress-systems/wuss-portal/

Not shown there is the shortcode to display your WebGL game inside your WordPress pages / posts. To show Bad Dreams, for instance, all it takes is this [wuss_webgl name=BadDreams height=500] and that is that.

Truly, as I said a few paragraphs back, WordPress for the back end and Unity for the front end. :) The stuff listed on the product page is the features available right now but there is a heck of a lot more coming including a friends system, PM, something similar to a FB wall, an online auction house to allow users to sell/auction off rare in-game items between each other... just to mention a few.

This is what this kit is all about :)

(1 edit)

Some more control panel images





Creating a new game in WordPress...

One example of how you can present it to your site visitors...

After they clicked on one of these to get to the product page:


Pretty nifty idea!

Thanks :)

Glad you like it! :) I tend to update this quite regularly whenever I have a brainstorm moment. I'm sure there are a number of features I forgot to mention but that probably wont matter much since there will likely be new features added before I discover which ones I forgot :P 

I posted this one first as it includes everything current and future all in one so I definitely believe this to be the best value for money option but as soon as I am done with the asset I am busy working on I'll start posting the individual assets here also so people can get only the features they want and pay significantly less for them than buying absolutely everything in one go. That should allow people to ease into this system more gradually but eventually that option will turn out to cost more so yeah... Start with the best option then add the more affordable ones afterwards :)

My goal is to stop using the Unity Asset Store and sell content from my website exclusively but the one advantage they have over me is traffic. Itch.io offers me a solution to the traffic problem so I plan on releasing everything on here (assets and games) so if you are not following me yet, consider doing so cause there is a lot of content coming :)

Hello,

I'm interested on connecting a game with the WordPress database and I think that your product will be very useful for that goal. But first I need to be sure that will fit my particular needs. For that reason I have a couple of questions for you:

Is your content working with the latest version of Unity?

Your WordPress - Unity integration includes the source code?


Thank you in advance for your help!

Hi Diego

Thanks for the interest. Let me try and answer those questions for you...

1. All my assets require at least 2017.3 but it works just fine in all versions of Unity after that. Basically,  as long as you use .NET 4 (i.e. set Scripting Runtime Version to 4.x in Player Settings) then you are good to go.

2. Source code? Absolutely. I have never distributed a single DLL in all my life. Full source, always. :)

Check out the WordPress myCustom product for a free sample. It won't work unless you have the Login kit installed but at least you can see for yourself how the code is distributed. Unity code, Server code, Dashboard code... full source included for all of it. :)

Hi MyBad - I'm interested in using this approach also - I'm looking into writing a CMS that a pc unity build uses to display updatable info at a museum kiosk.  If you've already done it I'd love to try it out.  Will the unity plug-in be back in the asset store sometime soon ? or does it no longer required any kind of unitypackage ? ok thanks  :)

(2 edits)

Hi mate.

Sorry to say but myBad Studios is no longer on the Asset Store. All the assets still work as before and everything is still the same as always... the only difference being all our assets can now be found only on our website (mybadstudios.com ) and on here.

None of our assets will be released on the Asset Store ever again. Existing Asset Store customers can download updates from our website but the Asset Store and us have gone our separate ways.

As for not needing a unitypackage any more, well, the login asset has a pretty comprehensive all-in-one ready made prefab that you can just skin and use as is... or redo completely, as you see fit... but the WordPress plugin is not dependent on Unity to work. As long as you send it the right params when you call it and you have a CML parser to parse the results then these kits can in fact work on any platform. Considering I have only written a CML parser for C#6 that limits the additional platforms to .NET platforms(I'd think. Welcome to prove me wrong! :D ). Sooooo, technically, no, it doesn't NEED the unitypackage (just the WP plugin(s) and the CML parser)... but the Unity prefab(s) sure speed up getting started... :)

Thanks for reaching out. :)

@myBad, I'm interested in your Wordpress login plugin but I was curious about 2 things:

1. How come you are not going to be on the Asset Store anymore?

2. How do you compare Wordpress as a database vs Google's FireBase, Amazon Cognito, or Playfab? Wordpress seems to be an uncommon way to authenticate users but it's interesting to us because we already have a Wordpress site for content creators (our application has user generated elements). Is Wordpress database performant at millions of users?

Hia

1. Unity and I had a falling out. They screwed up, my customers paid the price, I demanded they let me serve my customers, they demanded I leave. That is the short version. Everything I've created for the past 6 years all run on MBSCore and after the latest update they accepted I realized that I accidentally slipped in two bugs that broke the kit. I tried to fix it asap but Unity simply refused. Months went by during which I contacted numerous people via numerous media numerous times but the asset store vetting team kept refusing the update without giving a reason beyond "Something is wrong with something somewhere in the asset. Find that and fix it then resubmit". Not very helpful, is it? 

When I asked about this I simply got no response from anybody via any medium any time for all the weeks of trying... I said "The core of all my assets is broken. My customers are sitting with a broken asset for weeks now. You won't tell me why you reject the fix... what am I supposed to do?". The first response I got was "We have closed your store and all your assets have been removed". 

This resulted in everybody loosing everything they ever got from me during the last 8 years (including free assets) with 0 option to download it if they don't have a local copy still and 0 chance to get an update if they have an old copy. After 7 weeks of enough complaints from enough people they finally allowed people to download the latest versions of the assets they paid for. Isn't that nice of them? Unity also took only 2 months to finally get back to me regarding my emails saying "I keep getting emails from people asking me why the assets were removed and if the assets are no longer being supported or what. There is lots of confusion out there. Can I at least update the meta data to tell existing customers they can still get updates from my site?"... They agreed and let me do so... for everything except the broken asset and the turn based battle kit.

To this very day the asset you can download on the asset store is broken and to this very day Unity has made 0 effort to tell people this and they refuse to let me fix it, instead sending me emails that read (and I quote) "We are not interested"... So yeah, a few customers have asked me to return to the store and one literally begged me for days on end to return to the store but (a) they don't want me there and (b) with that level customer service I  don't want to be there. 

For the past 8 years almost all my reviews reviewed my customer service along with my assets and I got reviews like "I don't know where he finds the time to help me as much as he did", "He delivers the best customer service I have ever received on or off the asset store" and even "His support is so good that you should buy his asset even if you don't need them"...  For the past 8 years I put m customers first to the point where I would go to bed at 2am, receive a customer support email at 2:30am and get up to go reply. Like the Japanese say: "Customer is God". Customer first always... Yet, on the asset store I uploaded a broken asset at around August/September-ish and on the very next day I noticed the bug and sent an update to them the same day! It's been almost 6 months and Unity still hasn't even bothered to tell any of my  customers not to use that asset (that is at the core of everything). Me/ It took me less than a day to have a system up and running where all existing customers could download their assets from my site without having to pay for it again... Unity "are not interested" 6 months later in telling their customers that the asset on the store is broken... 

With me placing the customer first and THEM forcing ME to give the customers bad service simply by blocking me from getting updates and bug fixes to my customers... that is not a place I want to be on. Get the products from me, get updates within seconds after I created them. Compare that with Unity's "we are not interested" attitude and yeah, I have no interest in being on there...

2. How does one technology compare to another? I honestly can't say. I haven't used the others so I don't even know how well they perform on their own, let alone compared to one another. :( 

The reason why I decided to go with WordPress was because i had created a very very, very simple login kit using vanilla php and mysqli and that asset sold like hotcakes for months... yet apart from saying "Yes, this username and password match what was stored back when the account was created" the asset didn't do anything else. By adding WordPress to the mix I was able to make use of their security features and user tracking across server contacts (i.e. I didn't have to send the username and password along with every single server contact and re-authenticate the user with every single contact) and also, thanks to the WP codebase it meant I could very easily add loads of new features very easily.

Working with WP was both fun and offered great flexibility.  I fell in love with it, simple as that :D 

As for how well it performs, well, like I said above, Unity calls WP, WP does stuff and send back a custom text response instead of generating an HTML page (using the themes and templates and all that stuff) so from Unity's end there really isn't much going on: Contact the server, wait for the reply then do something. On the WP side of things, that works like WP normally works (except it doesn't generate the HTML output) so if your question is "How well does WP perform for a busy site with millions of people?" then you need to contact the WP guys and ask them for those figures cause that sounds like something they might know... from my end, using my kits is 100% the same as making people visit your website.

  • Considering 26% of the entire internet runs on WP I would assume it doesn't do a bad job, though ;) 
  • I myself was curious about all the SQL queries WP runs and how it will affect performance so I spoke to a DBA who all but laughed in my face as he told me that mySQL can easily run hundreds of thousands of instructions at the same time so no way would I be able to create a tool that will break SQL... So, basically, subject to things like record locking, of course, it seems me thinking my kits will break the website is akin to me having an ego the size of the moon... apparently ;) :P
  • BUT, having said all of that, there is one very important thing to note! Since this works like a web page this means my kits are meant to be used passively, not for real time games. I.e. Login in now, fetch the player data a second later, submit a high score every 5 or 10 minutes, save the game data whenever he reaches a save point and click's "Yes, please save" then wait for the server to say "I'm done"... do NOT try and save player position and rotation 50 times a second. That will absolutely NOT work!!!

If you want to use the kits for use with multiplayer games like shooters or MMOs etc, the by-the-frame updates will be handled by your server application but the data itself... well... thisi s where my kits get interesting. :D MBSCore (The broken asset of the Asset Store) has a class called CML which runs everything in all my applications. CML is like XML on steroids with loads of search and filtering functions that allow you to view your CML object as an in-memory database... and i mean that in every sense of the word. Every single CML object can contain any number of "tables" if you care to go as complex as that, otherwise you could simplify your life and use one CML object for each table.

The key thing to keep in mind here is that when your player logins in, you contact the server to fetch all his data. You then keep that data in memory inside that CML file and use that single object for all your game data (achievements, inventory, game settings, position, rotation, quests, whatever you want) and whenever the player reaches a checkpoint or whenever you feel like it you just send all or parts of that data to the server to say "Track this for next time" and then don't even bother with the server result. Send the "store this" command and continue playing. Next time the player logs in after starting your app, all the data is fetched again and you use everything from there. (You don't HAVE to do it this way but I tend to do it this way as it makes sense to me to do this).

What this boils down to is that your players log in and then don't contact the server very often after that... so will millions of players that only contact the server every few minutes kill your server? I doubt that but, like i said, I am not the expert in THAT particular department. All I can do is make an educated guess based on my understanding of the kits and the DBA who laughed at me when I asked if my kits could kill the server ;) 

Hope that answers your questions :)

(1 edit)

P.s. for examples of how CML works, visit my website at https;//mybadstudios.com and visit the product page in the store. Since leaving the Asset Store I updated the site quite a lot and products now contain Tutorial and FAQ and other tabs to give people a better understanding thereof. MBSCore has quite a detailed demonstration of how CML works.

Quick recap:

  • In-memory database
  • Search and filter functions
  • Runtime strongly typed variable generation
  • When compared to a database you COULD have multiple "tables" inside a file since each one just needs a node to mark where it starts and then you just add your rows under that
  • When comparing to DB tables, CML "rows" do not need to have the same  cols for every row. Each row can be as unique as you want it to be
  • Technically speaking, each "row" could be a separate "table" if you want it to be. CML absolutely supports nested tables within nested tables up to infinity deep (or int.MaxValue, at least :P )
  • Safely access data that is not stored in the "row" without runtime errors. CML will return default values by type thus if a variable has the default value for that type you don't even have to bother saving it to the database. This applies to all supported typed: int, long, float, Rect, Vector2, Vector3, Color, Quaternion, string
  • Save anything that you can turn into a string (including base64 encoded binary files)

As you can see, quite a nifty little class to have :) See the product page for sample code to see just how insanely easy this is to use and why you will never want to use XML ever again after trying this! :D 

Sounds like you're the guy to talk to when it comes to all things Wordpress/Unity. Funny how Wordpress powers a huge amount of the internet, Unity supposedly runs over 50% of the indie games and yet the universe of folks who have a login solution for the 2 services is you. Well we're grateful and will almost definitely pick up a copy of the login system tomorrow morning. Quick question on compatibility. We're game adjacent and so we're using a variety of SDKs to manage third-party services which makes it difficult to upgrade (we're limited by each SDK providing support for the higher version of Unity). As a result we're currently stuck on 2017.2.  Is there any way you solution will support that? I noticed in your changelog something about 2017.3 being required for future updates. Does that still stand?

You can try and install it into 2017.2 but I can't guarantee Unity will play nice. The only problem you might encounter is that the prefabs will be broken. I include a demo to get you up and running but by no means are you FORCED to use it. I specifically isolated all WordPress functionality and GUI stuff from one another so that you can use any GUI system you want and create a GUI to suit your taste so, again, by no means are you being forced to use the prefab I include... but having said that, the thing is pretty darn comprehensive and even goes so far as to localize the entire login kit into 4 languages and auto detect the presense of additional assets and expose login preferences for them if found... If you have to create it from scratch you'd be losing out on a lot. Fortunately, the code will still be functional so you can easily recreate the entire thing by just dropping the scripts onto the right objects and dragging the right stuff to the right field. Easy... just very tedious and mind numbingly boring work... That is the only problem I predict might happen if you install the asset into 2017.2...

As far as the code is concerned, that will work just fine in any version of Unity that supports .NET4. So here is what happened...

I created the kits for Unity 4 and it worked perfectly fine since day 1, never requiring any fixes as new versions of Unity was released. The only reason to ever download a new version was to get access to new features. From Unity 4.... right up to 2017.2. Then came Unity 2017.3 and they broke the WWW class. Using Debug.Log you could clearly see they leave one of the mandatory headers empty but they still maintain "We didn't break it. We didn't", even though the facts are right there, staring everyone in the face... So what did this empty header mean for my kits? Simple: I can no longer contact the server. The server always returned an error because it wanted that header (the header tells it how long the header info is so since the header.length value was always blank WordPress couldn't process the request). So, yeah, no biggie... :( Sigh...

As it is, they said that the WWW class was just a wrapper around the UnityWebRequest class and eventually they want to get rid of the WWW class completely so I figured that since all my kits are now completely broken anyway, now would be a good time to change my code to work with UnityWebRequest and so I did that. At that point, though, since I was now forced to create a new version for 2017.3 and later I figured, well, since C#6 is as awesome as it is and 2017.3 supports it, why NOT update the code to require it? And so that came to pass...

Thus... the code now uses the alternate version of internet access, the version Unity prefers us to use, and thus it should work just fine in any version of Unity that has the UnityWebRequest class... BUT I made .NET4 a requirement so that is the only REAL restriction on what version of Unity you can use the CODE with. I am not sure what version of Unity they first introduced .NET4 in but I think it was 2017.1 so the code should work just fine in 2017.2

The ONLY problem here is that Unity does not allow you to install assets made in one version of Unity into another version of Unity that is older than the other one. For models and scripts etc it won't make much difference but for prefabs and materials they tend to break them completely. By completely I mean you will see the folder structure of the prefab in the hierarchy but all scripts on it will be missing and the entire thing is just.... well... broken. 

As a general rule of thumb, if you get something in, say, 2017.3.15 and you try to install it into 2017.3.0 there is a huge probability that it will work just fine... but if you get something in 2017.3.0 and try to import it into 2017.2.x the chances are huge that it will break the prefabs. :( Unfortunately the only way to know for sure is to install it and see... and if push comes to shove then I can just send you screenshots of what the prefabs should look like and you can just recreate what you see from that... that is basically the worst case scenario I can imagine...

Nothing wrong with my code... just issues with importing .unityasset files into incompatible versions of Unity

We ended up upgrading to get ready for your plugin. We have a Wordpress website that we use for folks that want to create interactive stories and a mobile app (made with Unity) for the players who want to consume these stories.  Do you know if there's any way to differentiate the registrations from the website vs your Unity plugin? Ideally I would like to sync these users a little differently.

Hmmm..... the entire point of this exercise was to make the distinction be as invisible as possible so this is not something I've ever thought about. But now that the question is raised, I DO use WordPress's own code to actually create the accounts and everything BUT I do so inside a function I created as part of the plugin. All you would have to do is just open up the unity_functions.php and find the loginRegisterAccount() (or something similar) function, read through the code till you get to the part where I have verified the login and say everything is now fine then just add this:

      update_user_meta($current_user->ID, "unity_registration", 1);

Now, inside Unity you can check to see if the account was created via the website or not by adding "unity_registration" into the meta fields array and after login just check for either:

if (results[1].Int("unity_registration") > 0) or if (results[1].Bool("unity_registration"));

On your website, though, I don't have access to any of your plugins, obviously, but since you just added a simple usermeta field during a registration made via Unity you just need to update whatever scripts you are writing to just check if that usermeta field exists and if it's 1.

if (get_user_meta($current_users->ID, "unity_registration", true) == 1) echo "WoHoo! Unity detected!";

I think that should do the trick, no?

By the way, just some food for thought... Since my dialogue engine comes with a Visual Novel prefab I have been toying with the idea of creating a Visual Novel game for my website. Thing is that the code never needs to change between one story and the other, all that has to change is the text file for the story so I would build the game once and then just add new stories over time. One of the things I wanted to do was to allow site visitors to create stories also. Since they don't need access to the binary to do so I would then just give them a web page they can access via the Dashboard and have them write the dialogue in there.

In order to get access to this page in the dashboard I would just assign them a custom role or capability on my website (most likely a capability). Using WordPress Money I could sell them Dialogue Editing capabilities right on the site and as soon as the payment clears, voila, go to the dashboard and now they have access to edit / create stories.

This may be another avenue for you to explore. Give ppl a custom role on your site and then in Unity simply tick the box to fetch back the roles during login and inspect that instead of the custom meta which you won't have to write any more. This basically moves the automation from the Unity registration function into a manual process done on the website somehow. Not sure what it is you want to sync but by using custom roles you can give authors and consumers different pages on the website without involving my kits at all. In addition you can still check the roles like before so there is that... but if a custom role is overkill for your needs then the method in the previous post should work just fine :)

At least now you have options :)

We do have custom roles on our website!  Do you know if role can be a) set on registration or is it b) set on an update?  What I can do is have website folks who register automatically be assigned "writer" and then the mobile app registration role can be set to "player". If role can be set on registration that would work wonderfully for our existing webhooks.

Viewing posts 1 to 20 of 32 · Next page · Last page