Class CharacterContact

All Implemented Interfaces:
ConstCharacterContact, ConstCharacterContactKey, ConstJoltPhysicsObject, AutoCloseable, Comparable<JoltPhysicsObject>

public class CharacterContact extends CharacterContactKey implements ConstCharacterContact
Describe a contact between a Character and a body or another character.
  • Constructor Details

    • CharacterContact

      public CharacterContact(long contactVa, boolean owner, PhysicsSystem system)
      Instantiate with the specified native object assigned.
      Parameters:
      contactVa - the virtual address of the native object to assign (not zero)
      owner - true → make the JVM object the owner, false → it isn't the owner
      system - the physics system in which the contact is occurring (not null)

      For use in custom contact listeners.

  • Method Details

    • getCanPushCharacter

      public boolean getCanPushCharacter()
      Test whether the velocity of the contact point can push the character. The contact is unaffected. (native attribute: mCanPushCharacter)
      Specified by:
      getCanPushCharacter in interface ConstCharacterContact
      Returns:
      true if can push, otherwise false
    • getCharacterB

      public ConstCharacterVirtual getCharacterB()
      Return the colliding character. The contact is unaffected. (native attribute: mCharacterB)
      Specified by:
      getCharacterB in interface ConstCharacterContact
      Returns:
      a new JVM object with the pre-existing native object assigned, or null if no colliding character
    • getContactNormal

      public Vec3 getContactNormal()
      Copy the contact normal. The contact is unaffected. (native attribute: mContactNormal)
      Specified by:
      getContactNormal in interface ConstCharacterContact
      Returns:
      a new direction vector, pointing toward the character
    • getDistance

      public float getDistance()
      Return the contact separation. The contact is unaffected. (native attribute: mDistance)
      Specified by:
      getDistance in interface ConstCharacterContact
      Returns:
      the signed distance (in meters, ≤0→actual contact, >0→predictive contact)
    • getFraction

      public float getFraction()
      Return the fraction along the path where the contact takes place. The contact is unaffected. (native attribute: mFraction)
      Specified by:
      getFraction in interface ConstCharacterContact
      Returns:
      the fraction
    • getHadCollision

      public boolean getHadCollision()
      Test whether the character has actually collided. The contact is unaffected. (native attribute: mHadCollision)
      Specified by:
      getHadCollision in interface ConstCharacterContact
      Returns:
      true if a real collision, false for a predictive contact that never became a real one
    • getIsBackFacingContact

      public boolean getIsBackFacingContact()
      Test whether the contact came from a back-facing triangle or collision shape. The contact is unaffected. (native attribute: mIsBackFacingContact)
      Specified by:
      getIsBackFacingContact in interface ConstCharacterContact
      Returns:
      true if back-facing, otherwise false
    • getIsSensorB

      public boolean getIsSensorB()
      Test whether the colliding object is a sensor. The contact is unaffected. (native attribute: mIsSensorB)
      Specified by:
      getIsSensorB in interface ConstCharacterContact
      Returns:
      true for a sensor, otherwise false
    • getLinearVelocity

      public Vec3 getLinearVelocity()
      Copy the velocity of the contact point. The contact is unaffected. (native attribute: mLinearVelocity)
      Specified by:
      getLinearVelocity in interface ConstCharacterContact
      Returns:
      a new velocity vector
    • getMotionTypeB

      public EMotionType getMotionTypeB()
      Return the motion type of the colliding object. The contact is unaffected. (native attribute: mGetMotionTypeB)
      Specified by:
      getMotionTypeB in interface ConstCharacterContact
      Returns:
      an enum value (not null)
    • getPosition

      public RVec3 getPosition()
      Copy the location where the contact occurs. The contact is unaffected. (native attribute: mPosition)
      Specified by:
      getPosition in interface ConstCharacterContact
      Returns:
      a new vector (in system coordinates)
    • getSurfaceNormal

      public Vec3 getSurfaceNormal()
      Copy the surface normal of the contact. The contact is unaffected. (native attribute: mSurfaceNormal)
      Specified by:
      getSurfaceNormal in interface ConstCharacterContact
      Returns:
      a new direction vector
    • getUserData

      public long getUserData()
      Return the user data of the colliding object. The contact is unaffected. (native attribute: mUserData)
      Specified by:
      getUserData in interface ConstCharacterContact
      Returns:
      the data value
    • getWasDiscarded

      public boolean getWasDiscarded()
      Test whether the contact was discarded by the contact-validate callback. The contact is unaffected. (native attribute: mWasDiscarded)
      Specified by:
      getWasDiscarded in interface ConstCharacterContact
      Returns:
      true if discarded, otherwise false