adds the game

This commit is contained in:
2026-08-14 18:01:56 -04:00
commit 9edadb3ce2
563 changed files with 39331 additions and 0 deletions
+104
View File
@@ -0,0 +1,104 @@
[gd_scene format=3 uid="uid://cx7xtulmd8ay4"]
[ext_resource type="Script" uid="uid://ces1j6plojyra" path="res://addons/godot-xr-tools/xr/start_xr.gd" id="1_o5qli"]
[ext_resource type="PackedScene" uid="uid://draoeoi7h6mv6" path="res://scenes/player.tscn" id="2_0wfyh"]
[ext_resource type="Script" uid="uid://iishy6cydfps" path="res://scripts/multiplayer_spawner.gd" id="3_sugp2"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="6_o6xl0"]
[ext_resource type="PackedScene" uid="uid://c8qjmks8fhg31" path="res://scenes/structures and objects/example_table.tscn" id="6_tefeu"]
[ext_resource type="PackedScene" uid="uid://c41ay4f0417rq" path="res://scenes/net_ui.tscn" id="7_o6xl0"]
[ext_resource type="PackedScene" uid="uid://cb0vydd7mmy4b" path="res://scenes/menu_player.tscn" id="8_85g3d"]
[ext_resource type="PackedScene" uid="uid://dgdb1texynduw" path="res://addons/godot-xr-tools/objects/virtual_keyboard.tscn" id="8_tipki"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_sugp2"]
sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
ground_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
[sub_resource type="Sky" id="Sky_jyhfs"]
sky_material = SubResource("ProceduralSkyMaterial_sugp2")
[sub_resource type="Environment" id="Environment_tbgi4"]
background_mode = 2
sky = SubResource("Sky_jyhfs")
glow_enabled = true
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tbgi4"]
albedo_color = Color(0.4351923, 0.43519226, 0.43519226, 1)
[sub_resource type="PlaneMesh" id="PlaneMesh_6500s"]
lightmap_size_hint = Vector2i(52, 52)
material = SubResource("StandardMaterial3D_tbgi4")
size = Vector2(10, 10)
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_sugp2"]
points = PackedVector3Array(-5, 0, -5, -5, 0, 5, 5, 0, -5, 5, 0, 5)
[node name="main" type="Node" unique_id=296749525]
[node name="netUI" parent="." unique_id=906191773 instance=ExtResource("7_o6xl0")]
[node name="scripts" type="Node" parent="." unique_id=2104275164]
[node name="networkHandler" type="Node" parent="scripts" unique_id=1929475105]
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1728649695]
environment = SubResource("Environment_tbgi4")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=346435635]
transform = Transform3D(-0.99844074, -0.019092038, 0.05245495, 0, 0.9396926, 0.34202012, -0.05582139, 0.34148684, -0.9382274, 0, 0, 0)
shadow_enabled = true
[node name="XRToolsStartXR" type="Node" parent="." unique_id=496753110]
script = ExtResource("1_o5qli")
metadata/_custom_type_script = "uid://ces1j6plojyra"
[node name="world" type="Node3D" parent="." unique_id=499557932]
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="world" unique_id=357195240]
unique_name_in_owner = true
_spawnable_scenes = PackedStringArray("uid://draoeoi7h6mv6")
spawn_path = NodePath("../players")
script = ExtResource("3_sugp2")
network_player = ExtResource("2_0wfyh")
[node name="Viewport2Din3D" parent="world" unique_id=220980373 instance=ExtResource("6_o6xl0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.4314556, 37.370678, -0.71896917)
scene = ExtResource("7_o6xl0")
viewport_size = Vector2(1154, 649)
transparent = 1
scene_properties_keys = PackedStringArray("net_ui.gd")
[node name="VirtualKeyboard" parent="world" unique_id=1084765825 instance=ExtResource("8_tipki")]
transform = Transform3D(1, 3.090862e-08, 1.2802769e-08, -3.090862e-08, 0.70710677, 0.70710677, 1.2802772e-08, -0.70710677, 0.70710677, -4.433024, 36.10894, -0.3101681)
scene_properties_keys = PackedStringArray("virtual_keyboard_2d.gd")
[node name="players" type="Node3D" parent="world" unique_id=1684849232]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.1082158, 0)
[node name="floor" type="StaticBody3D" parent="world" unique_id=1317083778]
[node name="MeshInstance3D" type="MeshInstance3D" parent="world/floor" unique_id=734052999]
mesh = SubResource("PlaneMesh_6500s")
[node name="CollisionShape3D" type="CollisionShape3D" parent="world/floor" unique_id=1855732969]
shape = SubResource("ConvexPolygonShape3D_sugp2")
[node name="exampleTable" parent="world" unique_id=533933729 instance=ExtResource("6_tefeu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.058960974, 0.0052758455, -3.7729044)
[node name="exampleTable2" parent="world" unique_id=811627054 instance=ExtResource("6_tefeu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.1148345, 0.0052758455, -3.7110677)
[node name="exampleTable" parent="world/exampleTable2" unique_id=1026160462 instance=ExtResource("6_tefeu")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, -2.8783445, 0.0052758455, 7.303864)
[node name="exampleTable2" parent="world/exampleTable2" unique_id=866294949 instance=ExtResource("6_tefeu")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, -5.9342184, 0.0052758455, 7.2420273)
[node name="exampleTable3" parent="world/exampleTable2" unique_id=653745227 instance=ExtResource("6_tefeu")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0.16694403, 0.0052758455, 7.504451)
[node name="exampleTable3" parent="world" unique_id=797173023 instance=ExtResource("6_tefeu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.986328, 0.0052758455, -3.9734917)
[node name="menuPlayer" parent="world" unique_id=804209568 instance=ExtResource("8_85g3d")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.4556284, 35.433014, 1.0342389)
+47
View File
@@ -0,0 +1,47 @@
[gd_scene format=3 uid="uid://cb0vydd7mmy4b"]
[ext_resource type="PackedScene" uid="uid://bq86r4yll8po" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/left_fullglove_low.tscn" id="3_k0pxx"]
[ext_resource type="PackedScene" uid="uid://cqhw276realc" path="res://addons/godot-xr-tools/functions/function_pointer.tscn" id="5_1nhhu"]
[ext_resource type="PackedScene" uid="uid://xqimcf20s2jp" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/right_fullglove_low.tscn" id="6_opu0r"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_aweyw"]
transparency = 1
albedo_color = Color(0, 0.54509807, 0.9254902, 0.19215687)
[node name="menuPlayer" type="Node3D" unique_id=804209568]
[node name="XROrigin3D" type="XROrigin3D" parent="." unique_id=903771874]
[node name="XRCamera3D" type="XRCamera3D" parent="XROrigin3D" unique_id=149130915]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.7, 0)
[node name="leftHand" type="XRController3D" parent="XROrigin3D" unique_id=338633589]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 1, 0)
tracker = &"left_hand"
pose = &"grip"
[node name="LeftHand" parent="XROrigin3D/leftHand" unique_id=1839286752 instance=ExtResource("3_k0pxx")]
hand_material_override = SubResource("StandardMaterial3D_aweyw")
[node name="FunctionPointer" parent="XROrigin3D/leftHand" unique_id=1023605435 instance=ExtResource("5_1nhhu")]
transform = Transform3D(1, 0, 0, 0, 0.70710677, 0.70710677, 0, -0.70710677, 0.70710677, 0.02, -0.03535534, -0.10606602)
show_laser = 2
laser_length = 1
show_target = true
[node name="rightHand" type="XRController3D" parent="XROrigin3D" unique_id=886577781]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 1, 0)
tracker = &"right_hand"
pose = &"grip"
[node name="RightHand" parent="XROrigin3D/rightHand" unique_id=1787718913 instance=ExtResource("6_opu0r")]
hand_material_override = SubResource("StandardMaterial3D_aweyw")
[node name="FunctionPointer" parent="XROrigin3D/rightHand" unique_id=1859978898 instance=ExtResource("5_1nhhu")]
transform = Transform3D(1, 0, 0, 0, 0.70710677, 0.70710677, 0, -0.70710677, 0.70710677, -0.02, -0.03535534, -0.10606602)
show_laser = 2
laser_length = 1
show_target = true
[connection signal="input_float_changed" from="XROrigin3D/leftHand" to="XROrigin3D/leftHand" method="_on_input_float_changed"]
[connection signal="input_float_changed" from="XROrigin3D/rightHand" to="XROrigin3D/rightHand" method="_on_input_float_changed"]
+39
View File
@@ -0,0 +1,39 @@
[gd_scene format=3 uid="uid://c41ay4f0417rq"]
[ext_resource type="Script" uid="uid://brb6tvcl1busf" path="res://scripts/net_ui.gd" id="1_ucqo3"]
[node name="netUI" type="Control" unique_id=906191773]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_ucqo3")
[node name="ColorRect" type="ColorRect" parent="." unique_id=620875836]
layout_mode = 0
offset_right = 1152.0
offset_bottom = 647.0
color = Color(4.813075e-08, 0.5438712, 0.54444873, 1)
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=569205404]
layout_mode = 0
offset_left = 274.0
offset_top = 277.0
offset_right = 879.0
offset_bottom = 433.0
[node name="Button" type="Button" parent="VBoxContainer" unique_id=832862994]
layout_mode = 2
text = " SERVER "
[node name="Button2" type="Button" parent="VBoxContainer" unique_id=565104870]
layout_mode = 2
text = "CLIENT"
[node name="LineEdit" type="LineEdit" parent="VBoxContainer" unique_id=365862909]
layout_mode = 2
[connection signal="pressed" from="VBoxContainer/Button" to="." method="_on_button_pressed"]
[connection signal="pressed" from="VBoxContainer/Button2" to="." method="_on_button_2_pressed"]
+71
View File
@@ -0,0 +1,71 @@
[gd_scene format=3 uid="uid://dbgb2o2fleirc"]
[ext_resource type="Script" uid="uid://b7sj2fsybkjwp" path="res://scripts/rigid_body_3d_2.gd" id="1_bcpvd"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_m7226"]
sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
ground_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
[sub_resource type="Sky" id="Sky_v25gn"]
sky_material = SubResource("ProceduralSkyMaterial_m7226")
[sub_resource type="Environment" id="Environment_ea71n"]
background_mode = 2
sky = SubResource("Sky_v25gn")
glow_enabled = true
[sub_resource type="BoxMesh" id="BoxMesh_6500s"]
size = Vector3(1.8497314, 0.20263672, 0.15917969)
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_m7226"]
points = PackedVector3Array(0.9248657, 0.101318374, 0.079589844, 0.9248657, 0.101318374, -0.079589844, -0.9248657, 0.101318374, 0.079589844, 0.9248657, -0.10131836, 0.079589844, 0.9248657, -0.10131836, -0.079589844, -0.9248657, 0.101318374, -0.079589844, -0.9248657, -0.10131836, 0.079589844, -0.9248657, -0.10131836, -0.079589844)
[sub_resource type="BoxMesh" id="BoxMesh_v25gn"]
size = Vector3(0.13375854, 1.7163696, 0.15917969)
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_ea71n"]
points = PackedVector3Array(0.06687927, 0.8581848, 0.079589844, -0.06687927, 0.8581848, 0.079589844, 0.06687927, -0.8581848, 0.079589844, 0.06687927, 0.8581848, -0.079589844, -0.06687927, 0.8581848, -0.079589844, -0.06687927, -0.8581848, 0.079589844, 0.06687927, -0.8581848, -0.079589844, -0.06687927, -0.8581848, -0.079589844)
[node name="physics test" type="Node3D" unique_id=1333536618]
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=635120337]
environment = SubResource("Environment_ea71n")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1050263882]
transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)
shadow_enabled = true
[node name="Camera3D" type="Camera3D" parent="." unique_id=941722894]
transform = Transform3D(1, 0, 0, 0, 0.9658625, 0.25905514, 0, -0.25905514, 0.9658625, 0, 1.4516523, 2.3242326)
[node name="RigidBody3D" type="RigidBody3D" parent="." unique_id=406856185]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.012578249, 0.8916312, 0.034165263)
mass = 30.0
[node name="MeshInstance3D" type="MeshInstance3D" parent="RigidBody3D" unique_id=484807143]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.8426755, 0.0021235347, 0.14303422)
mesh = SubResource("BoxMesh_6500s")
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D" unique_id=1333027805]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.8426755, 0.0021235347, 0.14303422)
shape = SubResource("ConvexPolygonShape3D_m7226")
[node name="RigidBody3D2" type="StaticBody3D" parent="." unique_id=1163594731]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.36118686, 0, 0)
script = ExtResource("1_bcpvd")
[node name="MeshInstance3D" type="MeshInstance3D" parent="RigidBody3D2" unique_id=1488074563]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.35461283, 0.5809505, -0.001403451)
mesh = SubResource("BoxMesh_v25gn")
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D2" unique_id=942059865]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.35461283, 0.5809505, -0.001403451)
shape = SubResource("ConvexPolygonShape3D_ea71n")
[node name="HingeJoint3D" type="HingeJoint3D" parent="RigidBody3D2" unique_id=316936172]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.36118686, 0.9570182, 0.088234305)
node_a = NodePath("..")
node_b = NodePath("../../RigidBody3D")
angular_limit/enable = true
angular_limit/upper = 0.0
angular_limit/lower = 0.0
+710
View File
@@ -0,0 +1,710 @@
[gd_scene format=3 uid="uid://draoeoi7h6mv6"]
[ext_resource type="PackedScene" uid="uid://bq86r4yll8po" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/left_fullglove_low.tscn" id="1_g2els"]
[ext_resource type="Script" uid="uid://ch7s411vwan10" path="res://scripts/xr_origin_3d.gd" id="1_smehm"]
[ext_resource type="Script" uid="uid://csbuxf0o41r55" path="res://scripts/player.gd" id="1_ur7pv"]
[ext_resource type="PackedScene" uid="uid://xqimcf20s2jp" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/right_fullglove_low.tscn" id="2_qhqgy"]
[ext_resource type="PackedScene" uid="uid://bl2nuu3qhlb5k" path="res://addons/godot-xr-tools/functions/movement_direct.tscn" id="3_smehm"]
[ext_resource type="Script" uid="uid://clfxgaxhlvxxo" path="res://scripts/handLogic.gd" id="4_smehm"]
[ext_resource type="PackedScene" uid="uid://c2q5phg8w08o" path="res://addons/godot-xr-tools/functions/movement_jump.tscn" id="5_ur7pv"]
[ext_resource type="PackedScene" uid="uid://cqhw276realc" path="res://addons/godot-xr-tools/functions/function_pointer.tscn" id="6_d2wvv"]
[ext_resource type="PackedScene" uid="uid://b6bk2pj8vbj28" path="res://addons/godot-xr-tools/functions/movement_turn.tscn" id="6_y4r1p"]
[ext_resource type="PackedScene" uid="uid://diyu06cw06syv" path="res://addons/godot-xr-tools/player/player_body.tscn" id="7_d2wvv"]
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_y4r1p"]
properties/0/path = NodePath("XROrigin3D:position")
properties/0/spawn = true
properties/0/replication_mode = 1
properties/1/path = NodePath("XROrigin3D:rotation")
properties/1/spawn = true
properties/1/replication_mode = 1
properties/2/path = NodePath("XROrigin3D/leftHand/LeftHand:_pose_overrides")
properties/2/spawn = true
properties/2/replication_mode = 1
properties/3/path = NodePath("XROrigin3D/rightHand/RightHand:_pose_overrides")
properties/3/spawn = true
properties/3/replication_mode = 1
properties/4/path = NodePath("XROrigin3D/leftHand/leftRigid/LeftPhysics:_pose_overrides")
properties/4/spawn = true
properties/4/replication_mode = 1
properties/5/path = NodePath("XROrigin3D/rightHand/rightRigid/RightPhysics:_pose_overrides")
properties/5/spawn = true
properties/5/replication_mode = 1
properties/6/path = NodePath("XROrigin3D/leftHand:position")
properties/6/spawn = true
properties/6/replication_mode = 1
properties/7/path = NodePath("XROrigin3D/leftHand:rotation")
properties/7/spawn = true
properties/7/replication_mode = 1
properties/8/path = NodePath("XROrigin3D/leftHand/leftRigid:position")
properties/8/spawn = true
properties/8/replication_mode = 1
properties/9/path = NodePath("XROrigin3D/leftHand/leftRigid:rotation")
properties/9/spawn = true
properties/9/replication_mode = 1
properties/10/path = NodePath("XROrigin3D/rightHand:position")
properties/10/spawn = true
properties/10/replication_mode = 1
properties/11/path = NodePath("XROrigin3D/rightHand:rotation")
properties/11/spawn = true
properties/11/replication_mode = 1
properties/12/path = NodePath("XROrigin3D/rightHand/rightRigid:position")
properties/12/spawn = true
properties/12/replication_mode = 1
properties/13/path = NodePath("XROrigin3D/rightHand/rightRigid:rotation")
properties/13/spawn = true
properties/13/replication_mode = 1
properties/14/path = NodePath("XROrigin3D/leftHand/leftRigid/HingeJoint3D:node_a")
properties/14/spawn = true
properties/14/replication_mode = 1
properties/15/path = NodePath("XROrigin3D/leftHand/leftRigid/HingeJoint3D:node_b")
properties/15/spawn = true
properties/15/replication_mode = 1
properties/16/path = NodePath("XROrigin3D/rightHand/rightRigid/HingeJoint3D:node_a")
properties/16/spawn = true
properties/16/replication_mode = 1
properties/17/path = NodePath("XROrigin3D/rightHand/rightRigid/HingeJoint3D:node_b")
properties/17/spawn = true
properties/17/replication_mode = 1
properties/18/path = NodePath("XROrigin3D/MeshInstance3D:position")
properties/18/spawn = true
properties/18/replication_mode = 1
[sub_resource type="SphereMesh" id="SphereMesh_6500s"]
radius = 0.125
height = 0.25
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_g6ne4"]
transparency = 1
albedo_color = Color(0, 0.54509807, 0.9254902, 0.19215687)
[sub_resource type="GDScript" id="GDScript_fjrip"]
script/source = "@tool
@icon(\"res://addons/godot-xr-tools/editor/icons/hand.svg\")
#class_name XRToolsHand
extends XRToolsHandPalmOffset
## XR Tools Hand Script
##
## This script manages a godot-xr-tools hand. It animates the hand blending
## grip and trigger animations based on controller input.
##
## Additionally the hand script detects world-scale changes in the XRServer
## and re-scales the hand appropriately so the hand stays scaled to the
## physical hand of the user.
## Signal emitted when the hand scale changes
signal hand_scale_changed(scale)
## Blend tree to use
@export var hand_blend_tree : AnimationNodeBlendTree: set = set_hand_blend_tree
## Override the hand material
@export var hand_material_override : Material: set = set_hand_material_override
## Default hand pose
@export var default_pose : XRToolsHandPoseSettings: set = set_default_pose
## Name of the Grip action in the OpenXR Action Map.
@export var grip_action : String = \"grip\"
## Name of the Trigger action in the OpenXR Action Map.
@export var trigger_action : String = \"trigger\"
## Last world scale (for scaling hands)
var _last_world_scale : float = 1.0
## Initial hand transform (from controller) - used for scaling hands
var _initial_transform : Transform3D
## Current hand transform (from controller) - after scale
var _transform : Transform3D
## Hand mesh
var _hand_mesh : MeshInstance3D
## Hand animation player
var _animation_player : AnimationPlayer
## Hand animation tree
var _animation_tree : AnimationTree
## Animation blend tree
var _tree_root : AnimationNodeBlendTree
## Sorted stack of PoseOverride
var _pose_overrides := []
## Force grip value (< 0 for no force)
var _force_grip := -1.0
## Force trigger value (< 0 for no force)
var _force_trigger := -1.0
# Sorted stack of TargetOverride
var _target_overrides := []
# Current target (controller or override)
var _target : Node3D
## Pose-override class
class PoseOverride:
## Who requested the override
var who : Node
## Pose priority
var priority : int
## Pose settings
var settings : XRToolsHandPoseSettings
## Pose-override constructor
func _init(w : Node, p : int, s : XRToolsHandPoseSettings):
who = w
priority = p
settings = s
## Target-override class
class TargetOverride:
## Target of the override
var target : Node3D
## Target priority
var priority : int
## Target-override constructor
func _init(t : Node3D, p : int):
target = t
priority = p
# Add support for is_xr_class on XRTools classes
func is_xr_class(xr_name: String) -> bool:
return xr_name == \"XRToolsHand\"
## Called when the node enters the scene tree for the first time.
func _ready() -> void:
# Save the initial hand transform
_initial_transform = transform
_transform = _initial_transform
# Disconnect from parent transform as we move to it in the physics step,
# and boost the physics priority after any grab-drivers but before other
# processing.
#if not Engine.is_editor_hint():
# top_level = true
# process_physics_priority = -70
# Find the relevant hand nodes
_hand_mesh = _find_child(self, \"MeshInstance3D\")
_animation_player = _find_child(self, \"AnimationPlayer\")
_animation_tree = _find_child(self, \"AnimationTree\")
# Apply all updates
_update_hand_blend_tree()
_update_hand_material_override()
_update_pose()
_update_target()
# Called when we get added to our tree
func _enter_tree():
# Assume our first child is our hand subscene, we position this
var child = get_child(0)
if child:
set_apply_to(child)
super._enter_tree()
# Offset our hand
var base_transform = Transform3D()
if _controller and _controller.tracker == \"left_hand\":
base_transform.origin = Vector3(-0.01, 0.0, 0.05)
else:
base_transform.origin = Vector3(0.01, 0.0, 0.05)
set_base_transform(base_transform)
## This method checks for world-scale changes and scales itself causing the
## hand mesh and skeleton to scale appropriately. It then reads the grip and
## trigger action values to animate the hand.
func _physics_process(_delta: float) -> void:
# Do not run the rest of physics if in the editor
if Engine.is_editor_hint():
return
# Scale the hand mesh with the world scale.
if XRServer.world_scale != _last_world_scale:
_last_world_scale = XRServer.world_scale
_transform = _initial_transform.scaled(Vector3.ONE * _last_world_scale)
emit_signal(\"hand_scale_changed\", _last_world_scale)
# Animate the hand mesh with the controller inputs
if _controller:
var grip : float = _controller.get_float(grip_action)
var trigger : float = _controller.get_float(trigger_action)
# Allow overriding of grip and trigger
if _force_grip >= 0.0: grip = _force_grip
if _force_trigger >= 0.0: trigger = _force_trigger
$AnimationTree.set(\"parameters/Grip/blend_amount\", grip)
$AnimationTree.set(\"parameters/Trigger/blend_amount\", trigger)
# Move to target
#var target_transform : Transform3D
#if _target is XRToolsGrabPointHand:
# target_transform = _target.get_palm_transform(true)
# if hand_offset_mode != 4:
# target_transform = target_transform * XRTools.get_palm_offset(hand_offset_mode, _controller).inverse()
#else:
# target_transform = _target.global_transform
#global_transform = target_transform * _transform
#force_update_transform()
# This method verifies the hand has a valid configuration.
func _get_configuration_warnings() -> PackedStringArray:
var warnings : PackedStringArray = super._get_configuration_warnings()
# Check hand for mesh instance
if not _find_child(self, \"MeshInstance3D\"):
warnings.append(\"Hand does not have a MeshInstance3D\")
# Check hand for animation player
if not _find_child(self, \"AnimationPlayer\"):
warnings.append(\"Hand does not have a AnimationPlayer\")
# Check hand for animation tree
var tree : AnimationTree = _find_child(self, \"AnimationTree\")
if not tree:
warnings.append(\"Hand does not have a AnimationTree\")
elif not tree.tree_root:
warnings.append(\"Hand AnimationTree has no root\")
# Return warnings
return warnings
## Find an [XRToolsHand] node.
##
## This function searches from the specified node for an [XRToolsHand] assuming
## the node is a sibling of the hand under an [XROrigin3D].
static func find_instance(node : Node) -> XRToolsHand:
return XRTools.find_xr_child(
XRHelpers.get_xr_controller(node),
\"*\",
\"XRToolsHand\") as XRToolsHand
## This function searches from the specified node for the left controller
## [XRToolsHand] assuming the node is a sibling of the [XROrigin3D].
static func find_left(node : Node) -> XRToolsHand:
return XRTools.find_xr_child(
XRHelpers.get_left_controller(node),
\"*\",
\"XRToolsHand\") as XRToolsHand
## This function searches from the specified node for the right controller
## [XRToolsHand] assuming the node is a sibling of the [XROrigin3D].
static func find_right(node : Node) -> XRToolsHand:
return XRTools.find_xr_child(
XRHelpers.get_right_controller(node),
\"*\",
\"XRToolsHand\") as XRToolsHand
# Check property config
func _validate_property(property):
if property.name == \"top_level\":
# Hide it!
property.usage = PROPERTY_USAGE_NONE
else:
super._validate_property(property)
## Set the blend tree
func set_hand_blend_tree(blend_tree : AnimationNodeBlendTree) -> void:
hand_blend_tree = blend_tree
if is_inside_tree():
_update_hand_blend_tree()
_update_pose()
## Set the hand material override
func set_hand_material_override(material : Material) -> void:
hand_material_override = material
if is_inside_tree():
_update_hand_material_override()
## Set the default open-hand pose
func set_default_pose(pose : XRToolsHandPoseSettings) -> void:
default_pose = pose
if is_inside_tree():
_update_pose()
## Add a pose override
func add_pose_override(who : Node, priority : int, settings : XRToolsHandPoseSettings) -> void:
# Remove any existing pose override from this source
var modified := _remove_pose_override(who)
# Insert the pose override
if settings:
_insert_pose_override(who, priority, settings)
modified = true
# Update the pose
if modified:
_update_pose()
## Remove a pose override
func remove_pose_override(who : Node) -> void:
# Remove the pose override
var modified := _remove_pose_override(who)
# Update the pose
if modified:
_update_pose()
## Force the grip and trigger values (primarily for preview)
func force_grip_trigger(grip : float = -1.0, trigger : float = -1.0) -> void:
# Save the forced values
_force_grip = grip
_force_trigger = trigger
# Update the animation if forcing to specific values
if grip >= 0.0: $AnimationTree.set(\"parameters/Grip/blend_amount\", grip)
if trigger >= 0.0: $AnimationTree.set(\"parameters/Trigger/blend_amount\", trigger)
## This function adds a target override. The collision hand will attempt to
## move to the highest priority target, or the [XRController3D] if no override
## is specified.
func add_target_override(target : Node3D, priority : int) -> void:
# Remove any existing target override from this source
var modified := _remove_target_override(target)
# Insert the target override
_insert_target_override(target, priority)
modified = true
# Update the target
if modified:
_update_target()
## This function remove a target override.
func remove_target_override(target : Node3D) -> void:
# Remove the target override
var modified := _remove_target_override(target)
# Update the pose
if modified:
_update_target()
func _update_hand_blend_tree() -> void:
# As we're going to make modifications to our animation tree, we need to do
# a deep copy, simply setting resource local to scene does not seem to be enough
if _animation_tree and hand_blend_tree:
_tree_root = hand_blend_tree.duplicate(true)
_animation_tree.tree_root = _tree_root
func _update_hand_material_override() -> void:
if _hand_mesh:
_hand_mesh.material_override = hand_material_override
func _update_pose() -> void:
# Skip if no blend tree
if !_tree_root:
return
# Select the pose settings
var pose_settings : XRToolsHandPoseSettings = default_pose
if _pose_overrides.size():
pose_settings = _pose_overrides[0].settings
# Get the open and closed pose animations
var open_pose : Animation = pose_settings.open_pose
var closed_pose : Animation = pose_settings.closed_pose
# Apply the open hand pose in the player and blend tree
if open_pose:
var open_name = _animation_player.find_animation(open_pose)
if open_name == \"\":
open_name = \"open_hand\"
if _animation_player.has_animation(open_name):
_animation_player.get_animation_library(\"\").remove_animation(open_name)
_animation_player.get_animation_library(\"\").add_animation(open_name, open_pose)
var open_hand_obj : AnimationNodeAnimation = _tree_root.get_node(\"OpenHand\")
if open_hand_obj:
open_hand_obj.animation = open_name
# Apply the closed hand pose in the player and blend tree
if closed_pose:
var closed_name = _animation_player.find_animation(closed_pose)
if closed_name == \"\":
closed_name = \"closed_hand\"
if _animation_player.has_animation(closed_name):
_animation_player.get_animation_library(\"\").remove_animation(closed_name)
_animation_player.get_animation_library(\"\").add_animation(closed_name, closed_pose)
var closed_hand_obj : AnimationNodeAnimation = _tree_root.get_node(\"ClosedHand1\")
if closed_hand_obj:
closed_hand_obj.animation = closed_name
closed_hand_obj = _tree_root.get_node(\"ClosedHand2\")
if closed_hand_obj:
closed_hand_obj.animation = closed_name
func _insert_pose_override(who : Node, priority : int, settings : XRToolsHandPoseSettings) -> void:
# Construct the pose override
var override := PoseOverride.new(who, priority, settings)
# Iterate over all pose overrides in the list
for pos in _pose_overrides.size():
# Get the pose override
var pose : PoseOverride = _pose_overrides[pos]
# Insert as early as possible to not invalidate sorting
if pose.priority <= priority:
_pose_overrides.insert(pos, override)
return
# Insert at the end
_pose_overrides.push_back(override)
func _remove_pose_override(who : Node) -> bool:
var pos := 0
var length := _pose_overrides.size()
var modified := false
# Iterate over all pose overrides in the list
while pos < length:
# Get the pose override
var pose : PoseOverride = _pose_overrides[pos]
# Check for a match
if pose.who == who:
# Remove the override
_pose_overrides.remove_at(pos)
modified = true
length -= 1
else:
# Advance down the list
pos += 1
# Return the modified indicator
return modified
# This function inserts a target override into the overrides list by priority
# order.
func _insert_target_override(target : Node3D, priority : int) -> void:
# Construct the target override
var override := TargetOverride.new(target, priority)
# Iterate over all target overrides in the list
for pos in _target_overrides.size():
# Get the target override
var o : TargetOverride = _target_overrides[pos]
# Insert as early as possible to not invalidate sorting
if o.priority <= priority:
_target_overrides.insert(pos, override)
return
# Insert at the end
_target_overrides.push_back(override)
# This function removes a target from the overrides list
func _remove_target_override(target : Node) -> bool:
var pos := 0
var length := _target_overrides.size()
var modified := false
# Iterate over all pose overrides in the list
while pos < length:
# Get the target override
var o : TargetOverride = _target_overrides[pos]
# Check for a match
if o.target == target:
# Remove the override
_target_overrides.remove_at(pos)
modified = true
length -= 1
else:
# Advance down the list
pos += 1
# Return the modified indicator
return modified
# This function updates the target for hand movement.
func _update_target() -> void:
if _target_overrides.size():
_target = _target_overrides[0].target
else:
_target = get_parent()
static func _find_child(node : Node, type : String) -> Node:
# Iterate through all children
for child in node.get_children():
# If the child is a match then return it
if child.is_class(type):
return child
# Recurse into child
var found := _find_child(child, type)
if found:
return found
# No child found matching type
return null
"
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_fjrip"]
[sub_resource type="BoxShape3D" id="BoxShape3D_6500s"]
size = Vector3(0.051635742, 0.1160965, 0.14953613)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_smehm"]
[node name="player" type="Node3D" unique_id=388903966]
script = ExtResource("1_ur7pv")
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="." unique_id=291104021]
replication_config = SubResource("SceneReplicationConfig_y4r1p")
[node name="XROrigin3D" type="XROrigin3D" parent="." unique_id=2026609409]
script = ExtResource("1_smehm")
[node name="MeshInstance3D" type="MeshInstance3D" parent="XROrigin3D" unique_id=944746671]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.7, 0)
mesh = SubResource("SphereMesh_6500s")
[node name="XRCamera3D" type="XRCamera3D" parent="XROrigin3D" unique_id=661262409]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.7, 0)
[node name="leftHand" type="XRController3D" parent="XROrigin3D" unique_id=972246256 node_paths=PackedStringArray("physicsHand")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 1, 0)
tracker = &"left_hand"
pose = &"grip"
script = ExtResource("4_smehm")
physicsHand = NodePath("leftRigid")
[node name="LeftHand" parent="XROrigin3D/leftHand" unique_id=750051836 instance=ExtResource("1_g2els")]
hand_material_override = SubResource("StandardMaterial3D_g6ne4")
[node name="MovementDirect" parent="XROrigin3D/leftHand" unique_id=552284268 instance=ExtResource("3_smehm")]
strafe = true
[node name="FunctionPointer" parent="XROrigin3D/leftHand" unique_id=1883490498 instance=ExtResource("6_d2wvv")]
transform = Transform3D(1, 0, 0, 0, 0.70710677, 0.70710677, 0, -0.70710677, 0.70710677, 0.02, -0.03535534, -0.10606602)
show_laser = 2
laser_length = 1
show_target = true
[node name="leftRigid" type="RigidBody3D" parent="XROrigin3D/leftHand" unique_id=1627474705]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.39838424, -0.048642874, 0)
collision_layer = 4
collision_mask = 2
mass = 0.2
gravity_scale = 0.0
contact_monitor = true
max_contacts_reported = 1
linear_damp = 30.0
angular_damp = 30.0
[node name="LeftPhysics" parent="XROrigin3D/leftHand/leftRigid" unique_id=1387724990 instance=ExtResource("1_g2els")]
transform = Transform3D(1, 0, 0, 0, 0.9999999, 4.3711385e-08, 0, -4.3711385e-08, 0.9999999, 0, 0, 0)
script = SubResource("GDScript_fjrip")
hand_material_override = SubResource("StandardMaterial3D_fjrip")
[node name="CollisionShape3D" type="CollisionShape3D" parent="XROrigin3D/leftHand/leftRigid" unique_id=1238387176]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.010949463, 0.012000024, -0.025)
shape = SubResource("BoxShape3D_6500s")
[node name="HingeJoint3D" type="HingeJoint3D" parent="XROrigin3D/leftHand/leftRigid" unique_id=1861056992]
angular_limit/enable = true
angular_limit/upper = 0.0
angular_limit/lower = 0.0
[node name="rightHand" type="XRController3D" parent="XROrigin3D" unique_id=73016062 node_paths=PackedStringArray("physicsHand")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 1, 0)
tracker = &"right_hand"
pose = &"grip"
script = ExtResource("4_smehm")
physicsHand = NodePath("rightRigid")
[node name="RightHand" parent="XROrigin3D/rightHand" unique_id=930822948 instance=ExtResource("2_qhqgy")]
hand_material_override = SubResource("StandardMaterial3D_g6ne4")
[node name="MovementJump" parent="XROrigin3D/rightHand" unique_id=1008127823 instance=ExtResource("5_ur7pv")]
jump_button_action = "ax_button"
[node name="MovementTurn" parent="XROrigin3D/rightHand" unique_id=685646321 instance=ExtResource("6_y4r1p")]
turn_mode = 2
[node name="FunctionPointer" parent="XROrigin3D/rightHand" unique_id=1536690438 instance=ExtResource("6_d2wvv")]
transform = Transform3D(1, 0, 0, 0, 0.70710677, 0.70710677, 0, -0.70710677, 0.70710677, -0.02, -0.03535534, -0.10606602)
show_laser = 2
laser_length = 1
show_target = true
[node name="rightRigid" type="RigidBody3D" parent="XROrigin3D/rightHand" unique_id=436660202]
transform = Transform3D(1, 0, 0, 0, 0.99927187, 0.03815463, 0, -0.03815463, 0.99927187, -0.41185614, -0.053098798, 0)
collision_layer = 4
collision_mask = 2
mass = 0.2
gravity_scale = 0.0
contact_monitor = true
max_contacts_reported = 1
linear_damp = 30.0
angular_damp = 30.0
[node name="RightPhysics" parent="XROrigin3D/rightHand/rightRigid" unique_id=1287548770 instance=ExtResource("2_qhqgy")]
script = SubResource("GDScript_fjrip")
hand_material_override = SubResource("StandardMaterial3D_smehm")
[node name="CollisionShape3D" type="CollisionShape3D" parent="XROrigin3D/rightHand/rightRigid" unique_id=1281593956]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0119018555, 0.012240827, -0.024719207)
shape = SubResource("BoxShape3D_6500s")
[node name="HingeJoint3D" type="HingeJoint3D" parent="XROrigin3D/rightHand/rightRigid" unique_id=657199832]
angular_limit/enable = true
angular_limit/upper = 0.0
angular_limit/lower = 0.0
[node name="PlayerBody" parent="XROrigin3D" unique_id=1152944339 instance=ExtResource("7_d2wvv")]
collision_mask = 1019
[connection signal="input_float_changed" from="XROrigin3D/leftHand" to="XROrigin3D/leftHand" method="_on_input_float_changed"]
[connection signal="body_entered" from="XROrigin3D/leftHand/leftRigid" to="XROrigin3D/leftHand" method="_rigid_body_entered"]
[connection signal="body_exited" from="XROrigin3D/leftHand/leftRigid" to="XROrigin3D/leftHand" method="_rigid_body_exited"]
[connection signal="input_float_changed" from="XROrigin3D/rightHand" to="XROrigin3D/rightHand" method="_on_input_float_changed"]
[connection signal="body_entered" from="XROrigin3D/rightHand/rightRigid" to="XROrigin3D/rightHand" method="_rigid_body_entered"]
[connection signal="body_exited" from="XROrigin3D/rightHand/rightRigid" to="XROrigin3D/rightHand" method="_rigid_body_exited"]
@@ -0,0 +1,106 @@
[gd_scene format=3 uid="uid://c8qjmks8fhg31"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_0wfyh"]
frequency = 0.0157
domain_warp_enabled = true
domain_warp_type = 2
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_ycumx"]
generate_mipmaps = false
noise = SubResource("FastNoiseLite_0wfyh")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_sugp2"]
albedo_color = Color(0.6901961, 0.40784314, 0.2509804, 1)
albedo_texture = SubResource("NoiseTexture2D_ycumx")
texture_filter = 0
[sub_resource type="BoxMesh" id="BoxMesh_i3k32"]
material = SubResource("StandardMaterial3D_sugp2")
size = Vector3(2.272461, 1.1293945, 1.0107422)
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_qqyfx"]
points = PackedVector3Array(1.1362305, 0.56469727, 0.5053711, 1.1362305, 0.56469727, -0.5053711, -1.1362305, 0.56469727, 0.5053711, 1.1362305, -0.56469727, 0.5053711, 1.1362305, -0.56469727, -0.5053711, -1.1362305, 0.56469727, -0.5053711, -1.1362305, -0.56469727, 0.5053711, -1.1362305, -0.56469727, -0.5053711)
[sub_resource type="BoxMesh" id="BoxMesh_xoo12"]
size = Vector3(0.5, 0.5, 0.5)
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_jptdg"]
points = PackedVector3Array(0.25, 0.25, 0.25, 0.25, 0.25, -0.25, -0.25, 0.25, 0.25, 0.25, -0.25, 0.25, 0.25, -0.25, -0.25, -0.25, 0.25, -0.25, -0.25, -0.25, 0.25, -0.25, -0.25, -0.25)
[sub_resource type="BoxMesh" id="BoxMesh_7kwhr"]
size = Vector3(0.1, 0.1, 0.1)
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_5l1qp"]
points = PackedVector3Array(0.05, 0.05, 0.05, 0.05, 0.05, -0.05, -0.05, 0.05, 0.05, 0.05, -0.05, 0.05, 0.05, -0.05, -0.05, -0.05, 0.05, -0.05, -0.05, -0.05, 0.05, -0.05, -0.05, -0.05)
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_ycumx"]
properties/0/path = NodePath("RigidBody3D:position")
properties/0/spawn = true
properties/0/replication_mode = 1
properties/1/path = NodePath("RigidBody3D:rotation")
properties/1/spawn = true
properties/1/replication_mode = 1
properties/2/path = NodePath("RigidBody3D2:position")
properties/2/spawn = true
properties/2/replication_mode = 1
properties/3/path = NodePath("RigidBody3D2:rotation")
properties/3/spawn = true
properties/3/replication_mode = 1
properties/4/path = NodePath("RigidBody3D3:position")
properties/4/spawn = true
properties/4/replication_mode = 1
properties/5/path = NodePath("RigidBody3D3:rotation")
properties/5/spawn = true
properties/5/replication_mode = 1
[node name="exampleTable" type="Node3D" unique_id=533933729]
[node name="table" type="StaticBody3D" parent="." unique_id=9248055]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.49472415, -0.013702869)
[node name="MeshInstance3D" type="MeshInstance3D" parent="table" unique_id=1202934761]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.064697266, 0)
mesh = SubResource("BoxMesh_i3k32")
[node name="CollisionShape3D" type="CollisionShape3D" parent="table" unique_id=381716225]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.064697266, 0)
shape = SubResource("ConvexPolygonShape3D_qqyfx")
[node name="RigidBody3D" type="RigidBody3D" parent="." unique_id=467181482]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1920929e-07, 1.5055698, 0.18077302)
collision_layer = 2
collision_mask = 7
mass = 5.0
[node name="MeshInstance3D" type="MeshInstance3D" parent="RigidBody3D" unique_id=826616356]
mesh = SubResource("BoxMesh_xoo12")
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D" unique_id=383882318]
shape = SubResource("ConvexPolygonShape3D_jptdg")
[node name="RigidBody3D2" type="RigidBody3D" parent="." unique_id=206301946]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.63646364, 1.5055698, 0.33767557)
collision_layer = 2
collision_mask = 7
mass = 0.5
[node name="MeshInstance3D" type="MeshInstance3D" parent="RigidBody3D2" unique_id=1396467381]
mesh = SubResource("BoxMesh_7kwhr")
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D2" unique_id=574768314]
shape = SubResource("ConvexPolygonShape3D_5l1qp")
[node name="RigidBody3D3" type="RigidBody3D" parent="." unique_id=1334427483]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.59675825, 1.5055698, 0.33208632)
collision_layer = 2
collision_mask = 7
mass = 0.5
[node name="MeshInstance3D" type="MeshInstance3D" parent="RigidBody3D3" unique_id=398678789]
mesh = SubResource("BoxMesh_7kwhr")
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D3" unique_id=274011370]
shape = SubResource("ConvexPolygonShape3D_5l1qp")
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="." unique_id=425044432]
replication_config = SubResource("SceneReplicationConfig_ycumx")