Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
backpack model updated
sanp_backpack updated: edited smaller snapzones to scale object that are snapped, this is done by scaling the snapzones parent object
removed beltsnapzones from the pickable scene as they do not work properly

Do Note:
this PR is only useable once the GodotVR#401 PR is merged
the changes right now are not going to work without the above mentioend PR
  • Loading branch information
DigitalN8m4r3 committed Mar 1, 2023
1 parent 9acca67 commit eb2657a
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 47 deletions.
12 changes: 2 additions & 10 deletions addons/godot-xr-tools/objects/inventory/inventory_backpack.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export var return_to_player : bool = false
# wait time for return to player bool
export var wait_time = 3

export (PackedScene) var backpack_scene

export var backpack_path: NodePath

# timer node to control the return to player time
Expand Down Expand Up @@ -38,12 +36,6 @@ func _ready():
snap.enabled = false


# compare object to weapon .tscns used in game to determine which it is
func check_inventory_scene(object):
if object.name.begins_with("SnapBackpack"):
return backpack_scene
return null

func _on_backpack_picked_up(_pickable):
# Enable all snap-zones when picked up by a hand/controller
if backpack.get_picked_up_by_controller():
Expand All @@ -67,7 +59,7 @@ func _on_backpack_dropped(_pickable):
for holster in shoulder_holster:
#put on empty shoulder slot if one is available
if holster.picked_up_object == null:
holster._pick_up_object(backpack)
holster.pick_up_object(backpack)

if return_to_player:
# example code to automatically return backpack
Expand All @@ -85,5 +77,5 @@ func _on_Timer_timeout():
for holster in shoulder_holster:
#put on empty shoulder slot if one is available
if holster.picked_up_object == null:
holster._pick_up_object(backpack)
holster.pick_up_object(backpack)
break
Binary file modified assets/quaternius/Backpack/model/backpack.glb
Binary file not shown.
152 changes: 124 additions & 28 deletions scenes/pickable_demo/objects/snap_backpack.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=9 format=2]

[ext_resource path="res://addons/godot-xr-tools/objects/Snap_Zone.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/godot-xr-tools/objects/pickable.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-xr-tools/objects/snap_zone.tscn" type="PackedScene" id=5]
[ext_resource path="res://assets/quaternius/Backpack/model/backpack.glb" type="PackedScene" id=7]
Expand All @@ -20,6 +19,7 @@ script = ExtResource( 2 )
__meta__ = {
"_editor_description_": ""
}
picked_up_layer = 1114112

[node name="GrabPointHandLeft" parent="." instance=ExtResource( 13 )]
transform = Transform( -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 0.999999, 0.050919, 0.296961, 0.0741629 )
Expand All @@ -43,58 +43,141 @@ __meta__ = {

[node name="In" type="Spatial" parent="."]

[node name="SnapZone1" parent="In" instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.120223, 0.126457, 0.135 )
[node name="SnapArea1" type="MeshInstance" parent="In"]
transform = Transform( 0.75, 0, 0, 0, -3.27835e-08, -0.75, 0, 0.75, -3.27835e-08, -0.12, 0.126, 0.145 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone1" parent="In/SnapArea1" instance=ExtResource( 5 )]
__meta__ = {
"_editor_description_": ""
}
grab_distance = 0.05
snap_exclude = "Weapons"

[node name="Sprite3D" type="Sprite3D" parent="In/SnapZone1"]
transform = Transform( 0.075, 0, 0, 0, -3.27835e-09, 1, 0, -0.075, -4.37114e-08, 0, 0, 0 )
[node name="HighlightRing" type="Sprite3D" parent="In/SnapArea1/SnapZone1"]
transform = Transform( 0.075, 0, 0, 0, -3.27835e-09, -1, 0, 0.075, -4.37114e-08, 0, 0, 0 )
texture = ExtResource( 12 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone2" parent="In" instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.12, 0.126, 0.135 )
[node name="SnapArea2" type="MeshInstance" parent="In"]
transform = Transform( 0.75, 0, 0, 0, -3.27835e-08, -0.75, 0, 0.75, -3.27835e-08, 0.12, 0.126, 0.145 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone1" parent="In/SnapArea2" instance=ExtResource( 5 )]
__meta__ = {
"_editor_description_": ""
}
grab_distance = 0.05
snap_exclude = "Weapons"

[node name="Sprite3D" type="Sprite3D" parent="In/SnapZone2"]
transform = Transform( 0.075, 0, 0, 0, -3.27835e-09, 1, 0, -0.075, -4.37114e-08, 0, 0, 0 )
[node name="HighlightRing" type="Sprite3D" parent="In/SnapArea2/SnapZone1"]
transform = Transform( 0.075, 0, 0, 0, -3.27835e-09, -1, 0, 0.075, -4.37114e-08, 0, 0, 0 )
texture = ExtResource( 12 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone3" parent="In" instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.120223, -0.126, 0.135 )
[node name="SnapArea3" type="MeshInstance" parent="In"]
transform = Transform( 0.75, 0, 0, 0, -3.27835e-08, -0.75, 0, 0.75, -3.27835e-08, -0.12, 0, 0.145 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone1" parent="In/SnapArea3" instance=ExtResource( 5 )]
__meta__ = {
"_editor_description_": ""
}
grab_distance = 0.05
snap_exclude = "Weapons"

[node name="Sprite3D" type="Sprite3D" parent="In/SnapZone3"]
transform = Transform( 0.075, 0, 0, 0, -3.27835e-09, 1, 0, -0.075, -4.37114e-08, 0, 0, 0 )
[node name="HighlightRing" type="Sprite3D" parent="In/SnapArea3/SnapZone1"]
transform = Transform( 0.075, 0, 0, 0, -3.27835e-09, -1, 0, 0.075, -4.37114e-08, 0, 0, 0 )
texture = ExtResource( 12 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone4" parent="In" instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.12, -0.126, 0.135 )
[node name="SnapArea4" type="MeshInstance" parent="In"]
transform = Transform( 0.75, 0, 0, 0, -3.27835e-08, -0.75, 0, 0.75, -3.27835e-08, 0.12, 0, 0.145 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone1" parent="In/SnapArea4" instance=ExtResource( 5 )]
__meta__ = {
"_editor_description_": ""
}
grab_distance = 0.05
snap_exclude = "Weapons"

[node name="Sprite3D" type="Sprite3D" parent="In/SnapZone4"]
transform = Transform( 0.075, 0, 0, 0, -3.27835e-09, 1, 0, -0.075, -4.37114e-08, 0, 0, 0 )
[node name="HighlightRing" type="Sprite3D" parent="In/SnapArea4/SnapZone1"]
transform = Transform( 0.075, 0, 0, 0, -3.27835e-09, -1, 0, 0.075, -4.37114e-08, 0, 0, 0 )
texture = ExtResource( 12 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZoneKnife" parent="In" instance=ExtResource( 5 )]
[node name="SnapArea5" type="MeshInstance" parent="In"]
transform = Transform( 0.75, 0, 0, 0, -3.27835e-08, -0.75, 0, 0.75, -3.27835e-08, -0.120223, -0.126, 0.145 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone1" parent="In/SnapArea5" instance=ExtResource( 5 )]
__meta__ = {
"_editor_description_": ""
}
grab_distance = 0.05
snap_exclude = "Weapons"

[node name="HighlightRing" type="Sprite3D" parent="In/SnapArea5/SnapZone1"]
transform = Transform( 0.075, 0, 0, 0, -3.27835e-09, -1, 0, 0.075, -4.37114e-08, 0, 0, 0 )
texture = ExtResource( 12 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapArea6" type="MeshInstance" parent="In"]
transform = Transform( 0.75, 0, 0, 0, -3.27835e-08, -0.75, 0, 0.75, -3.27835e-08, 0.12, -0.126, 0.145 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone1" parent="In/SnapArea6" instance=ExtResource( 5 )]
__meta__ = {
"_editor_description_": ""
}
grab_distance = 0.05
snap_exclude = "Weapons"

[node name="HighlightRing" type="Sprite3D" parent="In/SnapArea6/SnapZone1"]
transform = Transform( 0.075, 0, 0, 0, -3.27835e-09, -1, 0, 0.075, -4.37114e-08, 0, 0, 0 )
texture = ExtResource( 12 )
__meta__ = {
"_editor_description_": ""
}

[node name="KnifeArea" type="MeshInstance" parent="In"]
transform = Transform( -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, -0.019, 0.15 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone1" parent="In/KnifeArea" instance=ExtResource( 5 )]
__meta__ = {
"_editor_description_": ""
}
grab_distance = 0.05
snap_require = "Knife"
snap_exclude = "Heavy"

[node name="Sprite3D" type="Sprite3D" parent="In/SnapZoneKnife"]
[node name="HighlightRing" type="Sprite3D" parent="In/KnifeArea/SnapZone1"]
transform = Transform( -3.27835e-09, 0.075, 0, -0.075, -3.27835e-09, 0, 0, 0, 0.1, 0, 0, 0 )
texture = ExtResource( 8 )
__meta__ = {
Expand All @@ -103,28 +186,41 @@ __meta__ = {

[node name="Out" type="Spatial" parent="."]

[node name="SnapZone1" parent="Out" groups=["User"] instance=ExtResource( 1 )]
transform = Transform( -1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1, 0.256364, 0.212929, 0.021 )
[node name="HeavyArea1" type="MeshInstance" parent="Out"]
transform = Transform( -1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1, 0.256, 0.213, 0.021 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone1" parent="Out/HeavyArea1" instance=ExtResource( 5 )]
__meta__ = {
"_editor_description_": ""
}
grab_distance = 0.15
snap_require = "Heavy"

[node name="Sprite3D" type="Sprite3D" parent="Out/SnapZone1"]
transform = Transform( -4.37114e-09, 0, 0.1, 0, 0.1, 0, -0.1, 0, -4.37114e-09, 0.0218272, 0.284689, 0 )
[node name="HighlightRing" type="Sprite3D" parent="Out/HeavyArea1/SnapZone1"]
transform = Transform( -4.37114e-09, 1.95399e-14, 0.1, 8.47033e-22, 0.1, -1.95399e-14, -0.1, -7.08435e-24, -4.37114e-09, 0.022, 0.285, 0 )
texture = ExtResource( 8 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone2" parent="Out" groups=["User"] instance=ExtResource( 1 )]
transform = Transform( -1, -1.50996e-07, 0, 1.50996e-07, -1, 0, 0, 0, 1, -0.256, 0.213, 0.021 )
[node name="HeavyArea2" type="MeshInstance" parent="Out"]
transform = Transform( -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0, 1, -0.256, 0.213, 0.021 )
__meta__ = {
"_editor_description_": ""
}

[node name="SnapZone1" parent="Out/HeavyArea2" instance=ExtResource( 5 )]
__meta__ = {
"_editor_description_": ""
}
grab_distance = 0.15
snap_require = "Heavy"

[node name="Sprite3D" type="Sprite3D" parent="Out/SnapZone2"]
transform = Transform( -4.37114e-09, 0, 0.1, 0, 0.1, 0, -0.1, 0, -4.37114e-09, -0.022, 0.285, 0 )
[node name="HighlightRing" type="Sprite3D" parent="Out/HeavyArea2/SnapZone1"]
transform = Transform( -4.37114e-09, 1.95399e-14, 0.1, 8.47033e-22, 0.1, -1.95399e-14, -0.1, -7.08435e-24, -4.37114e-09, -0.022, 0.285, 0 )
texture = ExtResource( 8 )
__meta__ = {
"_editor_description_": ""
Expand Down
10 changes: 1 addition & 9 deletions scenes/pickable_demo/pickable_demo.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=28 format=2]
[gd_scene load_steps=27 format=2]

[ext_resource path="res://addons/godot-xr-tools/staging/scene_base.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/maps/basic_map.tscn" type="PackedScene" id=2]
Expand All @@ -22,7 +22,6 @@
[ext_resource path="res://scenes/pickable_demo/objects/saucer.tscn" type="PackedScene" id=20]
[ext_resource path="res://scenes/pickable_demo/objects/teacup_stand.tscn" type="PackedScene" id=21]
[ext_resource path="res://scenes/pickable_demo/objects/instructions.tscn" type="PackedScene" id=22]
[ext_resource path="res://scenes/pickable_demo/objects/BeltSnapZone.tscn" type="PackedScene" id=23]
[ext_resource path="res://scenes/pickable_demo/objects/knife.tscn" type="PackedScene" id=24]
[ext_resource path="res://addons/godot-xr-tools/objects/inventory/inventory_backpack.tscn" type="PackedScene" id=25]
[ext_resource path="res://addons/godot-xr-tools/objects/inventory/BackpackSnapZone.tscn" type="PackedScene" id=26]
Expand Down Expand Up @@ -66,14 +65,7 @@ laser_length = 1

[node name="PlayerBody" parent="ARVROrigin" index="3" instance=ExtResource( 9 )]

[node name="BeltSnapZone01" parent="ARVROrigin/PlayerBody" index="0" instance=ExtResource( 23 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.2, 1, -0.15 )

[node name="BeltSnapZone02" parent="ARVROrigin/PlayerBody" index="1" instance=ExtResource( 23 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, 1, -0.15 )

[node name="InventoryBackpack" parent="ARVROrigin" index="4" instance=ExtResource( 25 )]
backpack_scene = ExtResource( 27 )
backpack_path = NodePath("SnapBackpack")

[node name="SnapBackpack" parent="ARVROrigin/InventoryBackpack" index="0" instance=ExtResource( 27 )]
Expand Down

0 comments on commit eb2657a

Please sign in to comment.