max strengh

This commit is contained in:
Snorre 2025-04-05 03:25:34 +02:00
parent 03359ccd04
commit 9beee62eed
5 changed files with 102 additions and 45 deletions

38
resources/player.tscn Normal file
View file

@ -0,0 +1,38 @@
[gd_scene load_steps=4 format=3 uid="uid://8fmy7u5fyonc"]
[ext_resource type="Script" uid="uid://bf27rxigs8b22" path="res://scripts/XRHand.cs" id="1_gyc3h"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_ij1v8"]
radius = 0.1
height = 0.2
[sub_resource type="SphereShape3D" id="SphereShape3D_iyx0m"]
radius = 0.01
[node name="XROrigin3D" type="XROrigin3D"]
current = true
[node name="LeftHand" type="XRController3D" parent="."]
tracker = &"left_hand"
script = ExtResource("1_gyc3h")
[node name="MeshInstance3D" type="MeshInstance3D" parent="LeftHand"]
mesh = SubResource("CapsuleMesh_ij1v8")
[node name="StaticBody3D" type="StaticBody3D" parent="LeftHand"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="LeftHand/StaticBody3D"]
shape = SubResource("SphereShape3D_iyx0m")
[node name="RightHand" type="XRController3D" parent="."]
tracker = &"right_hand"
[node name="MeshInstance3D" type="MeshInstance3D" parent="RightHand"]
mesh = SubResource("CapsuleMesh_ij1v8")
[node name="StaticBody3D" type="StaticBody3D" parent="RightHand"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="RightHand/StaticBody3D"]
shape = SubResource("SphereShape3D_iyx0m")
[node name="XRCamera3D" type="XRCamera3D" parent="."]

View file

@ -1,14 +1,7 @@
[gd_scene load_steps=11 format=3 uid="uid://din25343yu8wv"]
[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://bf27rxigs8b22" path="res://scripts/XRHand.cs" id="2_iyx0m"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_ij1v8"]
radius = 0.1
height = 0.2
[sub_resource type="SphereShape3D" id="SphereShape3D_iyx0m"]
radius = 0.01
[ext_resource type="Script" uid="uid://deiup1osipi8a" path="res://scripts/OverlapTester.cs" id="2_iyx0m"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_bl13t"]
@ -30,37 +23,9 @@ height = 0.113069
[node name="Node3D" type="Node3D"]
[node name="XROrigin3D" type="XROrigin3D" parent="."]
current = true
[node name="LeftHand" type="XRController3D" parent="XROrigin3D"]
tracker = &"left_hand"
script = ExtResource("2_iyx0m")
[node name="MeshInstance3D" type="MeshInstance3D" parent="XROrigin3D/LeftHand"]
mesh = SubResource("CapsuleMesh_ij1v8")
[node name="StaticBody3D" type="StaticBody3D" parent="XROrigin3D/LeftHand"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="XROrigin3D/LeftHand/StaticBody3D"]
shape = SubResource("SphereShape3D_iyx0m")
[node name="RightHand" type="XRController3D" parent="XROrigin3D"]
tracker = &"right_hand"
[node name="MeshInstance3D" type="MeshInstance3D" parent="XROrigin3D/RightHand"]
mesh = SubResource("CapsuleMesh_ij1v8")
[node name="StaticBody3D" type="StaticBody3D" parent="XROrigin3D/RightHand"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="XROrigin3D/RightHand/StaticBody3D"]
shape = SubResource("SphereShape3D_iyx0m")
[node name="XRCamera3D" type="XRCamera3D" parent="XROrigin3D"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("PlaneMesh_j5jx5")
skeleton = NodePath("../XROrigin3D")
skeleton = NodePath("")
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"]
@ -80,3 +45,10 @@ shape = SubResource("CapsuleShape3D_74lek")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="Bananan"]
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)

31
scripts/OverlapTester.cs Normal file
View file

@ -0,0 +1,31 @@
using Godot;
public partial class OverlapTester : Node3D
{
public override void _Ready()
{
GD.Print("Starting overlapper tester thingy");
}
public override void _Process(double delta)
{
var query = new PhysicsShapeQueryParameters3D();
var sphere = new SphereShape3D();
sphere.Radius = 0.1f;
query.Shape = sphere;
query.CollideWithBodies = true;
query.CollideWithAreas = false;
query.Transform = GlobalTransform;
var overlaps = GetWorld3D().DirectSpaceState.IntersectShape(query);
foreach (var fuckingcollider in overlaps)
{
try {
var collider = (RigidBody3D)fuckingcollider["collider"];
GD.Print(collider.Mass);
} catch (System.InvalidCastException) {
// dont care
}
}
}
}

View file

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

View file

@ -11,7 +11,7 @@ public partial class XRHand : XRController3D
[Export]
float strength = 1.0f;
public void _Update(float delta)
public override void _Process(double delta)
{
if ((bool)GetInput("trigger_click"))
{
@ -25,17 +25,32 @@ public partial class XRHand : XRController3D
var overlaps = GetWorld3D().DirectSpaceState.IntersectShape(query);
foreach (var fuckingcollider in overlaps)
{
var collider = (Node3D)fuckingcollider["collider"];
RigidBody3D body = null;
try
{
body = (RigidBody3D)fuckingcollider["collider"];
}
catch (System.InvalidCastException)
{
continue;
}
if (body.Mass > strength) {
continue;
}
Generic6DofJoint3D joint = new();
joint.NodeA = GetPathTo(body);
joint.NodeB = collider.GetPath();
joint.NodeB = body.GetPath();
joints.Add(joint);
AddChild(joint);
}
} else if (joints.Count > 0) {
foreach (var joint in joints)
joint.QueueFree();
joints.Clear();
}
else if (joints.Count > 0)
{
foreach (var joint in joints)
joint.QueueFree();
joints.Clear();
}
}
}