Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added enable property to XRToolsPickable. #318

Merged
merged 1 commit into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions addons/godot-xr-tools/objects/pickable.gd
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ enum ReleaseMode {
const GRIP_POSE_PRIORITY = 100


## If true, the pickable supports being picked up
export var enabled : bool = true

## If true, the grip control must be held to keep the object picked up
export var press_to_hold : bool = true

Expand Down Expand Up @@ -140,7 +143,7 @@ func _ready():

# Test if this object can be picked up
func can_pick_up(_by: Spatial) -> bool:
return _state == PickableState.IDLE
return enabled and _state == PickableState.IDLE


# Test if this object is picked up
Expand Down Expand Up @@ -185,8 +188,8 @@ func drop_and_free():

# Called when this object is picked up
func pick_up(by: Spatial, with_controller: ARVRController) -> void:
# Skip if not idle
if _state != PickableState.IDLE:
# Skip if disabled or already picked up
if not enabled or _state != PickableState.IDLE:
return

if picked_up_by:
Expand Down
1 change: 1 addition & 0 deletions scenes/pickable_demo/objects/snap_tray.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func _set_tray_active(new_value : bool) -> void:

## Update state based on tray_active property
func _update_tray_active() -> void:
enabled = tray_active
$Body.material_override = active_material if tray_active else inactive_material
$SnapArea1/SnapZone1.enabled = tray_active
$SnapArea2/SnapZone2.enabled = tray_active
Expand Down