added the ability to grab bananer
This commit is contained in:
parent
bf598a7682
commit
03359ccd04
|
@ -20,6 +20,9 @@
|
|||
godot_4-mono
|
||||
];
|
||||
};
|
||||
shellHook = ''
|
||||
godot4-mono -e 2>/dev/null 1>&2 & disown
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ config_version=5
|
|||
[application]
|
||||
|
||||
config/name="nordic25"
|
||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
||||
config/features=PackedStringArray("4.4", "C#", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[dotnet]
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class XrOrigin3d : XROrigin3D
|
||||
{
|
||||
private XRInterface _xrInterface;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_xrInterface = XRServer.FindInterface("OpenXR");
|
||||
if (_xrInterface == null || !_xrInterface.IsInitialized())
|
||||
GD.PushError("Failed to initialize OpenXR");
|
||||
|
||||
GD.PushError("OpenXR Initialized successfully");
|
||||
|
||||
DisplayServer.WindowSetVsyncMode(DisplayServer.VSyncMode.Disabled);
|
||||
GetViewport().UseXR = true;
|
||||
}
|
||||
}
|
|
@ -1,27 +1,82 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://din25343yu8wv"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://din25343yu8wv"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dglj0x0bpkx5i" path="res://scenes/XrOrigin3d.cs" id="1_errlg"]
|
||||
[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
|
||||
height = 0.02
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_bl13t"]
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_iyx0m"]
|
||||
noise = SubResource("FastNoiseLite_bl13t")
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_74lek"]
|
||||
albedo_texture = SubResource("NoiseTexture2D_iyx0m")
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_j5jx5"]
|
||||
material = SubResource("StandardMaterial3D_74lek")
|
||||
size = Vector2(20, 20)
|
||||
|
||||
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_lpvoh"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_74lek"]
|
||||
radius = 0.02
|
||||
height = 0.113069
|
||||
|
||||
[node name="Node3D" type="Node3D"]
|
||||
|
||||
[node name="XROrigin3D" type="XROrigin3D" parent="."]
|
||||
current = true
|
||||
script = ExtResource("1_errlg")
|
||||
|
||||
[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")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"]
|
||||
shape = SubResource("WorldBoundaryShape3D_lpvoh")
|
||||
|
||||
[node name="Bananan" type="RigidBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0676612, 0.724976, -0.380918)
|
||||
|
||||
[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)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Bananan"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.816107, -0.5779, 0, 0.5779, 0.816107, 0, -0.0504407, -0.0107305)
|
||||
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")
|
||||
|
|
41
scripts/XRHand.cs
Normal file
41
scripts/XRHand.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class XRHand : XRController3D
|
||||
{
|
||||
List<Generic6DofJoint3D> joints = new();
|
||||
|
||||
[Export]
|
||||
StaticBody3D body;
|
||||
|
||||
[Export]
|
||||
float strength = 1.0f;
|
||||
|
||||
public void _Update(float 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)
|
||||
{
|
||||
var collider = (Node3D)fuckingcollider["collider"];
|
||||
Generic6DofJoint3D joint = new();
|
||||
joint.NodeA = GetPathTo(body);
|
||||
joint.NodeB = collider.GetPath();
|
||||
joints.Add(joint);
|
||||
AddChild(joint);
|
||||
}
|
||||
} else if (joints.Count > 0) {
|
||||
foreach (var joint in joints)
|
||||
joint.QueueFree();
|
||||
joints.Clear();
|
||||
}
|
||||
}
|
||||
}
|
1
scripts/XRHand.cs.uid
Normal file
1
scripts/XRHand.cs.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://bf27rxigs8b22
|
19
scripts/XrOrigin3d.cs
Normal file
19
scripts/XrOrigin3d.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class XrOrigin3d : XROrigin3D
|
||||
{
|
||||
private XRInterface _xrInterface;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_xrInterface = XRServer.FindInterface("OpenXR");
|
||||
if (_xrInterface == null || !_xrInterface.IsInitialized())
|
||||
GD.PushError("Failed to initialize OpenXR");
|
||||
|
||||
GD.PushError("OpenXR Initialized successfully");
|
||||
|
||||
DisplayServer.WindowSetVsyncMode(DisplayServer.VSyncMode.Disabled);
|
||||
GetViewport().UseXR = true;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue