Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Self-balancing using RotationalLimitMotors


Many games today use a blend of animations and physics to create realistic movement. For animated characters, this revolves around balance. It could take the shape of a runner who leans inwards through a curve to counter the centrifugal force. Creating a system like this is not easy and requires a lot of tweaking. In this recipe, we'll look into some of the fundamentals of this, and we'll create a new Control class that will try to balance itself using the rotational motors of SixDofJoint.

Note

Six Degrees of Freedom (SixDof) relates to the six ways the joint can rotate: +x, -x, +y, -y, +z, and -z. One way it differs from a point2point joint is that in addition, it also has motors for each axis, which makes it possible for it to also apply force.

How to do it...

To simulate balancing, we will begin by creating the upper body of a stickman-shape figure with a torso and two rigid arms. To do this, perform the following set of steps:

  1. First of all, we should...