Skip to content
Home » Panda3D Part 19 – Animating the Slug Model

Panda3D Part 19 – Animating the Slug Model

Spread the love

In the previous part of the Panda3D series we used inverse kinematics in our slug model. Today we’ll be animating the model. We’ll be creating the first couple animations step by step and you can find all the animations in the blend file on github. Go ahead and open the slug.blend file in Blender.

There are several ways of animating bones in Blender, but what is important for us is that we should use animations as actions.

Let’s start with the none animation.

none Animation

First let’s switch to the Animation workspace (A) and make sure we’re in pose mode (B). Down in the Dope Sheet editor set the editing context to Action Editor (C). Next we must make sure that all bones are in their original positions. If not, select all the bones and hit Alt + G to reset location and/or Alt + R to reset rotation (D):

none animation

In the Action Editor make sure you’re at frame 1 (A). Then hit the New button to add a new action (B):

none animation

Rename the action ‘none’ (A) and hit the Shield button (B) to add a fake user. This is very important because this way our animation data will be saved even if the animation is not used. Otherwise we would lose it on leaving Blender. We must remember to add a fake user for each animation we create.

Our none animation, as its name suggests, hardly deserves to be called an animation because nothing is going to change here. That’s why we only need one frame for it. Set End frame to 1 (C):

none animation

Next, make sure all the bones are selected and, hovering over the 3D Viewport, hit I to add a keyframe. Then select Location, Rotation & Scale:

none animation

This will add keyframes for all the bones (A). I slightly dragged the border of the Action Editor (B) up so that you can see all the bones:

none animation

It doesn’t make sense to play this animation because nothing is going to happen anyway. Let’s let’s move on to the first actual animation, the idle animation.

idle Animation

So, hit the New Action button (A) to add a new action. Rename it ‘idle’ (B). Also, hit the Shield button (C) to add a fake user and thus permanently save the animation:

idle animation

When you add a new action, all the keyframes from the previous action are still there for you. You can use them if you need or delete them. In this case we can keep them.

In this animation the slug will be moving his tentacles and also slightly his body. Let’s start with the former. To better see the tentacles, let’s switch to front view (Num 1) and deselect all the bones (A). If you go to the Output tab (B), you will see that the frame rate is set to 24 fps (C). This means there will be 24 frames each second. We want the idle animation to take two seconds, so set the End frame to 48 (D). Then we will be looping the animation in the game.

idle animation

The tentacles should be in their original positions at frame 1 and 48. Halfway through the animation they should reach their maximum height.

So, go to frame 24 (A). Select the first bone of the left tentacle (B), which is actually the one you see on the right. If you go to the Bone tab (C), you can check the name of the bone (D). It’s Tentacle1.L:

idle animation

Hit R -60 to rotate the bone along with all its children 60 degrees counterclockwise (A). Then hit I to add a keyframe and select Location & Rotation. This will add the appropriate location and rotation keyframes for the selected bone (B):

idle animation

Then select the Tentacle1.R bone on the other tentacle (make sure the first one is deselected) and hit R 60 to rotate it 60 degrees clockwise (A). Hit I and select Location & Rotation to add a keyframe (B):

idle animation

Now, we want to add a breathing effect. We can do it by slightly changing the scale of the bones. Hit Num 3 to go to right view, deselect all bones and then select all the bones along the spine of the slug (A). Naturally real slugs don’t have spines, but ours do. You can also drag the border of the 3D Viewport on the left (B) to make it occupy less real estate so that we can see the slug better.

idle animation

Hit S 1.01 to scale the bones slightly and then hit I and select Location, Rotation & Scale to insert a keyframe:

idle animation

At the end of the animation all bones should return to their original positions. The easiest way to do it is copy the keyframes from frame 1 and paste them at frame 48.

First select all the bones (A). Then select all the keyframes at frame 1. You can do it by selecting the topmost keyframe at this frame (B). Make sure the keyframes at frame 24 are deselected. You can tell this by color. The selected keyframes are yellow, the deselected ones are white.

idle animation

Hit Ctrl + C to copy the keyframes. Then go to frame 48 and hit Ctrl + V to paste them there:

idle animation

Save the file, go back to frame 1 by hitting the left Jump to Endpoint button (A) and play the animation by hitting the Play Animation button (B):

idle animation

You should now see the slug breathing and moving his tentacles:

idle animation

Stop the animation by hitting the Stop Animation button:

idle animation

So, we’re done with the idle animation. Let’s move on to the walk animation.

Your Panda3D Magazine

Make Awesome Games and Other 3D Apps

with Panda3D and Blender using Python.

Cool stuff, easy to follow articles.

Get the magazine here (PDF).

walk Animation

Next, let’s implement the walk animation. This is the animation that will be played while the slug is walking to the racetrack or anywhere on the ground while not running.

Here, the slug should still be moving the tentacles, so we’re going to leave this as is. But apart from that, he should be lifting the middle part of his body slightly up.

So, hit the New Action button to add a new action. Rename it ‘walk’ (A) and hit the Shield button to add a fake user.

Now, as we don’t want to change anything about the tentacles, we’ll leave all the keyframes that are associated with them. We’ll also leave the keyframes on the other bones at frame 1 and 48 because at the beginning and at the end of the animation all bones should be in their original positions.

What we have to change is the way the body moves. So, deselect all keyframes in the Action Editor by hitting Alt + A and then hit B and box select the keyframes at frame 24 except the ones on the tentacles (B):

walk animation

Then hit X and select Delete Keyframes:

walk animation

Now, we want the animation two be three times longer than the idle animation. So, set the End frame to 144 (A). Go to left view (Ctrl + Num 3). Then select all bones and then all the keyframes at frame 48, which you can do by selecting the topmost keyframe. Hit G and move them to frame 144 (B). Next select all the keyframes at frame 24, hit G and move them to frame 72 (C):

walk animation

Next, go to frame 1 and select just the body_IK bone:

walk animation

Python Jumpstart Course

Learn the basics of Python, including OOP.

with lots of exercises, easy to follow

The course is available on Udemy.

Hit G Y 0.38 to move the controller bone to the left. This is where it should start off. Then hit I and select Location & Rotation to insert a keyframe:

walk animation

Now select just the keyframe at frame 1 and hit Ctrl + C to copy it. Go to frame 144 and past it by hitting Ctrl + V:

walk animation

Now go to frame 72. Hit G Y 0.01 to move the bone slightly. Then hit I and select Location & Rotation to insert a keyframe:

walk animation

Test the animation. There are going to be more animations, which you will find in the blend file. They are all created in a similar way as those we just made.

In the next part we’ll test our animations in Panda3D.

Blender Jumpstart Course

Learn the basics of 3D modeling in Blender.

step-by-step, easy to follow, visually rich

The course is available on Udemy and on Skillshare.


Spread the love

Leave a Reply