Finally fixed the site slowness problems!

I finally  had time to sit down and figure out why the site was loading everything so ridiculously slow… and the reason was simple. So simple I don’t even want to tell you. But I will.

When I was first transitioning hosts, I had a problem setting up the database locally. As a temporary workaround, I grabbed the externally accessible URL from my old hosting provider and continued to use that database. Then… I forgot about it and let it sit there and use a remote database for some extended amount of time.

The only reason I found out is because I was about the wipe out the entire site (after making a backup) and start over to see if that would fix any database problems I was experiencing. I grabbed the values from the config and noticed that it didn’t say localhost like it should; it said <decision you now regret you made many months ago>.com or something.

Anyway, after a quick update of the database location and a restore of the files/database, it appears everything is up and running without any problems and at a speed I don’t want to smash something over.

This is exactly why I make action lists 🙂 Too bad I started that habit after I made the database workaround decision >.>

Playing around with Unreal Motion Graphics (UMG)

I have been playing around with UMG since it came out in experimental format, but just got around to trying to tie data binding to a bar (for fun things like health, stamina, etc). UMG was promoted from experimental status with the latest UE4 release, so everything should be working fairly consistently. I spun my wheels for a little bit because apparently I forgot basic numeric properties >.>

To calculate the percentage for the bar, you have to take current <whatever> and divide it by max <whatever>. Basic math stuffs, yeah? The function for the percentage expects a float returned, because that is standard percentage stuff. Well apparently if you architect your variables as integers and ignore the main difference between integers and floats (whole numbers vs. fractions), you end up with a bar that only registers 0 and 100%! Whoops.

Go maths!

Besides that little snafu, I found the data binding within UMG to be extremely easy to handle inside of Blueprints once I figured out the casting I needed to do. I eventually switched to getting my character’s attributes through a Blueprint interface instead of having to mess around with so much casting. I found it much cleaner and easier to work with.

For example, I created an interface and implemented it in my character class like this:

implemented-interface

After which I can easily pull data out in the UMG HUD class like this:

called-interface

The result of the bars on the front end looks something like this:

bar-output

I’ve since created new attribute variables as floats and recreated the workflows (UE4 doesn’t allow you to change data types of variables that are in use anywhere in the Blueprint). I imagine as long as I segregate my interfaces well enough, they won’t become too unmanageable.

Hackathon UE4 code released

So I competed in a hackathon (Hack Midwest) back in July around my birthday and I managed to snag a prize for the “Most Entertaining App”. I used a combination of Unreal Engine 4, the VaRest plugin, and the Best Buy API. I open sourced the project here: https://github.com/alarial/BlastBestBuy and tried to include the basic instructions to get it up and working.

The project itself was more of a proof of concept than anything. I wanted to see if I could take returned data from a REST API and create some game objects dynamically. Turns out I can, but it is a little slow. I could see the code needing some optimization to be used in a production environment… but it worked for the intended purpose, which was to delight and entertain.

BBB-screenshot

Yes, that is a cow in the lower right corner. I dynamically created spheres with category labels, then as you destroy the spheres, cows drop with the subcategory labels.

Fun stuff. It may be a good example for someone looking to take advantage of RESTful API’s within UE4. I am hoping to see more full-featured API access within Blueprint, but I will take it one step at a time right now and explore what I can accomplish with what is available.

Game Tick – explained

I felt like my previous post deserved at least a little bit of a breakdown as to how to implement the game tick. If you have any desire to create an RPG-derivitive of some sort and your characters regenerate slowly over time rather than instantly, the game tick is your best friend. If you don’t like the idea of processing everything at the same time, you can always implement multiple ticks to handle different aspects of the update. Or use some type of tick logic on individual effects. There are many ways you can go with something like this, but deciding how you want to update your characters is very important.

I figured it would be worth it to run through the breakdown of how this tick is set up so that anyone that wanted to follow along would not need to just look at the screenshot and just blindly implement it hoping for the best.

Let’s start at the beginning…
UE4-BeginPlay

Event Begin Play issues a call to Game Tick, which is a custom event. One improvement to this might be adding a Switch Has Authority node so that you don’t make unnecessary calls. That node is on the Game Tick, so regular clients will get no further anyway.

UE4-GameTick

GameTick first makes sure that the entity trying to create a new tick is the authority (wouldn’t want peons defining their own ticks, right?). After that it seeds a new random stream. I have no interest in repeatable random, so the stream is set up to get a new random each time. I still need to fix the seed variable because it has no logic to regenerate every time, but the framework is there. It then gets a random integer between the min and max variables using the random seed and sets the CurrentGameTick value.

UE4-EventTick

Next, EventTick is obviously firing off all the freaking time, but we really don’t want to update that often. To fix that, we give it a sequence (so we can also process other stuff later) and check if the CurrentGameTick is not equal to 0 (ensuring that we have at least set it once). If it is something other than 0, we set a Delay for the length of time. After that delay, we execute another custom event, ProcessTick.

UE4-ProcessTick.

The last step here is to actually process events for the Game Tick. ProcessTick should contain whatever callouts to process things that you want to do every tick.

Finally, a quick look at the variables used here
UE4-GameTickVariables

Ignoring DefaultSceneRoot, the GameRandom is a VariableStream, while the rest are Integers.

There you have it. Hopefully an easy-to-follow implementation of basic game tick functionality in your game, using only Blueprints 🙂

As a recap:
1) Begin Play - Call the Game Tick
2) Game Tick - Create a new value in some range based on random seed
3) Event Tick - Wait for Game Tick time
4) Process Tick - Do stuff

Let me know if there is something here you would like me to explain more clearly 🙂

Game Tick

So I was messing around in Unreal Engine 4 and I managed to create the basis for my game tick through the Blueprint visual scripting system. For those of you unfamiliar with the concept, the tick (not confused with the constant tick for every frame in 3D rendering) is when the major game logic happens. The tick is when a player regenerates… when damage effects are applied… when regularly decremented values are assessed. Basically the tick is the master of all.

It actually wasn’t too bad in Blueprints. I am actually fairly proud that I managed to get the skeleton working the first time through without a bunch of trial and error. ^_^ Here is the Blueprint as it stands right now:
UE4-GameTick

This is all implemented in the Game Mode Blueprint that is supposed to contain the rules for the game. It should be fairly straightforward to implement. If you have any problems with it, let me know.