mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-25 00:30: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/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"]
|
[node name="OverlayInteraction" type="Node"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
@ -10,13 +9,9 @@ script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="left" type="ARVRController" parent="VR"]
|
[node name="left" type="ARVRController" parent="VR"]
|
||||||
|
|
||||||
[node name="OverlayActivator" parent="VR/left" instance=ExtResource( 6 )]
|
|
||||||
|
|
||||||
[node name="right" type="ARVRController" parent="VR"]
|
[node name="right" type="ARVRController" parent="VR"]
|
||||||
controller_id = 2
|
controller_id = 2
|
||||||
|
|
||||||
[node name="OverlayActivator" parent="VR/right" instance=ExtResource( 6 )]
|
|
||||||
|
|
||||||
[node name="head" type="ARVRCamera" parent="VR"]
|
[node name="head" type="ARVRCamera" parent="VR"]
|
||||||
visible = false
|
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
|
margin = 0.001
|
||||||
radius = 0.01
|
radius = 0.01
|
||||||
|
|
||||||
[node name="OverlayActivator" type="StaticBody"]
|
[node name="OverlayActivator" type="StaticBody" groups=[
|
||||||
|
"OverlayActivator",
|
||||||
|
]]
|
||||||
|
|
||||||
[node name="Collision" type="CollisionShape" parent="."]
|
[node name="Collision" type="CollisionShape" parent="."]
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
|
@ -57,7 +57,7 @@ func _trigger_off():
|
||||||
|
|
||||||
|
|
||||||
func _on_OverlayArea_entered(body: Node) -> void:
|
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
|
return
|
||||||
touch_state = true
|
touch_state = true
|
||||||
active_controller = body.get_parent().name
|
active_controller = body.get_parent().name
|
||||||
|
@ -66,7 +66,7 @@ func _on_OverlayArea_entered(body: Node) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_OverlayArea_exited(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
|
return
|
||||||
active_controller = ""
|
active_controller = ""
|
||||||
touch_state = false
|
touch_state = false
|
||||||
|
@ -96,15 +96,18 @@ func _update_offset():
|
||||||
|
|
||||||
|
|
||||||
func _update_target():
|
func _update_target():
|
||||||
|
var t = get_parent().current_target
|
||||||
# reparent _overlay_area
|
# reparent _overlay_area
|
||||||
_overlay_area.get_parent().remove_child(_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"
|
_left_is_activator = t != "left"
|
||||||
_right_is_activator = get_parent().current_target != "right"
|
_right_is_activator = t != "right"
|
||||||
# toggle appropriate colliders
|
# toggle appropriate colliders
|
||||||
$VR/left/OverlayActivator/Collision.disabled = !_left_is_activator
|
#$VR/left/OverlayActivator/Collision.disabled = !_left_is_activator
|
||||||
$VR/right/OverlayActivator/Collision.disabled = !_right_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():
|
func _update_modules():
|
||||||
|
|
|
@ -4,7 +4,9 @@ extends EditorPlugin
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
func _enter_tree() -> void:
|
||||||
add_autoload_singleton("OverlayInit", "res://addons/openvr_overlay/overlay_init.gd")
|
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:
|
func _exit_tree() -> void:
|
||||||
remove_autoload_singleton("OverlayInit")
|
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"
|
Settings="*res://addons/settings-manager/Settings.tscn"
|
||||||
OverlayInit="*res://addons/openvr_overlay/overlay_init.gd"
|
OverlayInit="*res://addons/openvr_overlay/overlay_init.gd"
|
||||||
|
OverlayInteractionRoot="*res://addons/openvr_overlay/OverlayInteractionRoot.tscn"
|
||||||
OverlayManager="*res://OverlayManager.tscn"
|
OverlayManager="*res://OverlayManager.tscn"
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
|
@ -39,6 +40,11 @@ enabled=PoolStringArray( "res://addons/godot-openvr/plugin.cfg", "res://addons/o
|
||||||
|
|
||||||
singletons=[ "res://addons/godot-openvr/godot_openvr.gdnlib" ]
|
singletons=[ "res://addons/godot-openvr/godot_openvr.gdnlib" ]
|
||||||
|
|
||||||
|
[layer_names]
|
||||||
|
|
||||||
|
3d_physics/layer_2="right_hand"
|
||||||
|
3d_physics/layer_3="left_hand"
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
common/enable_pause_aware_picking=true
|
common/enable_pause_aware_picking=true
|
||||||
|
|
Loading…
Reference in a new issue