|
@@ -1,200 +0,0 @@
|
|
-<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="Asciidoctor 1.5.4"><title>Custom Controls</title><link rel="stylesheet" href="./asciidoctor.css">
|
|
|
|
-<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
|
|
|
|
-<link rel="stylesheet" href="./coderay-asciidoctor.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"></head><body class="article toc2 toc-left"><div id="header"><div id="toolbar"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/src/docs/asciidoc/jme3/advanced/custom_controls.adoc"><i class="fa fa-pencil-square" aria-hidden="true"></i></a><a href="https://github.com/jMonkeyEngine/wiki/new/master/src/docs/asciidoc/jme3/advanced/"><i class="fa fa-plus-square" aria-hidden="true"></i></a><input dir="auto" style="position: relative; vertical-align: top;" spellcheck="false" autocomplete="off" class="searchbox__input aa-input" id="doc-search" name="search" placeholder="Search in the doc" required="required" type="search"></div><h1>Custom Controls</h1><div class="details"><span class="author" id="author"></span><br><span id="revnumber">version ,</span> <span id="revdate">2016/03/17 20:48</span></div><div id="toc" class="toc2"><div id="toctitle">Table of Contents</div><ul class="sectlevel1"><li><a href="#usage">Usage</a></li><li><a href="#example-code">Example Code</a></li><li><a href="#abstractcontrol-class">AbstractControl Class</a></li><li><a href="#the-control-interface">The Control Interface</a></li><li><a href="#best-practices">Best Practices</a></li></ul></div></div><div id="content"><div id="preamble"><div class="sectionbody"><div class="paragraph"><p>A <code>com.jme3.scene.control.Control</code> is a customizable jME3 interface that allows you to cleanly steer the behaviour of game entities (Spatials), such as artificially intelligent behaviour in NPCs, traps, automatic alarms and doors, animals and pets, self-steering vehicles or platforms – anything that moves and interacts. Several instances of custom Controls together implement the behaviours of a type of Spatial.</p></div>
|
|
|
|
-<div class="paragraph"><p>To control global game behaviour see <a href="../../jme3/advanced/application_states.html">Application States</a> – you often use AppStates and Control together.</p></div>
|
|
|
|
-<div class="ulist"><ul><li><p><a href="http://www.youtube.com/watch?v=MNDiZ9YHIpM">Quick video introduction to Custom Controls</a></p></li></ul></div>
|
|
|
|
-<div class="paragraph"><p>To control the behaviour of spatials:</p></div>
|
|
|
|
-<div class="olist arabic"><ol class="arabic"><li><p>Create one control for each <em>type of behavior</em>. When you add several controls to one spatial, they will be executed in the order they were added.<br>
|
|
|
|
-For example, one NPC can be controlled by a PhysicsControl instance and an AIControl instance.</p></li><li><p>Define the custom control and implement its behaviour in the Control’s update method:</p><div class="ulist"><ul><li><p>You can pass arguments into your custom control.</p></li><li><p>In the control class, the object <code>spatial</code> gives you access to the spatial and subspatials that the control is attached to.</p></li><li><p>Here you modify the `spatial’s transformation (move, scale, rotate), play animations, check its environement, define how it acts and reacts.</p></li></ul></div></li><li><p>Add an instance of the Control to a spatial to give it this behavior. The spatial’s game state is updated automatically from now on.</p><div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">spatial.addControl(myControl);</code></pre></div></div></li></ol></div>
|
|
|
|
-<div class="paragraph"><p>To implement game logic for a type of spatial, you will either extend AbstractControl (most common case), or implement the Control interface, as explained in this article.</p></div></div></div>
|
|
|
|
-<div class="sect1"><h2 id="usage">Usage</h2><div class="sectionbody"><div class="paragraph"><p>Use <a href="../../jme3/advanced/custom_controls.html">Controls</a> to implement the <em>behaviour of types of game entities</em>.</p></div>
|
|
|
|
-<div class="ulist"><ul><li><p>Use Controls to add a type of behaviour (that is, methods and fields) to individual Spatials.</p></li><li><p>Each Control has its own <code>update()</code> loop that hooks into <code>simpleUpdate()</code>. Use Controls to move blocks of code out of the <code>simpleUpdate()</code> loop.</p></li><li><p>One Spatial can be influenced by several Controls. (Very powerful and modular!)</p></li><li><p>Each Spatial needs its own instance of the Control.</p></li><li><p>A Control only has access to and control over the Spatial it is attached to.</p></li><li><p>Controls can be saved as .j3o file together with a Spatial.</p></li></ul></div>
|
|
|
|
-<div class="paragraph"><p>Examples: You can write</p></div>
|
|
|
|
-<div class="ulist"><ul><li><p>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.</p></li><li><p>A PlayerNavControl that is steered by user-configurable keyboard and mouse input.</p></li><li><p>A generic animation control that acts as a common interface that triggers animations (walk, stand, attack, defend) for various entities.</p></li><li><p>A DefensiveBehaviourControl that remote-controls NPC behaviour in fight situations.</p></li><li><p>An IdleBehaviourControl that remote-controls NPC behaviour in neutral situations.</p></li><li><p>A DestructionControl that automatically replaces a structure with an appropriate piece of debris after collision with a projectile…</p></li></ul></div>
|
|
|
|
-<div class="paragraph"><p>The possibilities are endless. emoji:smiley</p></div></div></div>
|
|
|
|
-<div class="sect1"><h2 id="example-code">Example Code</h2><div class="sectionbody"><div class="paragraph"><p>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.</p></div>
|
|
|
|
-<div class="paragraph"><p>Existing examples in the code base include:</p></div>
|
|
|
|
-<div class="ulist"><ul><li><p><a href="https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/animation/AnimControl.java">AnimControl.java</a> allows manipulation of skeletal animation, including blending and multiple channels.</p></li><li><p><a href="https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/scene/control/CameraControl.java">CameraControl.java</a> allows you to sync the camera position with the position of a given spatial.</p></li><li><p><a href="https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/scene/control/BillboardControl.java">BillboardControl.java</a> displays a flat picture orthogonally, e.g. a speech bubble or informational dialog.</p></li><li><p><a href="https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-bullet/src/common/java/com/jme3/bullet/control">PhysicsControl</a> subclasses (such as CharacterControl, RigidBodyControl, VehicleControl) allow you to add physical properties to any spatial. PhysicsControls tie into capabilities provided by the BulletAppState.</p></li></ul></div></div></div>
|
|
|
|
-<div class="sect1"><h2 id="abstractcontrol-class">AbstractControl Class</h2><div class="sectionbody"><div class="admonitionblock tip"><table><tr><td class="icon"><i class="fa icon-tip" title="Tip"></i></td><td class="content"><div class="paragraph"><p>The most common way to create a Control is to create a class that extends AbstractControl.</p></div></td></tr></table></div>
|
|
|
|
-<div class="paragraph"><p>The AbstractControl can be found under <code>com.jme3.scene.control.AbstractControl</code>. This is a default abstract class that implements the Control interface.</p></div>
|
|
|
|
-<div class="ulist"><ul><li><p>You have access to a boolean <code>isEnabled()</code>.</p></li><li><p>You have access to the Spatial object <code>spatial</code>.</p></li><li><p>You override the <code>controlUpdate()</code> method to implement the Spatial’s behaviour.</p></li><li><p>You have access to a <code>setEnabled(boolean)</code> method. This activates or deactivates this Control’s behaviour in this spatial temporarily. While the AbstractControl is toggled to be disabled, the <code>controlUpdate()</code> loop is no longer executed.<br>
|
|
|
|
-For example, you disable your IdleBehaviourControl when you enable your DefensiveBehaviourControl in a spatial.</p></li></ul></div>
|
|
|
|
-<div class="paragraph"><p>Usage: Your custom subclass implements the three methods <code>controlUpdate()</code>, <code>controlRender()</code>, <code>setSpatial()</code>, and <code>cloneForSpatial()</code> as shown here:</p></div>
|
|
|
|
-<div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">MyControl</span> <span class="directive">extends</span> AbstractControl <span class="directive">implements</span> Savable, <span class="predefined-type">Cloneable</span> {
|
|
|
|
- <span class="directive">private</span> <span class="type">int</span> index; <span class="comment">// can have custom fields -- example</span>
|
|
|
|
-
|
|
|
|
- <span class="directive">public</span> MyControl(){} <span class="comment">// empty serialization constructor</span>
|
|
|
|
-
|
|
|
|
- <span class="comment">/** Optional custom constructor with arguments that can init custom fields.
|
|
|
|
- * Note: you cannot modify the spatial here yet! */</span>
|
|
|
|
- <span class="directive">public</span> MyControl(<span class="type">int</span> i){
|
|
|
|
- <span class="comment">// index=i; // example</span>
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="comment">/** This method is called when the control is added to the spatial,
|
|
|
|
- * and when the control is removed from the spatial (setting a null value).
|
|
|
|
- * It can be used for both initialization and cleanup. */</span>
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> setSpatial(Spatial spatial) {
|
|
|
|
- <span class="local-variable">super</span>.setSpatial(spatial);
|
|
|
|
- <span class="comment">/* Example:
|
|
|
|
- if (spatial != null){
|
|
|
|
- // initialize
|
|
|
|
- }else{
|
|
|
|
- // cleanup
|
|
|
|
- }
|
|
|
|
- */</span>
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- <span class="comment">/** Implement your spatial's behaviour here.
|
|
|
|
- * From here you can modify the scene graph and the spatial
|
|
|
|
- * (transform them, get and set userdata, etc).
|
|
|
|
- * This loop controls the spatial while the Control is enabled. */</span>
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">protected</span> <span class="type">void</span> controlUpdate(<span class="type">float</span> tpf){
|
|
|
|
- <span class="keyword">if</span>(spatial != <span class="predefined-constant">null</span>) {
|
|
|
|
- <span class="comment">// spatial.rotate(tpf,tpf,tpf); // example behaviour</span>
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="predefined-type">Control</span> cloneForSpatial(Spatial spatial){
|
|
|
|
- <span class="directive">final</span> MyControl control = <span class="keyword">new</span> MyControl();
|
|
|
|
- <span class="comment">/* Optional: use setters to copy userdata into the cloned control */</span>
|
|
|
|
- <span class="comment">// control.setIndex(i); // example</span>
|
|
|
|
- control.setSpatial(spatial);
|
|
|
|
- <span class="keyword">return</span> control;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">protected</span> <span class="type">void</span> controlRender(RenderManager rm, ViewPort vp){
|
|
|
|
- <span class="comment">/* Optional: rendering manipulation (for advanced users) */</span>
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> read(JmeImporter im) <span class="directive">throws</span> <span class="exception">IOException</span> {
|
|
|
|
- <span class="local-variable">super</span>.read(im);
|
|
|
|
- <span class="comment">// im.getCapsule(this).read(...);</span>
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> write(JmeExporter ex) <span class="directive">throws</span> <span class="exception">IOException</span> {
|
|
|
|
- <span class="local-variable">super</span>.write(ex);
|
|
|
|
- <span class="comment">// ex.getCapsule(this).write(...);</span>
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-}</code></pre></div></div>
|
|
|
|
-<div class="paragraph"><p>See also:</p></div>
|
|
|
|
-<div class="ulist"><ul><li><p>To learn more about <code>write()</code> and <code>read()</code>, see <a href="../../jme3/advanced/save_and_load.html">Save and Load</a></p></li><li><p>To learn more about <code>setUserData()</code>, see <a href="../../jme3/advanced/spatial.html">Spatial</a>.</p></li></ul></div></div></div>
|
|
|
|
-<div class="sect1"><h2 id="the-control-interface">The Control Interface</h2><div class="sectionbody"><div class="admonitionblock tip"><table><tr><td class="icon"><i class="fa icon-tip" title="Tip"></i></td><td class="content"><div class="paragraph"><p>In the less common case that you want to create a Control that also extends another class, create a custom interface that extends jME3’s Control interface. Your class can become a Control by implementing the Control interface, and at the same time extending another class.</p></div></td></tr></table></div>
|
|
|
|
-<div class="paragraph"><p>The Control interface can be found under <code>com.jme3.scene.control.Control</code>. It has the following method signatures:</p></div>
|
|
|
|
-<div class="ulist"><ul><li><p><code>cloneForSpatial(Spatial)</code>: Clones the Control and attaches it to a clone of the given Spatial.<br>
|
|
|
|
-Implement this method to be able to <a href="../../jme3/advanced/save_and_load.html">save() and load()</a> Spatials carrying this Control.<br>
|
|
|
|
-The AssetManager also uses this method if the same spatial is loaded twice. You can specify which fields you want your object to reuse (e.g. collisionshapes) in this case.</p></li><li><p><code>setEnabled(boolean)</code>: Toggles a boolean that enables or disables the Control. Goes with accessor <code>isEnabled();</code>. You test for it in the <code>update(float tpf)</code> loop before you execute anything.</p></li><li><p>There are also some internal methods that you do not call from user code: <code>setSpatial(Spatial s)</code>, <code>update(float tpf);</code>, <code>render(RenderManager rm, ViewPort vp)</code>.</p></li></ul></div>
|
|
|
|
-<div class="paragraph"><p>Usage example:</p></div>
|
|
|
|
-<div class="olist arabic"><ol class="arabic"><li><p>Create a custom control interface.</p><div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">interface</span> <span class="class">MyControlInterface</span> <span class="directive">extends</span> <span class="predefined-type">Control</span> {
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> setSomething(<span class="type">int</span> x); <span class="comment">// optionally, add custom methods</span>
|
|
|
|
-}</code></pre></div></div></li><li><p>Create custom Controls implementing your Control interface.</p><div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">MyControl</span> <span class="directive">extends</span> MyCustomClass <span class="directive">implements</span> MyControlInterface {
|
|
|
|
-
|
|
|
|
- <span class="directive">protected</span> Spatial spatial;
|
|
|
|
-
|
|
|
|
- <span class="directive">protected</span> <span class="type">boolean</span> enabled = <span class="predefined-constant">true</span>;
|
|
|
|
-
|
|
|
|
- <span class="directive">public</span> MyControl() { } <span class="comment">// empty serialization constructor</span>
|
|
|
|
-
|
|
|
|
- <span class="directive">public</span> MyControl(<span class="type">int</span> x) { <span class="comment">// custom constructor</span>
|
|
|
|
- <span class="local-variable">super</span>(x);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> update(<span class="type">float</span> tpf) {
|
|
|
|
- <span class="keyword">if</span> (enabled && spatial != <span class="predefined-constant">null</span>) {
|
|
|
|
- <span class="comment">// Write custom code to control the spatial here!</span>
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> render(RenderManager rm, ViewPort vp) {
|
|
|
|
- <span class="comment">// optional for advanced users, e.g. to display a debug shape</span>
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="predefined-type">Control</span> cloneForSpatial(Spatial spatial) {
|
|
|
|
- MyControl control = <span class="keyword">new</span> MyControl();
|
|
|
|
- <span class="comment">// set custom properties</span>
|
|
|
|
- control.setSpatial(spatial);
|
|
|
|
- control.setEnabled(isEnabled());
|
|
|
|
- <span class="comment">// set some more properties here...</span>
|
|
|
|
- <span class="keyword">return</span> control;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> setEnabled(<span class="type">boolean</span> enabled) {
|
|
|
|
- <span class="local-variable">this</span>.enabled = enabled;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="type">boolean</span> isEnabled() {
|
|
|
|
- <span class="keyword">return</span> enabled;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> setSomething(<span class="type">int</span> z) {
|
|
|
|
- <span class="comment">// You can add custom methods ...</span>
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> write(JmeExporter ex) <span class="directive">throws</span> <span class="exception">IOException</span> {
|
|
|
|
- <span class="local-variable">super</span>.write(ex);
|
|
|
|
- OutputCapsule oc = ex.getCapsule(<span class="local-variable">this</span>);
|
|
|
|
- oc.write(enabled, <span class="string"><span class="delimiter">"</span><span class="content">enabled</span><span class="delimiter">"</span></span>, <span class="predefined-constant">true</span>);
|
|
|
|
- oc.write(spatial, <span class="string"><span class="delimiter">"</span><span class="content">spatial</span><span class="delimiter">"</span></span>, <span class="predefined-constant">null</span>);
|
|
|
|
- <span class="comment">// write custom variables ....</span>
|
|
|
|
- }
|
|
|
|
- <span class="annotation">@Override</span>
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> read(JmeImporter im) <span class="directive">throws</span> <span class="exception">IOException</span> {
|
|
|
|
- <span class="local-variable">super</span>.read(im);
|
|
|
|
- InputCapsule ic = im.getCapsule(<span class="local-variable">this</span>);
|
|
|
|
- enabled = ic.readBoolean(<span class="string"><span class="delimiter">"</span><span class="content">enabled</span><span class="delimiter">"</span></span>, <span class="predefined-constant">true</span>);
|
|
|
|
- spatial = (Spatial) ic.readSavable(<span class="string"><span class="delimiter">"</span><span class="content">spatial</span><span class="delimiter">"</span></span>, <span class="predefined-constant">null</span>);
|
|
|
|
- <span class="comment">// read custom variables ....</span>
|
|
|
|
- }
|
|
|
|
-}</code></pre></div></div></li></ol></div></div></div>
|
|
|
|
-<div class="sect1"><h2 id="best-practices">Best Practices</h2><div class="sectionbody"><div class="paragraph"><p>Use the getControl() accessor to get Control objects from Spatials. No need to pass around lots of object references.
|
|
|
|
-Here an example from the <a href="http://code.google.com/p/monkeyzone/">MonkeyZone</a> code:</p></div>
|
|
|
|
-<div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">CharacterAnimControl</span> <span class="directive">implements</span> <span class="predefined-type">Control</span> {
|
|
|
|
- ...
|
|
|
|
- public <span class="type">void</span> setSpatial(Spatial spatial) {
|
|
|
|
- ...
|
|
|
|
- animControl = spatial.getControl(AnimControl.class);
|
|
|
|
- characterControl = spatial.getControl(CharacterControl.class);
|
|
|
|
- ...
|
|
|
|
- }
|
|
|
|
-}</code></pre></div></div>
|
|
|
|
-<div class="paragraph"><p>You can create custom Control interfaces so a set of different Controls provide the same methods and can be accessed with the interface class type.</p></div>
|
|
|
|
-<div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">interface</span> <span class="class">ManualControl</span> <span class="directive">extends</span> <span class="predefined-type">Control</span> {
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> steerX(<span class="type">float</span> value);
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> steerY(<span class="type">float</span> value);
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> moveX(<span class="type">float</span> value);
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> moveY(<span class="type">float</span> value);
|
|
|
|
- <span class="directive">public</span> <span class="type">void</span> moveZ(<span class="type">float</span> value);
|
|
|
|
- ...
|
|
|
|
-}</code></pre></div></div>
|
|
|
|
-<div class="paragraph"><p>Then you create custom sub-Controls and implement the methods accordingly to the context:</p></div>
|
|
|
|
-<div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">ManualVehicleControl</span> <span class="directive">extends</span> ManualControl {...}</code></pre></div></div>
|
|
|
|
-<div class="paragraph"><p>and</p></div>
|
|
|
|
-<div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">ManualCharacterControl</span> <span class="directive">extends</span> ManualControl {...}</code></pre></div></div>
|
|
|
|
-<div class="paragraph"><p>Then add the appropriate controls to spatials:</p></div>
|
|
|
|
-<div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">characterSpatial.addControl(<span class="keyword">new</span> ManualCharacterControl());
|
|
|
|
-...
|
|
|
|
-vehicleSpatial.addControl(<span class="keyword">new</span> ManualVehicleControl());
|
|
|
|
-...</code></pre></div></div>
|
|
|
|
-<div class="admonitionblock tip"><table><tr><td class="icon"><i class="fa icon-tip" title="Tip"></i></td><td class="content"><div class="paragraph"><p>Use the getControl() method on a Spatial to get a specific Control object, and activate its behaviour!</p></div>
|
|
|
|
-<div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">ManualControl c = mySpatial.getControl(ManualControl.class);
|
|
|
|
-c.steerX(steerX);</code></pre></div></div></td></tr></table></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2017-06-13 18:11:33 UTC</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
|
|
|
|
- apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
|
|
|
|
- indexName: 'jmonkeyengine',
|
|
|
|
- inputSelector: '#doc-search',
|
|
|
|
- debug: false // Set debug to true if you want to inspect the dropdown
|
|
|
|
-});</script></body></html>
|
|
|