extends RigidBody3D class_name GrabableObject @export var grabBox: GrabBox var isGrabbed: bool = false @export var grabPositionPositionOffset: Vector3 @export var grabPositionRotationOffset: Vector3 @export var putDownPositionOffset: Vector3 @export var throwingForce = 8.0 #How strong objects are thrown func _ready() -> void: grabBox = $GrabBox grabBox.grabbedByPlayer.connect(grab.rpc.bind(multiplayer.get_unique_id())) set_collision_layer_value(1,false) #Disables default collision layer @rpc("any_peer", "call_local") func grab(id): isGrabbed = true freeze = true if not get_multiplayer_authority() == id: set_multiplayer_authority(id) @rpc("authority", "call_local") func release(): isGrabbed = false freeze = false set_multiplayer_authority(1) @rpc("any_peer","call_local") func throw(facingDirectionX,facingDirectionY,cameraRotationX): linear_velocity = Vector3(facingDirectionX,cameraRotationX/PI*2+0.3,facingDirectionY) * throwingForce