Class CharacterBase

All Implemented Interfaces:
ConstCharacterBase, ConstJoltPhysicsObject, RefTarget, AutoCloseable, Comparable<JoltPhysicsObject>
Direct Known Subclasses:
Character, CharacterVirtual

public abstract class CharacterBase extends NonCopyable implements ConstCharacterBase, RefTarget
Base class to represent a player navigating a PhysicsSystem.
  • Method Details

    • restoreState

      public void restoreState(StateRecorder recorder)
      Restore the character's state from the specified recorder.
      Parameters:
      recorder - the recorder to restore from (not null)
    • setMaxSlopeAngle

      public void setMaxSlopeAngle(float angle)
      Alter the maximum slope that the character can walk on.
      Parameters:
      angle - the desired slope angle (in radians, default=5*Pi/18)
    • setUp

      public void setUp(Vec3Arg up)
      Alter the character's "up" direction.
      Parameters:
      up - the desired direction (not null, unaffected, default=(0,1,0))
    • getCosMaxSlopeAngle

      public float getCosMaxSlopeAngle()
      Return the maximum slope that the character can walk on. The character is unaffected.
      Specified by:
      getCosMaxSlopeAngle in interface ConstCharacterBase
      Returns:
      the cosine of the slope angle
    • getGroundBodyId

      public int getGroundBodyId()
      Return the body ID of the supporting surface. The character is unaffected. (native method: GetGroundBodyID)
      Specified by:
      getGroundBodyId in interface ConstCharacterBase
      Returns:
      the BodyID value
    • getGroundMaterial

      public ConstPhysicsMaterial getGroundMaterial()
      Access the material of the supporting surface. The character is unaffected.
      Specified by:
      getGroundMaterial in interface ConstCharacterBase
      Returns:
      a new JVM object with the pre-existing native object assigned, or else null
    • getGroundNormal

      public Vec3 getGroundNormal()
      Copy the normal direction at the point of contact with the supporting surface. The character is unaffected.
      Specified by:
      getGroundNormal in interface ConstCharacterBase
      Returns:
      a new direction vector (in system coordinates)
    • getGroundPosition

      public RVec3 getGroundPosition()
      Copy the location of the point of contact with the supporting surface. The character is unaffected.
      Specified by:
      getGroundPosition in interface ConstCharacterBase
      Returns:
      a new location vector (in system coordinates)
    • getGroundState

      public EGroundState getGroundState()
      Return the relationship between the character and its supporting surface. The character is unaffected.
      Specified by:
      getGroundState in interface ConstCharacterBase
      Returns:
      an enum value (not null)
    • getGroundSubShapeId

      public int getGroundSubShapeId()
      Identify the face on the supporting surface where contact is occurring. The character is unaffected.
      Specified by:
      getGroundSubShapeId in interface ConstCharacterBase
      Returns:
      a SubShapeId value
    • getGroundUserData

      public long getGroundUserData()
      Return the user data of the supporting surface. The character is unaffected.
      Specified by:
      getGroundUserData in interface ConstCharacterBase
      Returns:
      the 64-bit value
    • getGroundVelocity

      public Vec3 getGroundVelocity()
      Copy the world-space velocity of the supporting surface. The character is unaffected.
      Specified by:
      getGroundVelocity in interface ConstCharacterBase
      Returns:
      a new velocity vector (meters per second in system coordinates)
    • getShape

      public ConstShape getShape()
      Access the character's shape. The character is unaffected.
      Specified by:
      getShape in interface ConstCharacterBase
      Returns:
      a new immutable JVM object with the pre-existing native object assigned, or null if none
    • getUp

      public Vec3 getUp()
      Copy the character's "up" direction. The character is unaffected.
      Specified by:
      getUp in interface ConstCharacterBase
      Returns:
      a new direction vector
    • isSlopeTooSteep

      public boolean isSlopeTooSteep(Vec3Arg normal)
      Test whether the specified normal direction is too steep. The character is unaffected.
      Specified by:
      isSlopeTooSteep in interface ConstCharacterBase
      Parameters:
      normal - the surface normal to test (not null, unaffected)
      Returns:
      true if too steep, otherwise false
    • isSupported

      public boolean isSupported()
      Test whether the character is supported. The character is unaffected.
      Specified by:
      isSupported in interface ConstCharacterBase
      Returns:
      true if supported, otherwise false
    • saveState

      public void saveState(StateRecorder recorder)
      Save the character's state to the specified recorder. The character is unaffected.
      Specified by:
      saveState in interface ConstCharacterBase
      Parameters:
      recorder - the recorder to save to (not null)
    • getRefCount

      public int getRefCount()
      Count the active references to the native CharacterBase. The character is unaffected.
      Specified by:
      getRefCount in interface RefTarget
      Returns:
      the count (≥0)
    • setEmbedded

      public void setEmbedded()
      Mark the native CharacterBase as embedded.
      Specified by:
      setEmbedded in interface RefTarget