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

Performing complex movements with MotionPaths


Players in games have been obliged to jump on moving platforms since the dawn of gaming. Even with the incredibly advanced games of today, it's not uncommon to encounter this most primitive game mechanic albeit with better graphics. There's also a popular retro genre that calls for the same, not the least for mobile games.

How do we do that in jMonkeyEngine? One way is, of course, to simply use move or setLocalTranslation on geometries. This can quickly get complex if we want to make sequenced paths. A better option is to use MotionPaths and MotionEvents.

A MotionPath object is basically a set of waypoints through which an object will move in an interpolated way meaning the movement will be smooth. The MotionEvent is the control class defining when and how the object should move along the MotionPath object. It can define how an object should be rotated along the path and if and how the path should be cycled through.

In this recipe, we'll check out...