Play games within MMD using MMD as a Game Engine!

A feature article on LearnMMD by Trackdancer2015!

Play Games within MMD!

The MMD physics engine is really quite remarkable; after all, it was written by a professor working for Tokyo University. In this article we’re going to show you exactly how good this physics engine is by showing you how to make a vocaloid actually throw a ball.

put a ball in your model’s hand…
…and make your model THROW it!

We will also show you how you can use this knowledge to develop games that you can play with your favorite Vocaloid model just using MMD!

IA Rocks [UNOFFICIAL] tells us about the MMD Physics Engine... how to make a bouncing ball and how to THROW it!

This will be a long article, but if you are patient and work through it all with us, you will also learn some really advanced techniques using both MMD and the PMD editor.

Many PC and dedicated gaming platform 3D RPGs have some sort of physics engine similar to one that comes with MMD, but the one that comes with MMD is good enough to use it to play almost any game that requires some sort of physics calculation.

Japanese MMDers for example have used it to make it possible for Miku to play billiards with scientific accuracy, but we’re not going to go that far with this article. Instead, we will show you how to make a vocaloid throw a ball and make a little game out of that.

Get the pinkBall.pmx model…

Download the ZIP of files created for this project.Download the LearnMMD_Throw_A_Ball.ZIP support materials. Inside that folder you will find motion files and the pinkBall.pmd model… an enhanced physics dynamic model: a bouncing ball. (Learn how to make your OWN bouncing ball!)

The pinkBall is not a “normal” model…

When you load the pinkBall, you will find that you cannot “do” anything with it; you cannot move its center bone. This is a dynamic model. The reason why you cannot pick up the ball with the center bone is because it is not weighted to it plus the fact that the ball bone to which the ball is weighted is under the control of MMD’s physics engine. Bones under the physics engine’s control cannot be user selected normally which is why they are normally hidden from the user in the MMD display.

But what’s the good of a ball that you can’t even control?

Actually, the ball can be totally controlled by a vocaloid! In actual fact the vocaloid can not only pick up the ball, but drop it. And if they can drop it, that means they can throw the ball and in a scientifically accurate manner if you program her correctly. But let’s start by getting the vocaloid to pick up the ball. To do this we will need IA’s help. So let’s load her next.

The model needs a Hand Attachment bone…

We will be using my version of IA Rocks [UNOFFICIAL] to illustrate and demonstrate the points discussed in this article. However, if you want to use a different model, that’s fine too as what we will be discussing here will work with any MMD model, but it will need a hand attachment bone. Most Tda style models will have one of these bones and they’re used to make it easy for an MMD model to hold things in their hands. This bone can also be added to a model without one of these bones using the PMD semi-standard bone plugin.

Now if you loaded the ball first, the moment you load IA the ball starts moving. Why? Basically because she kicked it out of her way so that she could occupy the same space. Physics in MMD is primarily used for collision detection and what you just saw happen is a graphic demonstration of this process.


So how do we get IA to pick up the ball?

Start by making a pose of IA holding the ball. You can make your own pose or use the one we provided (IA_holding_ball_pose.vpd) in Download the ZIP of files created for this project.the support materials download package. But the ball is still wandering around aimlessly somewhere around her feet so we’ll get her to pick it up. To do this do the following.

  1. Make the ball the focus model and make sure that you’re at frame 0 in the frames display.
  2. Expand the ballcontrol category so that you can select the ball bone. Click on the name to select the bone. The name will be highlighted once it is selected. With physics turned on, this is the only way to select one of these types of bones.
  3. Next turn off the physics control on the bone manipulation panel then click register. The “X” symbol next to the ball bone should change to a diamond symbol. Once this happens the bone will be user selectable, but we won’t need to manually move the ball into IA’s hands. There’s a much easier way and it is also one of the methods used to make a vocaloid model hold an object like a microphone in MMD.

Click on the OP button to open up the Outside Parent Settings window. Use the following settings.

subject bone: ball
target model: IA Rocks
target bone: attach_L (on Tda models this bone is usually labeled dummy_L)

Click on the OP register button.

Now normally for a static model like a microphone, the model will automatically pop into the model’s hand but the ball is a dynamic model so we need to do one more step.

Under the main MMD graphical GUI next to the “To camera” button are six fields pertaining to the XYZ coords and angle of the bone. We need to zero these out since the ball probably wandered off somewhere by itself when it’s physics was under the program’s control. To zero these values out just click on the “X”, “Y” and “Z” buttons next to each field. Then click on the register button in the bone manipulation panel to lock the ball bone’s position. The ball should now be in IA’s hands. If you used our pose data you need to do nothing else. If you used your own pose data or another model then proceed to the next step.

You will probably need to sit the ball properly in your model’s hand. To do this simply adjust the balls position in the hand using the vocaloid model’s hand attachment bone. Don’t move the ball by using the ball bone.


So how do we get IA to drop the ball?

Now that you know how to hold an object in their hands, we will show you how to make them drop the object.

Advance a couple of frames, arbitrarily we will use frame 5, then open up the ball’s Outside Parent Settings panel again.

Change the settings to:

subject bone: ball
target model: non
target bone: (auto populated with dashes)

Click on the OP register button.

The section underneath (subject bone relative place (auto calculated)) isn’t needed with the ball as it is a dynamic model but with a static object model once it is released by the model holding it you will want to click on the “frame register” button to lock it’s position to where it was released otherwise it will jump back to it’s default load position which is probably what you don’t want to see happen. So if you ever wondered what this function is, now you know.


At this point (frame 5) IA has released the ball and it will go straight down and bounce a couple of times. Tab back to frame 4 using the left cursor key and the ball goes back into IA’s hands. Tab forward again to frame 5 using the right cursor key and the ball drops again. See how it all works?

If you got this far and everything is working as noted here, you’re already way ahead of most MMDers as you are now able to dynamically interact with your vocaloid character. Now isn’t that something?

But we can go further than that. We can teach your model to throw the ball after all, what’s the fun of just dropping it?

Programming a vocaloid to throw a ball

Actually, you can get really sophisticated in how you program “a vocaloid throws the ball” but we will keep things simple in this article to demonstrate the basic principles by just having IA fling the ball. For this we will need motion data and the neat thing about this is that what her body does actually affects how the ball behaves once it is released. So for example an overhand throw will affect the balls trajectory in a manner totally differently from an underhand lob.

But for this article we will just adapt the pose data we just created to have IA fling the ball. You can create your own motion data but for now it will be easier to use the data that we provided (IA_ball_throwing_demo_motion.vmd). The data is 110 frames long and is intended to run for about 250 frames so load this data onto your model and set up your play functions accordingly. Some of the motion is just filler, the most important section is what happens from frame 0 to frame 30 – especially frame 30 when the ball is released.

So the first order of business once the motion data is loaded onto your vocaloid model is to flip back over to the ball model and drag all the recorded data at frame 5 (from what we did above) over to frame 30 as we want to the ball to be released at this point in time. Use the cursor to play the motion and check that the ball is in the model’s hands between frames 0-29 and released at frame 30. If this is correct, then hit the play button and see IA fling that ball!

OK so let’s throw that ball!

But… she’s throwing like, well, a girl, right? Well not to be sexist but the ball didn’t go far did it? And you’re probably thinking that you just wasted a good portion of your time but before you start sending me nasty notes, let me ask you the same question I asked above again: did you stay awake in physics class?

Click the image to see instructions for throwing the ball!

The reason why the ball didn’t go far is because of a simple law of vectors:

Isaac Newton’s Second Law of Motion

In concise terms this law states that the net force on an object is equal to the mass of the object multiplied by the acceleration of the object.

The ball has a mass – we gave this to the ball when we built it.

The ball also has acceleration – we know this because when IA threw the ball it didn’t go straight down.

So the reason why the ball didn’t go far is due to lack of force, but how do you create force in MMD?

The answer is actually very simple:

Force=mass x acceleration.

Therefore, all we need to do is accelerate IA’s movements and in so doing you will see exactly how good the MMD physics engine really is!

To accelerate (or decelerate) motion in MMD you use interpolation curves and/or modify the number of frames required to perform a set movement. But for our purposes we only need to accelerate the motion at frame 30, so go to the frames display and do the following:

  1. Select all the bones that are registered at frame 30 – just drag select them with the mouse.
  2. With these bones selected change the interpolation curve to something like in the diagram shown in the illustration below.


Now play back the motion.

Quite a difference isn’t it? If you did it correctly IA would have thrown the ball quite some distance.

MMD as a physics laboratory

Try different types of shapes for the interpolation curve and see what happens to the ball when it is thrown. You’ll find that for any given curve the results are fairly consistent in terms of distance and direction but sometimes the ball behaves quirky. One way to avoid this is to allow the full sequence to play through and for the physics engine to reset itself before hitting the play button again.

But you won’t get the exact same results each time due to other factors such as some degree of ambient noise built into the engine and factors like what else your PC is doing at the same time.

The next experiment is to open up the gravity settings panel again and trigger the noise function and see what happens now. Then try to change the acceleration (due to gravity) setting. This is by default set at sea level (9.80). A smaller figure represents the value of this variable at higher altitudes and it can have considerable effects on far the ball can be thrown.

But just as importantly is exactly what positions and angles IA’s bones are at in frame 30. Experiment by tweaking the angles and positions of those bones and see the difference. I made IA throw the ball slightly upwards with this motion and to help build force by pulling her arm back but if you change these the ball’s behavior will be totally different because it will change the angle at which the ball is released and the force with which it can be thrown.

Everything IA does with the ball with this system is scientifically accurate!

OK so let’s make this into a game!

Right then, when you’ve got the hang of how all this works let’s make this into a simple game. In the download package is a simple physics enabled “basket”. This will catch the ball if you can get IA to throw the ball into it.

So that’s the object of the game: Throw the ball into the basket.

Have fun playing a game within MMD!

To play, place the basket anywhere you like and simply have IA throw the ball into the basket. Try different interpolation curves, or tweak her motion to make this happen. You can also reposition and to a degree aim IA by moving her using her mother bone.

For a greater challenge, add noise or put the basket further away and mess with the acceleration variable to get the distance needed to reach the basket.

BTW, see what happens to the ball after it is thrown if you turn off the floor physics…

For even more advanced play, create your own motion or tweak the physics properties of the ball itself. Incidentally, the ball can also be kicked if the model kicking it has physics for the feet and vocaloids can really kick balls quite hard. You’ll be surprised how good the MMD physics engine really is!

Miku does it! Have fun playing a game within MMD!

And so now not only can your vocaloids sing, dance, make videos and pictures in MMD, they can even now play games with you and remember, you read about this first on!

Have fun and thanks for reading!



MMD 9.26
SketchUp Make 2014
Photoshop 7
DivX Codec

IA Rocks [UNOFFICIAL] – Mqdl/Trackdancer
IA (C) The First Place Co., Ltd. (Japan)

Miku Append – Tda
Miku Hatsune (C) Crypton Future Media, Inc. (Japan)


Visit the Homepage! Plenty of Mikumikudance instruction and info!