Class CharacterControl

All Implemented Interfaces:
PhysicsControl, Savable, Control, JmeCloneable, Cloneable

public class CharacterControl extends PhysicsCharacter implements PhysicsControl, JmeCloneable
You might want to try BetterCharacterControl as well.
  • Field Details

    • spatial

      protected Spatial spatial
    • enabled

      protected boolean enabled
    • added

      protected boolean added
    • space

      protected PhysicsSpace space
    • viewDirection

      protected Vector3f viewDirection
    • useViewDirection

      protected boolean useViewDirection
    • applyLocal

      protected boolean applyLocal
  • Constructor Details

    • CharacterControl

      public CharacterControl()
    • CharacterControl

      public CharacterControl(CollisionShape shape, float stepHeight)
  • Method Details

    • isApplyPhysicsLocal

      public boolean isApplyPhysicsLocal()
    • setApplyPhysicsLocal

      public void setApplyPhysicsLocal(boolean applyPhysicsLocal)
      When set to true, the physics coordinates will be applied to the local translation of the Spatial
      Parameters:
      applyPhysicsLocal - true→match local coordinates, false→match world coordinates (default=false)
    • cloneForSpatial

      @Deprecated public Control cloneForSpatial(Spatial spatial)
      Deprecated.
      Description copied from interface: Control
      Creates a clone of the Control, the given Spatial is the cloned version of the spatial to which this control is attached to.
      Specified by:
      cloneForSpatial in interface Control
      Parameters:
      spatial - the Spatial to be controlled by the clone
      Returns:
      A clone of this control for the spatial
    • jmeClone

      public Object jmeClone()
      Description copied from interface: JmeCloneable
      Performs a regular shallow clone of the object. Some fields may also be cloned but generally only if they will never be shared with other objects. (For example, local Vector3fs and so on.)

      This method is separate from the regular clone() method so that objects might still maintain their own regular java clone() semantics (perhaps even using Cloner for those methods). However, because Java's clone() has specific features in the sense of Object's clone() implementation, it's usually best to have some path for subclasses to bypass the public clone() method that might be cloning fields and instead get at the superclass protected clone() methods. For example, through super.jmeClone() or another protected clone method that some base class eventually calls super.clone() in.

      Specified by:
      jmeClone in interface JmeCloneable
      Returns:
      a new instance
    • cloneFields

      public void cloneFields(Cloner cloner, Object original)
      Description copied from interface: JmeCloneable
      Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner. The object can call cloner.clone(fieldValue) to deep clone any of its fields.

      Note: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied.

      Specified by:
      cloneFields in interface JmeCloneable
      Parameters:
      cloner - The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.
      original - The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
    • setSpatial

      public void setSpatial(Spatial spatial)
      Specified by:
      setSpatial in interface Control
      Parameters:
      spatial - the spatial to be controlled. This should not be called from user code.
    • getSpatial

      public Spatial getSpatial()
      Returns:
      returns the spatial the control is added to, or null if the control is not attached to a spatial yet.
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from interface: PhysicsControl
      Enable or disable this control.

      The physics object is removed from its physics space when the control is disabled. When the control is enabled again, the physics object is moved to the current location of the spatial and then added to the physics space.

      Specified by:
      setEnabled in interface PhysicsControl
      Parameters:
      enabled - true→enable the control, false→disable it
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: PhysicsControl
      Test whether this control is enabled.
      Specified by:
      isEnabled in interface PhysicsControl
      Returns:
      true if enabled, otherwise false
    • setViewDirection

      public void setViewDirection(Vector3f vec)
    • getViewDirection

      public Vector3f getViewDirection()
    • isUseViewDirection

      public boolean isUseViewDirection()
    • setUseViewDirection

      public void setUseViewDirection(boolean viewDirectionEnabled)
    • update

      public void update(float tpf)
      Description copied from interface: Control
      Updates the control. This should not be called from user code.
      Specified by:
      update in interface Control
      Parameters:
      tpf - Time per frame.
    • render

      public void render(RenderManager rm, ViewPort vp)
      Description copied from interface: Control
      Should be called prior to queuing the spatial by the RenderManager. This should not be called from user code.
      Specified by:
      render in interface Control
      Parameters:
      rm - the caller (not null)
      vp - the relevant ViewPort (not null)
    • setPhysicsSpace

      public void setPhysicsSpace(PhysicsSpace newSpace)
      If enabled, add this control's physics object to the specified physics space. If not enabled, alter where the object would be added. The object is removed from any other space it's currently in.
      Specified by:
      setPhysicsSpace in interface PhysicsControl
      Parameters:
      newSpace - where to add, or null to simply remove
    • getPhysicsSpace

      public PhysicsSpace getPhysicsSpace()
      Description copied from interface: PhysicsControl
      Access the physics space to which the object is (or would be) added.
      Specified by:
      getPhysicsSpace in interface PhysicsControl
      Returns:
      the pre-existing space, or null for none
    • write

      public void write(JmeExporter ex) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class PhysicsCharacter
      Throws:
      IOException
    • read

      public void read(JmeImporter im) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class PhysicsCharacter
      Throws:
      IOException