Add camera adjustment settings

main
Ensar Sarajčić 2022-01-24 20:55:21 +01:00
parent 2df1e29640
commit 4a8c32b2c3
7 changed files with 615 additions and 10 deletions

View File

@ -0,0 +1,41 @@
extends Spatial
const CAMERA_CONTROLLER = preload("res://player/cameras/camera_controller.gd")
var vehicle_path = "res://vehicles/buggy.tscn"
var camera_controller: CameraController
var vehicle: Node = null
func _ready() -> void:
reset()
func _process(_delta: float) -> void:
if Input.is_action_just_released("next_camera"):
camera_controller.next_camera()
camera_controller.update_camera(
(
Input.get_action_strength("turn_camera_right")
- Input.get_action_strength("turn_camera_left")
),
Input.get_action_strength("turn_camera_up") - Input.get_action_strength("turn_camera_down"),
Input.is_action_pressed("look_backwards")
)
func change_vehicle_to(new_vehicle_path: String) -> void:
vehicle_path = new_vehicle_path
reset()
func reset() -> void:
if vehicle != null:
vehicle.queue_free()
camera_controller.clear()
vehicle = load(vehicle_path).instance()
add_child(vehicle)
camera_controller = CAMERA_CONTROLLER.new()
camera_controller.attach_cameras_to(vehicle)

View File

@ -0,0 +1,237 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://icon.png" type="Texture" id=1]
[ext_resource path="res://menu/camera_config_scene.gd" type="Script" id=2]
[sub_resource type="PlaneMesh" id=1]
[sub_resource type="SpatialMaterial" id=2]
albedo_texture = ExtResource( 1 )
[sub_resource type="ConcavePolygonShape" id=3]
data = PoolVector3Array( 1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0, -1, 1, 0, -1 )
[sub_resource type="CylinderMesh" id=4]
height = 15.0
[sub_resource type="ConvexPolygonShape" id=5]
points = PoolVector3Array( -1, -7.5, 0, -0.995301, -7.5, -0.0980814, -0.995301, -7.5, 0.0978857, -1, 7.5, 0, -0.980814, -7.5, -0.195184, -0.995301, 7.5, -0.0980814, -0.980814, -7.5, 0.194988, -0.995301, 7.5, 0.0978857, -0.957126, -7.5, -0.290329, -0.980814, 7.5, -0.195184, -0.957126, -7.5, 0.290133, -0.980814, 7.5, 0.194988, -0.924041, -7.5, -0.382733, -0.957126, 7.5, -0.290329, -0.924041, -7.5, 0.382537, -0.957126, 7.5, 0.290133, -0.88195, -7.5, -0.471417, -0.924041, 7.5, -0.382733, -0.88195, -7.5, 0.471222, -0.924041, 7.5, 0.382537, -0.831637, -7.5, -0.555599, -0.88195, 7.5, -0.471417, -0.831637, -7.5, 0.555403, -0.88195, 7.5, 0.471222, -0.773101, -7.5, -0.634495, -0.831637, 7.5, -0.555599, -0.773101, -7.5, 0.634299, -0.831637, 7.5, 0.555403, -0.707126, -7.5, -0.707126, -0.773101, 7.5, -0.634495, -0.707126, -7.5, 0.70693, -0.773101, 7.5, 0.634299, -0.634495, -7.5, -0.773101, -0.707126, 7.5, -0.707126, -0.634495, -7.5, 0.772905, -0.707126, 7.5, 0.70693, -0.555599, -7.5, -0.831637, -0.634495, 7.5, -0.773101, -0.555599, -7.5, 0.831441, -0.634495, 7.5, 0.772905, -0.471417, -7.5, -0.88195, -0.555599, 7.5, -0.831637, -0.471417, -7.5, 0.881754, -0.555599, 7.5, 0.831441, -0.382733, -7.5, -0.924041, -0.471417, 7.5, -0.88195, -0.382733, -7.5, 0.923845, -0.471417, 7.5, 0.881754, -0.290329, -7.5, -0.957126, -0.382733, 7.5, -0.924041, -0.290329, -7.5, 0.95693, -0.382733, 7.5, 0.923845, -0.195184, -7.5, -0.980814, -0.290329, 7.5, -0.957126, -0.195184, -7.5, 0.980619, -0.290329, 7.5, 0.95693, -0.0980814, -7.5, -0.995301, -0.195184, 7.5, -0.980814, -0.0980814, -7.5, 0.995106, -0.195184, 7.5, 0.980619, 0, -7.5, -1, -0.0980814, 7.5, -0.995301, 0, -7.5, 1, -0.0980814, 7.5, 0.995106, 0.0978857, -7.5, -0.995301, 0, 7.5, -1, 0.0978857, -7.5, 0.995106, 0, 7.5, 1, 0.194988, -7.5, -0.980814, 0.0978857, 7.5, -0.995301, 0.194988, -7.5, 0.980619, 0.0978857, 7.5, 0.995106, 0.290133, -7.5, -0.957126, 0.194988, 7.5, -0.980814, 0.290133, -7.5, 0.95693, 0.194988, 7.5, 0.980619, 0.382537, -7.5, -0.924041, 0.290133, 7.5, -0.957126, 0.382537, -7.5, 0.923845, 0.290133, 7.5, 0.95693, 0.471222, -7.5, -0.88195, 0.382537, 7.5, -0.924041, 0.471222, -7.5, 0.881754, 0.382537, 7.5, 0.923845, 0.555403, -7.5, -0.831637, 0.471222, 7.5, -0.88195, 0.555403, -7.5, 0.831441, 0.471222, 7.5, 0.881754, 0.634299, -7.5, -0.773101, 0.555403, 7.5, -0.831637, 0.634299, -7.5, 0.772905, 0.555403, 7.5, 0.831441, 0.70693, -7.5, -0.707126, 0.634299, 7.5, -0.773101, 0.70693, -7.5, 0.70693, 0.634299, 7.5, 0.772905, 0.772905, -7.5, -0.634495, 0.70693, 7.5, -0.707126, 0.772905, -7.5, 0.634299, 0.70693, 7.5, 0.70693, 0.831441, -7.5, -0.555599, 0.772905, 7.5, -0.634495, 0.831441, -7.5, 0.555403, 0.772905, 7.5, 0.634299, 0.881754, -7.5, -0.471417, 0.831441, 7.5, -0.555599, 0.881754, -7.5, 0.471222, 0.831441, 7.5, 0.555403, 0.923845, -7.5, -0.382733, 0.881754, 7.5, -0.471417, 0.923845, -7.5, 0.382537, 0.881754, 7.5, 0.471222, 0.95693, -7.5, -0.290329, 0.923845, 7.5, -0.382733, 0.95693, -7.5, 0.290133, 0.923845, 7.5, 0.382537, 0.980619, -7.5, -0.195184, 0.95693, 7.5, -0.290329, 0.980619, -7.5, 0.194988, 0.95693, 7.5, 0.290133, 0.995106, -7.5, -0.0980814, 0.980619, 7.5, -0.195184, 0.995106, -7.5, 0.0978857, 0.980619, 7.5, 0.194988, 1, -7.5, 0, 0.995106, 7.5, -0.0980814, 0.995106, 7.5, 0.0978857, 1, 7.5, 0 )
[node name="Spatial" type="Spatial"]
script = ExtResource( 2 )
[node name="StaticBody" type="StaticBody" parent="."]
transform = Transform( 99.9785, 0, 0, 0, 99.9785, 0, 0, 0, 99.9785, 0, 0, 0 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody"]
transform = Transform( 6.13726, 0, 0, 0, 6.13726, 0, 0, 0, 6.13726, 0, 0, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
transform = Transform( 6.13726, 0, 0, 0, 6.13726, 0, 0, 0, 6.13726, 0, 0, 0 )
shape = SubResource( 3 )
[node name="StaticBody48" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, -31.0595, 4.33657, 9.2691 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody48"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody48"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody49" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, -22.0595, 4.33657, 9.2691 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody49"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody49"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody50" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, -13.0595, 4.33657, 9.2691 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody50"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody50"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody51" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, -5.05947, 4.33657, 9.2691 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody51"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody51"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody52" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, 2.94053, 4.33657, 9.2691 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody52"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody52"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody53" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, 13.9405, 4.33657, 9.2691 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody53"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody53"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody54" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, 24.9405, 4.33657, 9.2691 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody54"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody54"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody55" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, 34.9405, 4.33657, 9.2691 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody55"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody55"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody56" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, 34.9405, 4.33657, -8.7309 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody56"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody56"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody57" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, 30.9405, 4.33657, -8.7309 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody57"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody57"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody58" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, 25.9405, 4.33657, -8.7309 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody58"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody58"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody59" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, 20.9405, 4.33657, -8.7309 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody59"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody59"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody60" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, 13.9405, 4.33657, -8.7309 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody60"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody60"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody61" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, 6.94053, 4.33657, -8.7309 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody61"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody61"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody62" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, -4.05947, 4.33657, -8.7309 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody62"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody62"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody63" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, -20.0595, 4.33657, -8.7309 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody63"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody63"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )
[node name="StaticBody64" type="StaticBody" parent="."]
transform = Transform( 0.375559, 0, 0, 0, -1.64162e-08, 1, 0, -0.375559, -4.37114e-08, -20.0595, 4.33657, -8.7309 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody64"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody64"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.417043, 0 )
shape = SubResource( 5 )

View File

@ -1,6 +1,13 @@
extends Panel
const PLAYER_CONTROLLER = preload("res://player/vehicle_controller.gd")
const CAMERA_TEST_SCENE = preload("res://menu/camera_config_scene.tscn")
const BUGGY = "res://vehicles/buggy.tscn"
const BEETLE = "res://vehicles/beetlecar.tscn"
const BUGMOBILE = "res://vehicles/bugmobile.tscn"
var vehicles = [BEETLE, BUGGY, BUGMOBILE]
var inputs = BuggedVehicle.VehicleInputs.new()
@ -19,9 +26,9 @@ onready var auto_clutch_cb: CheckBox = $MarginContainer/VSplitContainer/TabConta
# gdlint: ignore=max-line-length
onready var automatic_transmission_cb: CheckBox = $MarginContainer/VSplitContainer/TabContainer/Controls/Controls/AutomaticTransmissionCheckBox
# gdlint: ignore=max-line-length
onready var fullscreen_cb: CheckBox = $MarginContainer/VSplitContainer/TabContainer/Video/Video/FullscreenCheckBox
onready var fullscreen_cb: CheckBox = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/System/FullscreenCheckBox
# gdlint: ignore=max-line-length
onready var borderless_cb: CheckBox = $MarginContainer/VSplitContainer/TabContainer/Video/Video/BorderlessCheckBox
onready var borderless_cb: CheckBox = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/System/BorderlessCheckBox
# gdlint: ignore=max-line-length
onready var multiplayer_name_box: LineEdit = $MarginContainer/VSplitContainer/TabContainer/Gameplay/Gameplay/MultiplayerNameBox
# gdlint: ignore=max-line-length
@ -46,6 +53,26 @@ onready var brakes_value_slider: HSlider = $MarginContainer/VSplitContainer/TabC
# gdlint: ignore=max-line-length
onready var gear_value_slider: HSlider = $MarginContainer/VSplitContainer/TabContainer/Controls/Controls/HBoxContainer/Gear/HSlider
# gdlint: ignore=max-line-length
onready var fov_slider: HSlider = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/FovSlider
# gdlint: ignore=max-line-length
onready var move_forward_slider: HSlider = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveForwardSlider
# gdlint: ignore=max-line-length
onready var move_backward_slider: HSlider = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveBackwardSlider
# gdlint: ignore=max-line-length
onready var move_left_slider: HSlider = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveLeftSlider
# gdlint: ignore=max-line-length
onready var move_right_slider: HSlider = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveRightSlider
# gdlint: ignore=max-line-length
onready var move_up_slider: HSlider = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveUpSlider
# gdlint: ignore=max-line-length
onready var move_down_slider: HSlider = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveDownSlider
# gdlint: ignore=max-line-length
onready var vehicle_selector: OptionButton = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/VBoxContainer/VehicleSelector
# gdlint: ignore=max-line-length
onready var viewport: Viewport = $MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/VBoxContainer/ViewportContainer/Viewport
onready var camera_scene = CAMERA_TEST_SCENE.instance()
func _ready() -> void:
auto_clutch_cb.grab_focus()
@ -61,6 +88,13 @@ func _ready() -> void:
steering_deadzone_outer_slider.value = GlobalSettings.steering_deadzone_outer
throttle_sensitivity_slider.value = GlobalSettings.throttle_sensitivity
brakes_sensitivity_slider.value = GlobalSettings.brake_sensitivity
fov_slider.value = GlobalSettings.camera_fov
move_forward_slider.value = GlobalSettings.camera_move_forward
move_backward_slider.value = GlobalSettings.camera_move_backward
move_right_slider.value = GlobalSettings.camera_move_right
move_left_slider.value = GlobalSettings.camera_move_left
move_up_slider.value = GlobalSettings.camera_move_up
move_down_slider.value = GlobalSettings.camera_move_down
fullscreen_cb.pressed = false
borderless_cb.pressed = false
var controller = PLAYER_CONTROLLER.new()
@ -71,6 +105,13 @@ func _ready() -> void:
if OS.get_borderless_window():
_set_borderless(true)
vehicle_selector.add_item("Beetlecar")
vehicle_selector.add_item("Buggy")
vehicle_selector.add_item("Bugmobile")
vehicle_selector.selected = 1
viewport.add_child(camera_scene)
func _physics_process(_delta: float) -> void:
steering_value_slider.value = -inputs.steering
@ -143,6 +184,38 @@ func _on_BrakesSensitivitySlider_value_changed(new_value: float) -> void:
GlobalSettings.brake_sensitivity = new_value
func _on_FovSlider_value_changed(new_value: float) -> void:
GlobalSettings.camera_fov = new_value
func _on_MoveForwardSlider_value_changed(new_value: float) -> void:
GlobalSettings.camera_move_forward = new_value
func _on_MoveBackwardSlider_value_changed(new_value: float) -> void:
GlobalSettings.camera_move_backward = new_value
func _on_MoveLeftSlider_value_changed(new_value: float) -> void:
GlobalSettings.camera_move_left = new_value
func _on_MoveRightSlider_value_changed(new_value: float) -> void:
GlobalSettings.camera_move_right = new_value
func _on_MoveUpSlider_value_changed(new_value: float) -> void:
GlobalSettings.camera_move_up = new_value
func _on_MoveDownSlider_value_changed(new_value: float) -> void:
GlobalSettings.camera_move_down = new_value
func _on_VehicleSelector_item_selected(item_index: int) -> void:
camera_scene.change_vehicle_to(vehicles[item_index])
func _set_fullscreen(new_state: bool) -> void:
OS.set_window_fullscreen(new_state)
OS.set_window_maximized(new_state)

View File

@ -30,6 +30,9 @@ margin_left = 20.0
margin_top = 20.0
margin_right = -20.0
margin_bottom = -20.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer"]
margin_right = 984.0
@ -179,13 +182,25 @@ margin_top = 72.0
margin_right = -8.0
margin_bottom = -8.0
[node name="Video" type="VBoxContainer" parent="MarginContainer/VSplitContainer/TabContainer/Video"]
[node name="TabContainer" type="TabContainer" parent="MarginContainer/VSplitContainer/TabContainer/Video"]
margin_right = 968.0
margin_bottom = 104.0
margin_bottom = 384.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="FullscreenCheckBox" type="CheckBox" parent="MarginContainer/VSplitContainer/TabContainer/Video/Video"]
margin_right = 968.0
[node name="System" type="VBoxContainer" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 8.0
margin_top = 72.0
margin_right = -8.0
margin_bottom = -8.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="FullscreenCheckBox" type="CheckBox" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/System"]
margin_right = 952.0
margin_bottom = 48.0
custom_fonts/font = SubResource( 3 )
text = "Fullscreen"
@ -194,9 +209,9 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="BorderlessCheckBox" type="CheckBox" parent="MarginContainer/VSplitContainer/TabContainer/Video/Video"]
[node name="BorderlessCheckBox" type="CheckBox" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/System"]
margin_top = 56.0
margin_right = 968.0
margin_right = 952.0
margin_bottom = 104.0
custom_fonts/font = SubResource( 3 )
text = "Borderless"
@ -205,6 +220,192 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Camera" type="HSplitContainer" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 8.0
margin_top = 72.0
margin_right = -8.0
margin_bottom = -8.0
size_flags_horizontal = 3
split_offset = -500
[node name="Camera" type="VBoxContainer" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera"]
margin_right = 129.0
margin_bottom = 556.0
rect_pivot_offset = Vector2( -793.71, -168 )
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="FovLabel" type="Label" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_right = 404.0
margin_bottom = 18.0
custom_fonts/font = SubResource( 5 )
text = "FOV"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="FovSlider" type="HSlider" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 26.0
margin_right = 404.0
margin_bottom = 58.0
min_value = 1.0
max_value = 180.0
step = 0.1
value = 70.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveForwardLabel" type="Label" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 66.0
margin_right = 404.0
margin_bottom = 84.0
custom_fonts/font = SubResource( 5 )
text = "Move forward"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveForwardSlider" type="HSlider" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 92.0
margin_right = 404.0
margin_bottom = 124.0
max_value = 10.0
step = 0.01
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveBackwardLabel" type="Label" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 132.0
margin_right = 404.0
margin_bottom = 150.0
custom_fonts/font = SubResource( 5 )
text = "Move back"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveBackwardSlider" type="HSlider" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 158.0
margin_right = 404.0
margin_bottom = 190.0
max_value = 10.0
step = 0.01
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveLeftLabel" type="Label" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 198.0
margin_right = 404.0
margin_bottom = 216.0
custom_fonts/font = SubResource( 5 )
text = "Move left"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveLeftSlider" type="HSlider" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 224.0
margin_right = 404.0
margin_bottom = 256.0
max_value = 10.0
step = 0.01
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveRightLabel" type="Label" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 264.0
margin_right = 404.0
margin_bottom = 282.0
custom_fonts/font = SubResource( 5 )
text = "Move right"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveRightSlider" type="HSlider" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 290.0
margin_right = 404.0
margin_bottom = 322.0
max_value = 10.0
step = 0.01
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveUpLabel" type="Label" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 330.0
margin_right = 404.0
margin_bottom = 348.0
custom_fonts/font = SubResource( 5 )
text = "Move up"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveUpSlider" type="HSlider" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 356.0
margin_right = 404.0
margin_bottom = 388.0
max_value = 10.0
step = 0.01
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveDownLabel" type="Label" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 396.0
margin_right = 404.0
margin_bottom = 414.0
custom_fonts/font = SubResource( 5 )
text = "Move down"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveDownSlider" type="HSlider" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera"]
margin_top = 422.0
margin_right = 404.0
margin_bottom = 454.0
max_value = 10.0
step = 0.01
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera"]
margin_left = 153.0
margin_right = 952.0
margin_bottom = 556.0
[node name="ViewportContainer" type="ViewportContainer" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/VBoxContainer"]
margin_left = 153.0
margin_right = 952.0
margin_bottom = 500.0
[node name="Viewport" type="Viewport" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/VBoxContainer/ViewportContainer"]
size = Vector2( 500, 500 )
handle_input_locally = false
render_target_update_mode = 0
gui_disable_input = true
[node name="VehicleSelector" type="OptionButton" parent="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/VBoxContainer"]
margin_right = 349.0
margin_bottom = 48.0
align = 1
[node name="Controls" type="ScrollContainer" parent="MarginContainer/VSplitContainer/TabContainer"]
visible = false
anchor_right = 1.0
@ -464,8 +665,16 @@ __meta__ = {
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Audio/Audio/MasterSlider" to="." method="_on_MasterSlider_value_changed"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Audio/Audio/SoundEffectsSlider" to="." method="_on_SoundEffectsSlider_value_changed"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Audio/Audio/MusicSlider" to="." method="_on_MusicSlider_value_changed"]
[connection signal="toggled" from="MarginContainer/VSplitContainer/TabContainer/Video/Video/FullscreenCheckBox" to="." method="_on_fullscreen_toggled"]
[connection signal="toggled" from="MarginContainer/VSplitContainer/TabContainer/Video/Video/BorderlessCheckBox" to="." method="_on_borderless_toggled"]
[connection signal="toggled" from="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/System/FullscreenCheckBox" to="." method="_on_fullscreen_toggled"]
[connection signal="toggled" from="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/System/BorderlessCheckBox" to="." method="_on_borderless_toggled"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/FovSlider" to="." method="_on_FovSlider_value_changed"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveForwardSlider" to="." method="_on_MoveForwardSlider_value_changed"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveBackwardSlider" to="." method="_on_MoveBackwardSlider_value_changed"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveLeftSlider" to="." method="_on_MoveLeftSlider_value_changed"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveRightSlider" to="." method="_on_MoveRightSlider_value_changed"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveUpSlider" to="." method="_on_MoveUpSlider_value_changed"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/Camera/MoveDownSlider" to="." method="_on_MoveDownSlider_value_changed"]
[connection signal="item_selected" from="MarginContainer/VSplitContainer/TabContainer/Video/TabContainer/Camera/VBoxContainer/VehicleSelector" to="." method="_on_VehicleSelector_item_selected"]
[connection signal="toggled" from="MarginContainer/VSplitContainer/TabContainer/Controls/Controls/AutoClutchCheckBox" to="." method="_on_autoclutch_toggled"]
[connection signal="toggled" from="MarginContainer/VSplitContainer/TabContainer/Controls/Controls/AutomaticTransmissionCheckBox" to="." method="_on_automatictransmission_toggled"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/TabContainer/Controls/Controls/SteeringSensitivitySlider" to="." method="_on_SteeringSensitivitySlider_value_changed"]

View File

@ -30,6 +30,9 @@ func attach_cameras_to(player_node: BuggedVehicle) -> void:
func select_camera(camera_index: int) -> void:
if _cameras.size() == 0:
return
var select_index = camera_index
if camera_index < 0 or camera_index >= _cameras.size():
select_index = 0
@ -38,6 +41,12 @@ func select_camera(camera_index: int) -> void:
_cameras[select_index].current = true
func clear():
for cam in _cameras:
cam.queue_free()
_cameras = []
func next_camera() -> void:
select_camera(GlobalSettings.selected_camera + 1)

View File

@ -4,6 +4,15 @@ extends Camera
func reset() -> void:
rotation = Vector3.ZERO
rotate(Vector3.UP, deg2rad(180))
fov = GlobalSettings.camera_fov
translation = Vector3.ZERO
translate(
Vector3(
GlobalSettings.camera_move_right - GlobalSettings.camera_move_left,
GlobalSettings.camera_move_up - GlobalSettings.camera_move_down,
GlobalSettings.camera_move_backward - GlobalSettings.camera_move_forward
)
)
func update_rotation(horizontal: float, vertical: float) -> void:

View File

@ -12,6 +12,14 @@ var steering_deadzone_outer = 0.0
var selected_camera: int = 0
var multiplayer_name: String = "Player"
var camera_fov = 70
var camera_move_forward = 0
var camera_move_backward = 0
var camera_move_right = 0
var camera_move_left = 0
var camera_move_up = 0
var camera_move_down = 0
var _config: Dictionary
@ -35,6 +43,15 @@ func _ready() -> void:
steering_deadzone_inner = stored_config["controls"].get("steering_deadzone_inner", 1.0)
steering_deadzone_outer = stored_config["controls"].get("steering_deadzone_outer", 1.0)
if stored_config.has("camera"):
camera_fov = stored_config["camera"].get("fov", 70)
camera_move_forward = stored_config["camera"].get("camera_move_forward", 0)
camera_move_backward = stored_config["camera"].get("camera_move_backward", 0)
camera_move_left = stored_config["camera"].get("camera_move_left", 0)
camera_move_right = stored_config["camera"].get("camera_move_right", 0)
camera_move_up = stored_config["camera"].get("camera_move_up", 0)
camera_move_down = stored_config["camera"].get("camera_move_down", 0)
func read_json_file(file_path: String) -> Dictionary:
var file = File.new()
@ -80,6 +97,16 @@ func to_dictionary() -> Dictionary:
"brake_sensitivity": brake_sensitivity,
"steering_deadzone_inner": steering_deadzone_inner,
"steering_deadzone_outer": steering_deadzone_outer,
},
"camera":
{
"fov": camera_fov,
"move_forward": camera_move_forward,
"move_backward": camera_move_backward,
"move_right": camera_move_right,
"move_left": camera_move_left,
"move_up": camera_move_up,
"move_down": camera_move_down
}
}