This commit is contained in:
Snorre 2025-04-05 18:46:38 +02:00
parent bcf363d798
commit ffeaf1aaa8
6 changed files with 37 additions and 24 deletions

View file

@ -11,6 +11,7 @@ config_version=5
[application]
config/name="nordic25"
run/main_scene="uid://din25343yu8wv"
config/features=PackedStringArray("4.4", "C#", "Forward Plus")
config/icon="res://icon.svg"

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=8 format=3 uid="uid://8fmy7u5fyonc"]
[ext_resource type="Script" uid="uid://bf27rxigs8b22" path="res://scripts/XRHand.cs" id="1_gyc3h"]
[ext_resource type="Script" uid="uid://dglj0x0bpkx5i" path="res://scripts/XrOrigin3d.cs" id="1_ucfva"]
[ext_resource type="Script" uid="uid://cjuwcdex32ad0" path="res://scripts/GrabTester.cs" id="3_graai"]
[ext_resource type="Script" uid="uid://typrll7n6g3e" path="res://scripts/Mouth.cs" id="3_un1ji"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_ij1v8"]
@ -19,13 +19,12 @@ radius = 0.03
[node name="XROrigin3D" type="XROrigin3D"]
current = true
script = ExtResource("1_ucfva")
[node name="LeftHand" type="XRController3D" parent="." node_paths=PackedStringArray("body")]
[node name="LeftHand" type="XRController3D" parent="." node_paths=PackedStringArray("rb")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.381652, 0.302346, 0)
tracker = &"left_hand"
script = ExtResource("1_gyc3h")
body = NodePath("RigidBody3D")
rb = NodePath("RigidBody3D")
[node name="MeshInstance3D" type="MeshInstance3D" parent="LeftHand"]
mesh = SubResource("CapsuleMesh_ij1v8")
@ -43,11 +42,9 @@ disabled = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="LeftHand/Area3D"]
shape = SubResource("SphereShape3D_un1ji")
[node name="RightHand" type="XRController3D" parent="." node_paths=PackedStringArray("body")]
[node name="RightHand" type="XRController3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.412168, 0.292391, 0)
tracker = &"right_hand"
script = ExtResource("1_gyc3h")
body = NodePath("RigidBody3D")
[node name="MeshInstance3D" type="MeshInstance3D" parent="RightHand"]
mesh = SubResource("CapsuleMesh_ij1v8")
@ -55,6 +52,7 @@ mesh = SubResource("CapsuleMesh_ij1v8")
[node name="RigidBody3D" type="RigidBody3D" parent="RightHand"]
freeze = true
freeze_mode = 1
script = ExtResource("3_graai")
[node name="CollisionShape3D" type="CollisionShape3D" parent="RightHand/RigidBody3D"]
shape = SubResource("SphereShape3D_iyx0m")
@ -66,7 +64,7 @@ disabled = true
shape = SubResource("SphereShape3D_un1ji")
[node name="XRCamera3D" type="XRCamera3D" parent="." node_paths=PackedStringArray("RightHand", "LeftHand")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.821388, 0.40056)
transform = Transform3D(0.447029, 0.69956, -0.557478, -0.351336, 0.710443, 0.609782, 0.822635, -0.0767277, 0.563369, 0, 0.821388, 0.40056)
near = 0.005
script = ExtResource("3_un1ji")
RightHand = NodePath("../RightHand")
@ -86,5 +84,6 @@ shape = SubResource("SphereShape3D_ucfva")
[connection signal="button_pressed" from="RightHand" to="RightHand" method="OnPress"]
[connection signal="button_released" from="RightHand" to="RightHand" method="OnRelease"]
[connection signal="input_float_changed" from="RightHand" to="RightHand" method="OnFloat"]
[connection signal="SpamGrab" from="RightHand/RigidBody3D" to="RightHand" method="OnPress"]
[connection signal="body_entered" from="RightHand/Area3D" to="RightHand" method="OnEnter"]
[connection signal="body_exited" from="RightHand/Area3D" to="RightHand" method="OnLeave"]

View file

@ -33,7 +33,9 @@ skeleton = NodePath("")
shape = SubResource("WorldBoundaryShape3D_lpvoh")
[node name="Bananan" type="RigidBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0676612, 0.46696, -0.00682727)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3997, 0.647031, -0.00682727)
gravity_scale = 0.01
can_sleep = false
[node name="banana" parent="Bananan" instance=ExtResource("2_bl13t")]
transform = Transform3D(0.02, 0, 0, 0, 0.02, 0, 0, 0, 0.02, 0, 0, 0)

12
scripts/GrabTester.cs Normal file
View file

@ -0,0 +1,12 @@
using Godot;
public partial class GrabTester : RigidBody3D {
[Signal]
public delegate void SpamGrabEventHandler(string name);
public override void _Process(double delta) {
EmitSignal(SignalName.SpamGrab, "select_button");
}
}

View file

@ -0,0 +1 @@
uid://cjuwcdex32ad0

View file

@ -3,16 +3,21 @@ using System.Collections.Generic;
public partial class XRHand : XRController3D
{
List<PinJoint3D> joints = new();
List<Generic6DofJoint3D> joints = new();
[Export]
RigidBody3D body;
RigidBody3D rb;
List<RigidBody3D> overlaps;
List<RigidBody3D> overlaps = new();
[Export]
public float Strength = 1.0f;
public override void _Ready() {
if (rb == null)
GD.PrintErr("Missing Rigidbody");
}
public void OnEnter(Node3D node)
{
try
@ -44,26 +49,19 @@ public partial class XRHand : XRController3D
GD.Print("Picked up ", body);
PinJoint3D joint = new();
Generic6DofJoint3D joint = new();
joint.NodeA = body.GetPath();
joint.NodeB = this.body.GetPath();
joint.SetParam(PinJoint3D.Param.Bias, 10f);
joint.NodeB = rb.GetPath();
joints.Add(joint);
PinJoint3D joint2 = new();
joint2.NodeA = this.body.GetPath();
joint2.NodeB = body.GetPath();
joint2.SetParam(PinJoint3D.Param.Bias, 10f);
joints.Add(joint2);
this.body.AddChild(joint);
body.AddChild(joint2);
rb.AddChild(joint);
joint.Position = Vector3.Zero;
}
}
}
public void OnRelease(string name)
{
GD.Print("lego");
if (name == "select_button")
{
foreach (var joint in joints)