|
@@ -33,3 +33,35 @@ To implement game logic for a type of spatial, you will either extend AbstractCo
|
|
|
|
|
|
|
|
|
== Usage
|
|
|
+
|
|
|
+Use <<jme3/advanced/custom_controls#,Controls>> to implement the _behaviour of types of game entities_.
|
|
|
+
|
|
|
+* Use Controls to add a type of behaviour (that is, methods and fields) to individual Spatials.
|
|
|
+* Each Control has its own `update()` loop that hooks into `simpleUpdate()`. Use Controls to move blocks of code out of the `simpleUpdate()` loop.
|
|
|
+* One Spatial can be influenced by several Controls. (Very powerful and modular!)
|
|
|
+* Each Spatial needs its own instance of the Control.
|
|
|
+* A Control only has access to and control over the Spatial it is attached to.
|
|
|
+* Controls can be saved as .j3o file together with a Spatial.
|
|
|
+
|
|
|
+Examples: You can write
|
|
|
+
|
|
|
+* A WalkerNavControl, SwimmerNavControl, FlyerNavControl… that defines how a type of NPC finds their way around. All NPCs can walk, some can fly, others can swim, and some can all three, etc.
|
|
|
+* A PlayerNavControl that is steered by user-configurable keyboard and mouse input.
|
|
|
+* A generic animation control that acts as a common interface that triggers animations (walk, stand, attack, defend) for various entities.
|
|
|
+* A DefensiveBehaviourControl that remote-controls NPC behaviour in fight situations.
|
|
|
+* An IdleBehaviourControl that remote-controls NPC behaviour in neutral situations.
|
|
|
+* A DestructionControl that automatically replaces a structure with an appropriate piece of debris after collision with a projectile…
|
|
|
+
|
|
|
+The possibilities are endless. emoji:smiley
|
|
|
+
|
|
|
+
|
|
|
+== Example Code
|
|
|
+
|
|
|
+Other examples include the built-in RigidBodyControl in JME's physics integration, the built-in TerrainLODControl that updates the terrain's level of detail depending on the viewer's perspective, etc.
|
|
|
+
|
|
|
+Existing examples in the code base include:
|
|
|
+
|
|
|
+* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/animation/AnimControl.java[AnimControl.java] allows manipulation of skeletal animation, including blending and multiple channels.
|
|
|
+* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/scene/control/CameraControl.java[CameraControl.java] allows you to sync the camera position with the position of a given spatial.
|
|
|
+* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/scene/control/BillboardControl.java[BillboardControl.java] displays a flat picture orthogonally, e.g. a speech bubble or informational dialog.
|
|
|
+* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-bullet/src/common/java/com/jme3/bullet/control[PhysicsControl] subclasses (such as CharacterControl, RigidBodyControl, VehicleControl) allow you to add physical properties to any spatial. PhysicsControls tie into capabilities provided by the BulletAppState.
|