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

Location-dependent animation – edge check


In certain games, players traverse dangerous areas where a fall off from a ledge could lead to their deaths. Sometimes, in these games, the player is not meant to fall off and their movement is restricted when they are close, or the player gets an extra warning before they plummet.

The control we'll develop can be used for any of those things, but since this chapter is about animations, we'll use it to play a special animation when the player gets too close to the edge.

Getting ready

The recipe will use similar patterns that have been used before in this chapter and we'll also use the animation manager control from earlier in the chapter. Any animation control will be fine to use, but it should have separate channels for the upper and lower parts of the body.

How to do it...

We can implement almost everything we need in a single class as follows:

  1. We begin by creating a class called EdgeCheckControl, which extends AbstractControl and contains the following...