summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Main.tscn18
-rw-r--r--Raft.gd8
-rw-r--r--World.gd16
-rw-r--r--project.godot20
4 files changed, 61 insertions, 1 deletions
diff --git a/Main.tscn b/Main.tscn
index 5b62675..887edee 100644
--- a/Main.tscn
+++ b/Main.tscn
@@ -1,10 +1,12 @@
-[gd_scene load_steps=13 format=2]
+[gd_scene load_steps=17 format=2]
[ext_resource path="res://character/fps_controller/fps_controller.tscn" type="PackedScene" id=1]
[ext_resource path="res://ship/ship/ship.tscn" type="PackedScene" id=2]
[ext_resource path="res://water/Water.tscn" type="PackedScene" id=3]
[ext_resource path="res://Float.tscn" type="PackedScene" id=4]
[ext_resource path="res://ship/ship/crate.tscn" type="PackedScene" id=5]
+[ext_resource path="res://World.gd" type="Script" id=5]
+[ext_resource path="res://Raft.gd" type="Script" id=6]
[sub_resource type="BoxShape" id=19]
extents = Vector3( 1000, 0.1, 1000 )
@@ -69,6 +71,7 @@ axis_lock_linear_x = true
axis_lock_linear_z = true
linear_damp = 2.0
angular_damp = 2.0
+script = ExtResource( 6 )
[node name="CollisionShape" type="CollisionShape" parent="ShipRigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.78898, 0 )
@@ -120,6 +123,19 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 9.77011, -3.30323, -49.022 )
[node name="crates" type="Spatial" parent="."]
+[node name="World" type="RigidBody" parent="."]
+collision_layer = 0
+collision_mask = 0
+axis_lock_linear_y = true
+axis_lock_angular_x = true
+axis_lock_angular_y = true
+axis_lock_angular_z = true
+linear_damp = 0.5
+script = ExtResource( 5 )
+
+[node name="CollisionShape" type="CollisionShape" parent="World"]
+shape = SubResource( 22 )
+
[node name="crate" parent="crates" instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.56126, 0 )
diff --git a/Raft.gd b/Raft.gd
new file mode 100644
index 0000000..75f5f63
--- /dev/null
+++ b/Raft.gd
@@ -0,0 +1,8 @@
+extends RigidBody
+
+export var ang_acceleration = 60.0
+
+func _integrate_forces(_state):
+ var stick = Input.get_axis("ship_right","ship_left")
+ if stick != 0.0:
+ self.add_torque(Vector3.UP*stick*ang_acceleration)
diff --git a/World.gd b/World.gd
new file mode 100644
index 0000000..09b8e85
--- /dev/null
+++ b/World.gd
@@ -0,0 +1,16 @@
+extends RigidBody
+
+export var acceleration = 10.0;
+
+func travel(direction:Vector3):
+ var boat_direction = $"/root/Main/Raft".global_transform.basis
+ boat_direction = Basis(Vector3.UP*boat_direction.get_euler().y)
+ direction = -direction
+ direction = boat_direction * direction
+ direction = direction.normalized()
+ self.add_central_force(direction*acceleration)
+
+func _integrate_forces(_state):
+ var stick = Input.get_axis("ship_down","ship_up")
+ if stick != 0.0:
+ travel(Vector3.FORWARD*stick)
diff --git a/project.godot b/project.godot
index fcde3af..13b5902 100644
--- a/project.godot
+++ b/project.godot
@@ -76,6 +76,26 @@ jump={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
+ship_up={
+"deadzone": 0.5,
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+ ]
+}
+ship_down={
+"deadzone": 0.5,
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+ ]
+}
+ship_left={
+"deadzone": 0.5,
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+ ]
+}
+ship_right={
+"deadzone": 0.5,
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+ ]
+}
[physics]