summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-09-16 07:01:09 -0400
committerdusoleil <howcansocksbereal@gmail.com>2022-09-16 07:01:09 -0400
commit65baf0c396004d2ea36a871824898abc88f5977a (patch)
treeff5ec2e45d9d554547689af8f49226d42fb375fa
parentd2388741536636f91643fb1c60e02bb8c20b31ae (diff)
downloadgodot_wildjam_49-65baf0c396004d2ea36a871824898abc88f5977a.tar.gz
godot_wildjam_49-65baf0c396004d2ea36a871824898abc88f5977a.zip
Move Viewport Cameras with the boat
-rw-r--r--ship/ship/ViewPorts.gd15
-rw-r--r--ship/ship/ship.tscn2
2 files changed, 17 insertions, 0 deletions
diff --git a/ship/ship/ViewPorts.gd b/ship/ship/ViewPorts.gd
new file mode 100644
index 0000000..2e8e800
--- /dev/null
+++ b/ship/ship/ViewPorts.gd
@@ -0,0 +1,15 @@
+extends Spatial
+
+var camera_locations = []
+
+func _ready():
+ for viewport in self.get_children():
+ var cam = viewport.get_node("Camera")
+ camera_locations.push_back(cam.global_transform)
+
+func _physics_process(_delta):
+ for i in self.get_child_count():
+ var viewport = self.get_child(i)
+ var cam = viewport.get_node("Camera")
+ cam.global_transform = camera_locations[i]
+ cam.global_transform = self.global_transform * cam.global_transform
diff --git a/ship/ship/ship.tscn b/ship/ship/ship.tscn
index 06f098f..eaf0161 100644
--- a/ship/ship/ship.tscn
+++ b/ship/ship/ship.tscn
@@ -22,6 +22,7 @@
[ext_resource path="res://ship/steering_wheel/steering_wheel.tscn" type="PackedScene" id=20]
[ext_resource path="res://ship/light_fixture/light_fixture.tres" type="Material" id=21]
[ext_resource path="res://ship/water_pump/water_pump.tscn" type="PackedScene" id=22]
+[ext_resource path="res://ship/ship/ViewPorts.gd" type="Script" id=23]
[sub_resource type="BoxShape" id=26]
extents = Vector3( 5.76897, 0.594175, 1.03357 )
@@ -366,6 +367,7 @@ extents = Vector3( 10.6563, 0.518438, 37.8106 )
[node name="ship" type="Spatial"]
[node name="ViewPorts" type="Spatial" parent="."]
+script = ExtResource( 23 )
[node name="below_deck" type="Viewport" parent="ViewPorts"]
size = Vector2( 320, 180 )