Showing posts with label UE4 import. Show all posts
Showing posts with label UE4 import. Show all posts

Saturday, February 13, 2016

UE4 Enemy Characters & Animations

This tutorial is the seventh in the 10 part series on how to create a first person shooter game using Unreal Engine 4. We recommend you read the previous articles first to get the maximum benefit from this tutorial.

UE4 Enemy Characters & Animations

In this tutorial I will be using animations I downloaded from mixamo. Mixamo is a website that has many different characters and animations for free download.

The Mixamo website is a great place to get free character meshes and animations

Downloading From Mixamo

Sign up for mixamo and after you made a account click the store tab and click on characters. For this tutorial I will be using the character Warzombie F Pedroso. After you have selected your character click add to my assets this will allow you to download the character later and then click look for animations this will do a search and only show you the animations that are compatible with you selected character.

Zombie hcaracter available on Mixamo

Chose the animations that you want. For this tutorial I will be using the animations Zombie Idle, Zombie Walk, Zombie Run, Zombie Attack and Zombie Dying. Once you pick the animations make sure to click the add to assets option so you are able to download it later.





Once you have added all the animations you want you go to the my assets tab. It should bring you to the my character sub-tab select your character and click queue download a menu should pop up you the format to be FBX and the pose to be T-Pose and click queue download againThen go to the my animations sub-tab and select all your animations for that character and click queue download another menu should pop up format  FBX, With skin, 60 frames per second and keyframe reduction set to none. Then click downloads and download all your animations.


A selection of animations ready to be downloaded from the Mixamo website


Import The Character To UE4

Open unreal engine pick your project. Then right click on the content browser and make a new folder I will call mine Zombie. While in the folder click import and find your character FBX file or drag and drop it in. A pop up menu should appear you shouldn't have to change anything  for importing the character so just click import all.



UE4 FBX Import Options


Import The Animations To UE4

Next drag all the animations into a folder on your desktop and import them to Unreal Engine.

Select the animations to be imported

But this time when the menu pops up you should untick import mesh and click the drop down for skeleton and select your character's skeleton then click import all.


Select the relevant import options
Then you can delete the take 1 animations as they are unnecessary. After you have deleted those your unreal folder should look like the image below. 

UE4 files


The Animation Blueprint

Next we are going to make an animation blueprint. Go the Zombie folder and right click go to animation then click animation blueprint.

Create an Animation Blueprint

Then a menu should pop up there you chose the skeleton that you want the animation blueprint to work with and then click ok then name it ZombieAnimations

Select the skeleton to use with the animation blueprint

Then create and open a new Third Person project. We will use the Third Person Animation settings from here as a base template for our Enemy Character. 

Inside the third person template then open the animations folder which is in the mannequin folder. Once there double click the ThirdPerson_AnimBP.


Open the ThirdPerson_AnimBP

Open the event graph highlight all the code and copy it by pressing ctrl c and pasting it back into our ZombieAnimations event graph by pressing ctrl v.

Copy the event graph code from the ThirdPerson_AnimBP

Next, back into our ZombieAnimations event graphwe need to make the variables for this code  so go to the variables section make a new variable call it IsInAir? leave it as a boolean variable.

Create the same variables from the ThirdPerson_AnimBP in our zombieanimation blueprint

Then make another variable call it Speed and set it as a float.

The AnimGraph

Next double click on the AnimGraph from the ThirdPerson_AnimBP and highlight the object called default and copy it and paste it into the AnimGraph of zombie animations and connect it to Final animation pose.



Next double click on default and delete everything so that all is left is idle/run and entry




Animation Blend Space

Now delete the Thirdperson_IdleRun2D then minimize ZombieAnimations and right click back in the zombie folder and hover over animation and click Blend space 1D. After you click it a menu should pop up and ask you which skeleton would you like to use just chose your characters skeleton again. Name this Blend space 1D Idle_Walk_Run.


Then open the blend space 1D and click the option to display the editor vertically and all the animations compatible with your skeleton should appear on the right. Then change the X Axis label to Speed and change the range to 0 to 375.



Also for character animations you should open each animation that you are using and enable root motion.



Then drag your animations over from the right onto the graph in the middle. Place the idle animation at the bottom, the running animation at the top and the walking animation at around 80.


Now open ZombieAnimations again and right click and search for play blendspace player Idle_Walk_Run and connect it in between Speed and Final animation pose. Then hit compile and save and we will use this in the next tutorial. 

Connect up the blendspace node between speed and Final Animation Pose

Next Up

Now that the enemy character is set up it is time to get it to chase and attack the player by programming the Enemy AI for the game.



UE4 Custom Static Meshes

This tutorial is the sixth in the 10 part series on how to create a first person shooter game using Unreal Engine 4. We recommend you read the previous articles first to get the maximum benefit from this tutorial.

Find a suitable mesh/model:

First off you need to find a suitable mesh or meshes for your game design project. We recommend www.blenndswap.com as the best place to find quality, free 3D models and meshes. The files are all compatible with blender (a free 3d modelling software) so it will be easy and free to edit/tweak them beforing exporting as an .fbx file to be compatible with Unreal Engine 4.

You need to create an account before you can download but it is all free, although there is an option to upgrade to a paid account you will hardly need it unless you are downloading a huge volume of models. The website has a huge collection of models all available under a variety of different creative commons licences. Just use the search function to find what you need then download it... simple!

Find free 3d models using Blendswap
Find free 3d models using Blendswap

Edit in Blender

Blender is a free software that can be downloaded from www.blender.org . If you are not familiar with it you can read and/or watch some of our tutorials here. Before you open the file in Blender be sure to unzip/extract the file as it will have downloaded as a .zip file from Blendswap.
The key thing in blender will be to unpack any textures that are used on the model. If you do this correctly the textures can then be imported automatically to UE4 along with the .fbx file and UE4 will even create the material automatically.

Blender windows

What you need to do is select the object in the outliner window, then select the material (there may be more than one) from the materials tab in the properties window and finally select the textures tab also in the properties window. In the textures section there may be more than one texture listed so you will need to unpack them all individually.

Blender Materials Tab Highlighted

Blender Textures Tab Highlighted

You can do this by going to the subsection title 'Image' and clicking on the little icon beside the file name. This will present you with 4 unpacking options - choose the first one. You will not notice any changes but what happens is a folder called 'textures' is automatically generated where the blender file is saved and the unpacked texture is place it in. This is an important file management step which  ensures the textures will import correctly to UE4.

Unpack a texture in blender

Repeat these step for objects in the scene outliner to ensure all textures get unpacked.

*In blender you may also want to, if necessary, remove any additional objects that you do not want to use in UE4. For example you might download a file which contains 3 trees but you might only want one of the 3. In cases like this simply select the object and press delete (or 'x') on your keyboard.


Export as an FBX

Once you have unpacked all the textures and made any other edits to the model that you want it is time to export it as an .fbx file so it can be imported to UE4. Simply click file > export > FBX (.fbx)

This will bring you to the export page. In the bottom left of the screen you will find the export options. There are a couple of key settings that you will want to change.

Firstly, in the main section, you only need to export the mesh so select only the mesh option. By default all options will be highlighted and will result in unwanted elements being imported as part of the mesh.

Select only the 'Mesh' option
Secondly, in the geometries sections, you will need to change the smoothing option to face, this is important for UE4 and will result in an import error if you do not do this step.

Set smoothing to 'Face'

Once you have completed these steps you can click the export button in the top right of the screen.

*Do not change the save location, the .fbx needs to be in the same folder as the original blender fil and beside the auto generated textures folder.


Import To UE4

Before importing the file to Unreal Engine you should first create a folder titled 'Meshes' or something similar and then inside it a sub-folder with a suitable title eg. 'Trees'.

Sample folder structure for Meshes

Once inside the folder click on the Import button and navigate to where you saved the .fbx file, select it and click open. This will bring up the Import options. Depending on the mesh you will choose different options but always be sure to select Import Materials and Import Textures. Choosing Auto Generate Collision is most likely something you will want but for meshes such as grass you should deselect it.

UE4 import settings

Once happy with your selected settings click 'Import All' and the mesh and textures will be imported and UE4 will automatically generate materials from the textures and apply to the mesh.

For textures that contain transparent or semi transparent areas you will need to edit the auto generated material in order for them to work correctly. To do this simply double click on the material to open the material editor. In the material editor select the large material node and in the details window on the left change the blend mode form opaque to translucent. This will activate the opacity channel on the material node. You can now plug in the alpha channel of the texture node to the opacity channel. Click save and this will update the material and the mesh to display correctly.

UE4 Material Editor
Click save and exit the material editor. Then click save all in the Content Browser to add the files to the project.

Add Using Foliage Mode (optional)

    All meshes can simply be dragged and dropped into the level but for meshes such as grass, trees, bushes etc. that may be used across a wide expanse of the level you should use the foliage editor.

    Select the foliage editor tab in the top left of your screen and then drag and drop your mesh or meshes into the area saying "Drag and Drop Foliage Meshes Here". You can then select a mesh and edit it's various settings so that it is applied in the way that you want. You can select and deselect a range of meshes to paint on the ones you want when you want.

    UE4 Foliage Editor Settings

    To learn more about the foliage setting click on the graduation cap icon and follow the in-built UE4 tutorial. Once the foliage and other meshes are added your level will be much more detailed and interesting for the player. Here is how it looks like in our game when placed in map.

    Next Up

    Now it is time to give our player something to shoot at! We will download and set up our custom enemy character and animations.



    close
    Banner iklan disini