diff options
-rw-r--r-- | ship/ship/ViewPorts.gd | 15 | ||||
-rw-r--r-- | ship/ship/ship.tscn | 2 |
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 ) |