diff --git a/scenes/test.tscn b/scenes/test.tscn index 2891b17..cec547b 100644 --- a/scenes/test.tscn +++ b/scenes/test.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=9 format=3 uid="uid://din25343yu8wv"] [ext_resource type="PackedScene" uid="uid://csh2n73hb2co8" path="res://models/banana.fbx" id="2_bl13t"] -[ext_resource type="Script" uid="uid://deiup1osipi8a" path="res://scripts/OverlapTester.cs" id="2_iyx0m"] +[ext_resource type="PackedScene" uid="uid://8fmy7u5fyonc" path="res://resources/player.tscn" id="2_iyx0m"] [sub_resource type="FastNoiseLite" id="FastNoiseLite_bl13t"] @@ -46,9 +46,4 @@ shape = SubResource("CapsuleShape3D_74lek") transform = Transform3D(1, 0, 0, 0, -0.837394, -0.546599, 0, 0.546599, -0.837394, 0, 0.025557, -0.00612295) shape = SubResource("CapsuleShape3D_74lek") -[node name="Node3D" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.065958, 0, -0.366133) -script = ExtResource("2_iyx0m") - -[node name="Camera3D" type="Camera3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.351838, 0.598454) +[node name="Player" parent="." instance=ExtResource("2_iyx0m")] diff --git a/scripts/XRHand.cs b/scripts/XRHand.cs index 416ff5a..6f0ef3d 100644 --- a/scripts/XRHand.cs +++ b/scripts/XRHand.cs @@ -3,54 +3,54 @@ using System.Collections.Generic; public partial class XRHand : XRController3D { - List joints = new(); + List joints = new(); - [Export] - StaticBody3D body; + [Export] + StaticBody3D body; - [Export] - float strength = 1.0f; + [Export] + float strength = 1.0f; - public override void _Process(double delta) - { - if ((bool)GetInput("trigger_click")) - { - var query = new PhysicsShapeQueryParameters3D(); - var sphere = new SphereShape3D(); - sphere.Radius = 0.1f; - query.Shape = sphere; - query.CollideWithBodies = true; - query.CollideWithAreas = false; - query.Transform = ((Node3D)GetParent()).GlobalTransform; - var overlaps = GetWorld3D().DirectSpaceState.IntersectShape(query); - foreach (var fuckingcollider in overlaps) - { - RigidBody3D body = null; - try - { - body = (RigidBody3D)fuckingcollider["collider"]; - } - catch (System.InvalidCastException) - { - continue; - } + public override void _Process(double delta) + { + if ((bool)GetInput("trigger_click")) + { + var query = new PhysicsShapeQueryParameters3D(); + var sphere = new SphereShape3D(); + sphere.Radius = 0.1f; + query.Shape = sphere; + query.CollideWithBodies = true; + query.CollideWithAreas = false; + query.Transform = ((Node3D)GetParent()).GlobalTransform; + var overlaps = GetWorld3D().DirectSpaceState.IntersectShape(query); + foreach (var fuckingcollider in overlaps) + { + RigidBody3D body = null; + try + { + body = (RigidBody3D)fuckingcollider["collider"]; + } + catch (System.InvalidCastException) + { + continue; + } - if (body.Mass > strength) { - continue; - } + if (body.Mass > strength) { + continue; + } - Generic6DofJoint3D joint = new(); - joint.NodeA = GetPathTo(body); - joint.NodeB = body.GetPath(); - joints.Add(joint); - AddChild(joint); - } - } - else if (joints.Count > 0) - { - foreach (var joint in joints) - joint.QueueFree(); - joints.Clear(); - } - } + Generic6DofJoint3D joint = new(); + joint.NodeA = GetPathTo(body); + joint.NodeB = body.GetPath(); + joints.Add(joint); + AddChild(joint); + } + } + else if (joints.Count > 0) + { + foreach (var joint in joints) + joint.QueueFree(); + joints.Clear(); + } + } }