first
This commit is contained in:
127
Maps/Spaceship/Objects/Grabable/FuelCanister.tscn
Normal file
127
Maps/Spaceship/Objects/Grabable/FuelCanister.tscn
Normal file
File diff suppressed because one or more lines are too long
19
Maps/Spaceship/Objects/Grabable/GrabBox.gd
Normal file
19
Maps/Spaceship/Objects/Grabable/GrabBox.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Area3D
|
||||
class_name GrabBox
|
||||
|
||||
signal grabbedByPlayer
|
||||
@export var obj: GrabableObject
|
||||
@export var type: String #Used to signify the type of Object for other code interacting with the grab box
|
||||
@export var heavy: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
set_collision_layer_value(5,true) #Enables Grabing colision layer
|
||||
set_collision_layer_value(1,false) #Disables Default collision layer
|
||||
set_collision_mask_value(1,false)
|
||||
|
||||
func grab() -> GrabableObject:
|
||||
if !obj: return
|
||||
if !obj.isGrabbed:
|
||||
grabbedByPlayer.emit()
|
||||
return obj
|
||||
return null
|
||||
1
Maps/Spaceship/Objects/Grabable/GrabBox.gd.uid
Normal file
1
Maps/Spaceship/Objects/Grabable/GrabBox.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cmo8m6v4wlw2y
|
||||
33
Maps/Spaceship/Objects/Grabable/GrabableObject.gd
Normal file
33
Maps/Spaceship/Objects/Grabable/GrabableObject.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
extends RigidBody3D
|
||||
class_name GrabableObject
|
||||
|
||||
@export var grabBox: GrabBox
|
||||
|
||||
var isGrabbed: bool = false
|
||||
@export var grabPositionPositionOffset: Vector3
|
||||
@export var grabPositionRotationOffset: Vector3
|
||||
@export var putDownPositionOffset: Vector3
|
||||
@export var throwingForce = 8.0 #How strong objects are thrown
|
||||
|
||||
func _ready() -> void:
|
||||
grabBox = $GrabBox
|
||||
grabBox.grabbedByPlayer.connect(grab.rpc.bind(multiplayer.get_unique_id()))
|
||||
set_collision_layer_value(1,false) #Disables default collision layer
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local")
|
||||
func grab(id):
|
||||
isGrabbed = true
|
||||
freeze = true
|
||||
if not get_multiplayer_authority() == id:
|
||||
set_multiplayer_authority(id)
|
||||
|
||||
@rpc("authority", "call_local")
|
||||
func release():
|
||||
isGrabbed = false
|
||||
freeze = false
|
||||
set_multiplayer_authority(1)
|
||||
|
||||
@rpc("any_peer","call_local")
|
||||
func throw(facingDirectionX,facingDirectionY,cameraRotationX):
|
||||
linear_velocity = Vector3(facingDirectionX,cameraRotationX/PI*2+0.3,facingDirectionY) * throwingForce
|
||||
1
Maps/Spaceship/Objects/Grabable/GrabableObject.gd.uid
Normal file
1
Maps/Spaceship/Objects/Grabable/GrabableObject.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dkss4o54xymwj
|
||||
127
Maps/Spaceship/Objects/Grabable/PowerCell.tscn
Normal file
127
Maps/Spaceship/Objects/Grabable/PowerCell.tscn
Normal file
File diff suppressed because one or more lines are too long
54
Maps/Spaceship/Objects/Grabable/RepairCube.tscn
Normal file
54
Maps/Spaceship/Objects/Grabable/RepairCube.tscn
Normal file
@@ -0,0 +1,54 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://wo0ikejk0hag"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dkss4o54xymwj" path="res://Maps/Spaceship/Objects/Grabable/GrabableObject.gd" id="1_jgf10"]
|
||||
[ext_resource type="Script" uid="uid://cmo8m6v4wlw2y" path="res://Maps/Spaceship/Objects/Grabable/GrabBox.gd" id="2_yocvc"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_61j30"]
|
||||
size = Vector3(0.5, 0.5, 0.5)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_qey0m"]
|
||||
size = Vector3(0.5, 0.5, 0.5)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_4unh8"]
|
||||
size = Vector3(0.5, 0.5, 0.5)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_utenr"]
|
||||
albedo_color = Color(0.111197, 0.111197, 0.111197, 1)
|
||||
metallic = 1.0
|
||||
roughness = 0.3
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_yocvc"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:rotation")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
|
||||
[node name="RepairCube" type="RigidBody3D" node_paths=PackedStringArray("grabBox")]
|
||||
script = ExtResource("1_jgf10")
|
||||
grabBox = NodePath("GrabBox")
|
||||
throwingForce = 2.0
|
||||
metadata/_custom_type_script = "uid://dkss4o54xymwj"
|
||||
|
||||
[node name="GrabBox" type="Area3D" parent="." node_paths=PackedStringArray("obj")]
|
||||
script = ExtResource("2_yocvc")
|
||||
obj = NodePath("..")
|
||||
type = "RepairCube"
|
||||
heavy = true
|
||||
metadata/_custom_type_script = "uid://cmo8m6v4wlw2y"
|
||||
|
||||
[node name="GrabShape" type="CollisionShape3D" parent="GrabBox"]
|
||||
shape = SubResource("BoxShape3D_61j30")
|
||||
debug_fill = false
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("BoxShape3D_qey0m")
|
||||
debug_fill = false
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("BoxMesh_4unh8")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_utenr")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_yocvc")
|
||||
1322
Maps/Spaceship/Objects/Grabable/boombox_1.tscn
Normal file
1322
Maps/Spaceship/Objects/Grabable/boombox_1.tscn
Normal file
File diff suppressed because one or more lines are too long
186
Maps/Spaceship/Objects/Grabable/toolbox.tscn
Normal file
186
Maps/Spaceship/Objects/Grabable/toolbox.tscn
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user