mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-21 23:20:25 +01:00
make triggers use physics layers and only have one set of trigger activators
This commit is contained in:
parent
f081a963a4
commit
b673410e70
6 changed files with 45 additions and 14 deletions
|
@ -1,7 +1,6 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/openvr_overlay/interaction/overlay_interaction.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/openvr_overlay/interaction/OverlayActivator.tscn" type="PackedScene" id=6]
|
||||
|
||||
[node name="OverlayInteraction" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
|
@ -10,13 +9,9 @@ script = ExtResource( 1 )
|
|||
|
||||
[node name="left" type="ARVRController" parent="VR"]
|
||||
|
||||
[node name="OverlayActivator" parent="VR/left" instance=ExtResource( 6 )]
|
||||
|
||||
[node name="right" type="ARVRController" parent="VR"]
|
||||
controller_id = 2
|
||||
|
||||
[node name="OverlayActivator" parent="VR/right" instance=ExtResource( 6 )]
|
||||
|
||||
[node name="head" type="ARVRCamera" parent="VR"]
|
||||
visible = false
|
||||
|
||||
|
|
23
src/addons/openvr_overlay/OverlayInteractionRoot.tscn
Normal file
23
src/addons/openvr_overlay/OverlayInteractionRoot.tscn
Normal file
|
@ -0,0 +1,23 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/openvr_overlay/interaction/OverlayActivator.tscn" type="PackedScene" id=1]
|
||||
|
||||
[node name="OverlayInteractionRoot" type="Node"]
|
||||
|
||||
[node name="VR" type="ARVROrigin" parent="."]
|
||||
|
||||
[node name="left" type="ARVRController" parent="VR"]
|
||||
|
||||
[node name="OverlayActivator" parent="VR/left" instance=ExtResource( 1 )]
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
|
||||
[node name="right" type="ARVRController" parent="VR"]
|
||||
controller_id = 2
|
||||
|
||||
[node name="OverlayActivator" parent="VR/right" instance=ExtResource( 1 )]
|
||||
collision_layer = 2
|
||||
collision_mask = 2
|
||||
|
||||
[node name="head" type="ARVRCamera" parent="VR"]
|
||||
visible = false
|
|
@ -4,7 +4,9 @@
|
|||
margin = 0.001
|
||||
radius = 0.01
|
||||
|
||||
[node name="OverlayActivator" type="StaticBody"]
|
||||
[node name="OverlayActivator" type="StaticBody" groups=[
|
||||
"OverlayActivator",
|
||||
]]
|
||||
|
||||
[node name="Collision" type="CollisionShape" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
|
|
|
@ -57,7 +57,7 @@ func _trigger_off():
|
|||
|
||||
|
||||
func _on_OverlayArea_entered(body: Node) -> void:
|
||||
if body.get_node("../../..") != self or pause_triggers or !get_parent().overlay_visible:
|
||||
if pause_triggers or !get_parent().overlay_visible:
|
||||
return
|
||||
touch_state = true
|
||||
active_controller = body.get_parent().name
|
||||
|
@ -66,7 +66,7 @@ func _on_OverlayArea_entered(body: Node) -> void:
|
|||
|
||||
|
||||
func _on_OverlayArea_exited(body: Node) -> void:
|
||||
if body.get_node("../../..") != self or pause_triggers or !get_parent().overlay_visible:
|
||||
if pause_triggers or !get_parent().overlay_visible:
|
||||
return
|
||||
active_controller = ""
|
||||
touch_state = false
|
||||
|
@ -96,15 +96,18 @@ func _update_offset():
|
|||
|
||||
|
||||
func _update_target():
|
||||
var t = get_parent().current_target
|
||||
# reparent _overlay_area
|
||||
_overlay_area.get_parent().remove_child(_overlay_area)
|
||||
tracker_nodes[get_parent().current_target].add_child(_overlay_area)
|
||||
tracker_nodes[t].add_child(_overlay_area)
|
||||
|
||||
_left_is_activator = get_parent().current_target != "left"
|
||||
_right_is_activator = get_parent().current_target != "right"
|
||||
_left_is_activator = t != "left"
|
||||
_right_is_activator = t != "right"
|
||||
# toggle appropriate colliders
|
||||
$VR/left/OverlayActivator/Collision.disabled = !_left_is_activator
|
||||
$VR/right/OverlayActivator/Collision.disabled = !_right_is_activator
|
||||
#$VR/left/OverlayActivator/Collision.disabled = !_left_is_activator
|
||||
#$VR/right/OverlayActivator/Collision.disabled = !_right_is_activator
|
||||
_overlay_area.collision_mask = int(t!="right")*2
|
||||
_overlay_area.collision_mask += int(t!="left")*4
|
||||
|
||||
|
||||
func _update_modules():
|
||||
|
|
|
@ -4,7 +4,9 @@ extends EditorPlugin
|
|||
|
||||
func _enter_tree() -> void:
|
||||
add_autoload_singleton("OverlayInit", "res://addons/openvr_overlay/overlay_init.gd")
|
||||
add_autoload_singleton("OverlayInteractionRoot", "res://addons/openvr_overlay/OverlayInteractionRoot.tscn")
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
remove_autoload_singleton("OverlayInit")
|
||||
remove_autoload_singleton("OverlayInteractionRoot")
|
||||
|
|
|
@ -20,6 +20,7 @@ config/icon="res://textures/icon.png"
|
|||
|
||||
Settings="*res://addons/settings-manager/Settings.tscn"
|
||||
OverlayInit="*res://addons/openvr_overlay/overlay_init.gd"
|
||||
OverlayInteractionRoot="*res://addons/openvr_overlay/OverlayInteractionRoot.tscn"
|
||||
OverlayManager="*res://OverlayManager.tscn"
|
||||
|
||||
[debug]
|
||||
|
@ -39,6 +40,11 @@ enabled=PoolStringArray( "res://addons/godot-openvr/plugin.cfg", "res://addons/o
|
|||
|
||||
singletons=[ "res://addons/godot-openvr/godot_openvr.gdnlib" ]
|
||||
|
||||
[layer_names]
|
||||
|
||||
3d_physics/layer_2="right_hand"
|
||||
3d_physics/layer_3="left_hand"
|
||||
|
||||
[physics]
|
||||
|
||||
common/enable_pause_aware_picking=true
|
||||
|
|
Loading…
Reference in a new issue