Time for action – get these cubes under control
One type of dedicated jMonkeyEngine class that encapsulates a spatial's behavior is the Control
class from the com.jme3.scene.control
package. You can create a Control
object based on the code mentioned earlier, and add it to an individual cube. This prompts the cube to automatically test its own distance to the camera, and move away when the player looks at it! Seeing is believing:
- Create a
CubeChaserControl
class. Make it extend theAbstractControl
class from thecom.jme3.scene.control
package. - Implement abstract methods of the
CubeChaserControl
class with the following template:@Override protected void controlUpdate(float tpf) { } protected void controlRender(RenderManager rm, ViewPort vp) { } ...
Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.