UE4 Key-Sequences

Someone was having trouble with Key Sequences yesterday (e.g. Left, Right, Up, Left, Right, Fire) in UE4. Apparently the only method google could suggest was a highly complicated arrangement of branches that didn’t sound like much fun to implement and like a real pain to add to or change.

My suggestion is to use an Enum of possible key presses (Left, LeftDown, LeftUp etc.) and then store the last however many in an array which you compare to predefined ‘Make Array’ sequences of Enums, and once one matches execute whatever action you want for that sequence. Obviously you only add to the array if the key is different from the last entry in the array.

As you generally want the sequence to be either entered fairly rapidly or to not work, you could add a small timeout that is reset every time you press a different key. If the timeout reaches zero you clear the array ready to start again.

I hope this is some help.


Blender to UE4 FBX morph targets

Shape keys in Blender (Morph Targets in UE4) are incredibly useful but there are still some issues with the Blender to UE4 pipeline to be aware of.

Selecting “Faces” for smoothing in the FBX export can result in UE4 crashing, selecting “Normals” works around this (but obviously may cause you other problems with smoothing) – apparently it was fixed in Blender a couple of months ago but doesn’t seem to have made it into the version I’m using (2.74) as I am getting UE4 crashing. So you may find this unnecessary.

“Apply Modifiers” can apparently cause issues with shape keys.

Scaling a group of vertices down to 0 so they overlap at exactly the same coordinates can cause the shape keys to not work in UE4, scaling to something very very small like 0.01 will make them practically invisible without breaking the morph targets in UE4.


Blueprint Return Node behaviour

I’ve just discovered the hard way that if:

  1. You call a blueprint function that returns a value.
  2. You call the same function but the logic results in it not returning a value.

It will return the value it returned the first time. It will continue to return that value every time you call the function until the logic explicitly hits the ReturnNode and returns a new value.

It’s not entirely unreasonable behaviour it’s just not what I’d expected it to do (I thought it would return None).

The moral of the story is:

Always connect all of your logic paths to the ReturnNode.


UE4 Instanced Static Mesh and NavMesh

Having just spent hours on this problem I’m posting here.

I have a simple square made up of Instanced Static Meshes, I’m then trying to run around on them and it just won’t move even though seemingly everything is working. I can see the NavMesh is not generating anything on them, and it will if I put some other static mesh in there, but I don’t know why.

Having beat my head against this one and tried everything ever suggested on the subject I did the obviously-not-going-to-work-but-clutching-at-straws-thing of restarting UE4. It now works.



Blender to UE4 physics issues

There’s Blender to UE4 workflow issues if you’d rather watch that instead.

tl;dr summary (I ramble but there’re details in the long version that are needed):

Blender to UE4 export/import procedure results in UE4 physics model exploding. Ensure you’ve applied scale and rotation (Ctrl-A->”Scale & Rotation”) to the objects before exporting, then set the FBX export scale to the correct value. Just because the model imports at what visually is a suitable size, doesn’t mean it’s the right scale. It may work fine in every respect (animations, appearance etc.) but still be wrong when you get to the UE4 PHAT editor. Details for how in the long version.

Long version:

I’ve had plenty of problems importing from Blender to UE4 previously but thought I’d got past those issues. Working with the PHAT editor to modify the physics body on a model I’m working on I discovered another. Happily I’ve also worked out what it is and how to fix it.

No matter how the physics body appears to match the model, it may be that it doesn’t really. I was happy with how the generated physics model looked with only some minor modifications needed, a few sphyls needing collision disabling manually, some rescaling etc.

After that though I couldn’t get the simulation to run without the model exploding like a cartoon clockwork toy.

The first thing to check is that in Blender you’ve applied the Scale and Rotation on all of the objects to be exported, but most especially the skeleton/armature. To do this go into Object Mode, select all of the objects you’ll be exporting and in the 3D view press Ctrl-A to bring up the ‘Apply’ menu, then select “Scale & Rotation“.

At this point your armature may mangle horribly, I’m afraid the only solution I’ve found so far is to start from scratch and apply the scale and rotation as soon as you’ve performed any scales or rotates, either that or manually move everything back into place. In a couple of my cases they were so badly mangled it was quicker to start over. I do like to learn the hard way 🙂

Applying scale and rotation will fix most of the issues.

Eventually I noticed that if I transformed a sphyl it would move faster than the transform arrows I was dragging. On a hunch I went back to Blender and halved the FBX export scale – deleting the previous import in UE4 and importing it from scratch made PHAT behave much better, then making some adjustments like turning off a few overlapping sphyl collisions it worked perfectly!

The following should work for you as well as it now does for me:

  1. Follow the Unit Scale in Blender” instructions on the Unreal Engine wiki.
  2. Remember to Ctrl-A->”Scale & Rotation” at suitable points in the Blender modelling process.
  3. When you Export->FBX, set the following options: Scale=0.005; Armature/Mesh (unset Empty, Camera, Lamp and Other); Smoothing=Face; Check “Only Deform Bones“. Everything else should be okay as default.
  4. In UE4 you should be able to import with the default settings.

You should now have a valid physics model, though you may need to turn off collisions (hover over the “Collision Off” button and hold Ctrl+Alt for an explanation of what it does and how to use it).

I hope this is of some use!


EDIT: I’ve put up Blender to UE4 workflow issues.

Building a human body from scratch

…but only in blender, this isn’t Weird Science.

I’ve been applying my recently learned knowledge to create a human character – I’ve not used any reference photos etc. as a bit of an experiment and I’m really pleased with how it’s looking so far.

So now I’ve got a giant woman doing cartwheels while the default UE4 character runs around. Oops, she just accidentally launched me into space as her leg came up. For some reason her head’s falling off. I should fix that.


Server issues

My poor overworked server has been running out of memory regularly, requiring restarts to ‘fix’ it. I’ve spent a little time investigating and tuning apache prefork feels like it’s improved things. Only time will tell, I’ll keep an eye on it.


2 Weeks in

I’ve learned a lot over the last couple of weeks, but not had all the time I’ll ordinarily have due to school holidays. There’s only so much time you can stick them in front of <random electronic device>.

I’ve learned that the blender to UE4 workflow has its pitfalls:

Body-with-inverted-armsWhy are the arms inside-out? I still don’t know. It’s fine in blender. I imagine I’ve got a bone with odd settings somewhere though I’ve tried resetting the roll on all of them already. It can wait, I’ll get back to it. If you happen to know, please say. When I find out I’ll post the answer.

I’ve learned more hot-keys in blender. That is so very useful and saves so very much time.

I’ve now taken two of my children through the Dynamic Spawning/Exploding Cow tutorial and they’ve had fun with it and then come back asking to do it again.

I’ve corrupted a UE4 project so badly I had to start again from scratch after a couple of days spent on it. Oh yes, that reminds me – I need to log a bug report, I’m fairly sure deleting an output and undoing that delete isn’t supposed to destroy your project…


UE4 “Access None” issue

After much messing around trying to identify the cause of an “Access None” error in a Blueprint function I finally worked out that it’s not only happening at a different node than the one reported, but a completely different function (the one giving the error isn’t even called!).

It turned out I’d stupidly used the ‘Length’ of the array to get the last item in the array, so it was returning ‘None’. It must have been an oversight as I’d correctly used ‘Last Index’ elsewhere!

There are various articles and threads relating to this in the forums and the problem was clearly my own mistake so I won’t log this, obviously, but the error could be less confusing (this too has been mentioned).


Visual Studio and UE4 include note

I’ve been meaning to mention:

In Visual Studio – if you create new files in the Solution Explorer, even if they appear to be in the same directory as your other files they will fail to #include as they aren’t really in the same directory. So when you get:

error C1083: Cannot open include file:

it will be because it’s created the .h or .cpp file in the GameTitle/Intermediate/ProjectFiles directory rather than the GameTitle/Source/GameTitle directory with the others. You can cut and paste the file(s) from one to the other, ‘Remove’ the files from Solution Explorer and then drag and drop the newly placed files from Windows Explorer to GameTitle in Solution Explorer to fix it.
I’m sure there’s some other way this is supposed to be done but I learn by playing and then read the instructions when I get stuck.