Animations in NeoAxis 




This tutorial was made to demonstrate how to get animations from a mesh to another set of meshes in NeoAxis. This way you could use one skeleton&animation for multiple characters or units. Version of NeoAxis used was 0.52.

To use this tutorial you need to have Visual Studio 2005 or 2008 installed. You can use the free Express versions from Microsoft.

Visual Studio Download

Download and install the C# package. When that is done open the solution that came with your NeoAxis package. It’s in the Src-folder and it’s named something like NonCommercialLicense.sln depending on what package you downloaded.

Visual Studio should open up and show all the files and projects in your selected solution.

First create a new class to your GameEntities-project by selecting GameEntities with right mousebutton, select “Add new item”, select a class item and name it Robot.cs.

Delete everything in your new class and copy the code from the file in this link.

Source Code

After copying press F6 and Visual Studio should compile the class and the whole project to new GameEntities.dll. Now you can use your new class in your game.

Next open up your NeoAxis Resource Editor. From this moment on it will be called as RE.

Create a new folder Robert, create a new EntityType called Robert in it and select Robot as your type's Class-type.




Now doubleclick Robert.type to go into edit-mode. Put mousepointer in the middle of the screen and click with right mousebutton. Select Attach object -> Mesh and attach all your meshes that belong to your robot. They must be in the .mesh form that NeoAxis supports.



I used meshes from my other unit, so that is why you can see textures on my meshes. But if you are trying to get animations working you already now how to texture meshes…

Here is a picture where all my robot's meshes are attached. It doesn’t look like much, because all the meshes are in the same position.



Next attach one more mesh that has a skeleton and the needed animations. This mesh is only a grey box, but it has the much needed skeleton with animations. You need to have a “walk” animation and “idle” animation. These are the animation names Robot.cs will look for when it tries to play animations.



Now doubleclick your Robert.type again to make it editable. Then check your animation mesh's box in the top right corner. Now you can edit that mesh's properties.

In the Properties window you can see a collection named BoneSlots. Add a new BoneSlot for every bone that you need to move your mesh.

When that is done change the Visible attribute to False, so that this mesh is not visible in simulation. After all we just need the bones and animation from it.





Now select every mesh one by one and assign correct BoneSlot to it. You need to assign only those meshes that you want animated. Also correct mesh Rotation if mesh is rotated incorrectly. You can see the meshes moving to where the bones are when you do this.




Few meshes are still out of place, but we will soon fix this. Robot-class uses physics body named “mainBody” to move our unit around. Let’s create it.

Rightclick on our type folder and create a new resource. Select Physics Model and name it Robert. Then rightclick on your Robert.type to make it editable and modify the PhysicsModel property to contain your new physics model.

Now when you check the box “Show Physics” your Robert should look like this.



With rightclicking you can select scale, rotate and move to stretch your blue physics box over your robot. When you are done name your physics body “mainBody”. Modify the Box-shape in the Shapes-list so that StaticFriction and DynamicFriction are 0.0. Otherwise Robert will fall to it’s face.



Now assign all your nonanimation related mesh parts to the “mainBody” by selecting mainBody in meshes Body-property (animations mesh too!). Then move these meshes to their right place. Don’t assign legs or animation related meshes to bodies!!!

Now the Robert looks more like a real robot.



Doubleclick Robert.type and check animations meshs's box. Then give animations mesh an alias “animations”. This is how Robot.cs will find our animations.

Now let’s test this baby! Change the AllowEditorCreate property to True so we can drop this on a map in Map editor. Also change AllowPlayerControl to True so we can drive it.

Close RE.

Open your Map Editor and drop Robert to some map. Then start simulation, run to Robert and press ‘E’-key and then ‘W’-key and you should see the legs moving. It may not be pretty but it works…

Q&A:

Q: I did exactly like you told me but he legs are still not moving.
A: I noticed that if the leg meshes have Position other than 0 0 0 they are somehow misaligned with the bones and they won’t move. So I think the reason might be that your skeleton’s bones and leg meshes are in different locations.

Here is a video (xvid encoded avi 20MB!!!) of animations:


Walker avi


--Wellu