class PlayerInteraction

Exported Variables

NameTypeDescription
grabPivotScenePackedSceneThe scene that is instantiated and grabs the object. Essentially your “hand”
maxInteractDistancefloatThe maximum distance away from the camera that the player can interact with objects
dropDistanceBufferfloatAdded to maxInteractDistance to determine how far away a grabbed object needs to be from the player to be grabbed. Adding a small buffer instead of just dropping the object when it’s distance from the player exceeds maxInteractDistance gives the player a little wiggle room when grabbing something at the very edge of their interact distance
grabStrengthfloatThe strength of the force applied to grabbed objects to move them
grabDampeningfloatPrevents jitter when moving grabbed objects, but if turned up too high can make it harder to move objects
grabRotationStrengthfloatThe strength of the force applied to grabbed objects to rotate them
grabRotationDampeningfloatPrevents jitter when rotating grabbed objects, but if turned up too high can make it harder to rotate objects
grabDistanceAdjustmentIncrementfloatThe amount to increment/decrement the distance the grabbed object is from the player
grabCenterOffsetfloatHow far off to the left/right grabbed objects are when grabbed by the corresponding hands. Done so that when the player grabs two objects, they don’t fight for the same space directly in front of the player
playerCrosshairRayCast3D

Public Variables

NameTypeDescription
toggleGrabModeIsOn
{ get; private set; }
boolTrue if the active grab mode is “Toggle”

class GrabData

Public Variables

NameTypeDescription
grabPivotRigidBody3DThe active grab pivot
fixedJointGeneric6DofJoint3DThe active fixed joint
grabbedObjectRigidBody3DThe currently grabbed object
rotationOffsetBasis
readyToDropboolHelps decide what press of the grab button causes the player to drop the object when in “toggle” grab mode
centerOffsetSignfloatNegative means this hand will hold objects a little off center to the left, positive means off to the right