Add mobile controls and optimized settings to Truck Town

On mobile platforms, the vehicle automatically accelerates.
Touch the left and right edges of the screen to steer.
Touch the middle of the screen to brake/reverse
(this also temporarily stops acceleration).

- Fix braking not working correctly (and make breaking stronger
  to make vehicles easier to control at high speeds).
- Allow using the D-Pad for steering and X/Square for braking.
- Tweak exhaust particles to be more subtle and fade more smoothly.
- Change spawn position to a location that's more straightforward
  to drive.
This commit is contained in:
Hugo Locurcio
2023-11-17 20:00:33 +01:00
parent 5eed925b7b
commit cdbdbac1e7
23 changed files with 279 additions and 81 deletions

View File

@@ -6,16 +6,20 @@ varying complexity using vehicle physics.
Controls:
- <kbd>Up Arrow</kbd>, <kbd>W</kbd>, <kbd>Gamepad Right Trigger</kbd>, <kbd>Gamepad A/Cross</kbd>: Accelerate
- <kbd>Down Arrow</kbd>, <kbd>S</kbd>, <kbd>Gamepad Left Trigger</kbd>, <kbd>Gamepad B/Circle</kbd> : Brake
- <kbd>Left Arrow</kbd>, <kbd>Gamepad Left Stick</kbd>: Steer left
- <kbd>Right Arrow</kbd>, <kbd>Gamepad Left Stick</kbd>: Steer right
- <kbd>Down Arrow</kbd>, <kbd>S</kbd>, <kbd>Gamepad Left Trigger</kbd>, <kbd>Gamepad B/Circle</kbd>, <kbd>Gamepad X/Square</kbd>: Brake/reverse
- <kbd>Left Arrow</kbd>, <kbd>Gamepad Left Stick</kbd>, <kbd>Gamepad D-Pad Left</kbd>: Steer left
- <kbd>Right Arrow</kbd>, <kbd>Gamepad Left Stick</kbd>, <kbd>Gamepad D-Pad Right</kbd>: Steer right
- <kbd>U</kbd>, <kbd>Gamepad Select</kbd>, left-click speedometer: Change speedometer unit (m/s, km/h, mph)
- <kbd>C</kbd>, <kbd>Gamepad Y/Triangle</kbd>: Change camera (exterior, interior, top-down)
- <kbd>Escape</kbd>, <kbd>Gamepad D-Pad Up</kbd>: Go back to menu (press again to exit)
On mobile platforms, the vehicle automatically accelerates. Touch the left and
right edges of the screen to steer. Touch the middle of the screen to
brake/reverse (this also temporarily stops acceleration).
Language: GDScript
Renderer: Forward Plus
Renderer: Forward+ on desktop, Mobile on mobile
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/524

View File

@@ -29,7 +29,7 @@ size_flags_vertical = 2
script = ExtResource("1")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
anchors_preset = 14
layout_mode = 0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
@@ -38,22 +38,25 @@ grow_vertical = 2
alignment = 1
[node name="MiniVan" type="Button" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 6
size_flags_vertical = 4
icon = ExtResource("2")
[node name="TrailerTruck" type="Button" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 6
size_flags_vertical = 4
icon = ExtResource("3")
[node name="TowTruck" type="Button" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 6
size_flags_vertical = 4
icon = ExtResource("4")
[node name="Label" type="Label" parent="."]
anchors_preset = 5
layout_mode = 0
anchor_left = 0.5
anchor_right = 0.5
offset_left = -180.0
@@ -62,8 +65,12 @@ offset_right = 180.0
offset_bottom = 123.0
grow_horizontal = 2
theme_override_colors/font_color = Color(0.494118, 0.858824, 0.960784, 1)
theme_override_colors/font_shadow_color = Color(0, 0.25098, 1, 0.12549)
theme_override_colors/font_outline_color = Color(0.105882, 0.278431, 0.47451, 1)
theme_override_constants/shadow_offset_x = 6
theme_override_constants/shadow_offset_y = 6
theme_override_constants/outline_size = 38
theme_override_constants/shadow_outline_size = 38
theme_override_fonts/font = SubResource("FontVariation_hqcvw")
theme_override_font_sizes/font_size = 64
text = "Truck Town"

View File

@@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/choose_tow.png-e1d5f4ba7eb707eed82d65f6944c64
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false

View File

@@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/choose_trailer.png-42b178b0fc9d742f9f23bb1d9f
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false

View File

@@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/choose_van.png-a2669a1a5e1faa5c8245c7e87ce8c4
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false

View File

@@ -13,10 +13,10 @@ config_version=5
config/name="Truck Town"
config/description="This is a demo implementing different types of trucks of
varying complexity using vehicle physics."
run/main_scene="res://car_select/car_select.tscn"
config/features=PackedStringArray("4.0")
config/icon="res://icon.webp"
config/tags=PackedStringArray("3d", "demo", "official", "physics", "vehicle")
run/main_scene="res://car_select/car_select.tscn"
config/features=PackedStringArray("4.1")
config/icon="res://icon.webp"
[display]
@@ -27,117 +27,120 @@ window/stretch/aspect="expand"
ui_accept={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_select={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_cancel={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
ui_focus_next={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
ui_focus_prev={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
ui_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
}
ui_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
ui_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
ui_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
ui_page_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194323,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194323,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
ui_page_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194324,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194324,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
accelerate={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":5,"axis_value":1.0,"script":null)
]
}
reverse={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":4,"axis_value":1.0,"script":null)
]
}
turn_left={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
]
}
turn_right={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
]
}
cycle_speedometer_unit={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":85,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":85,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":4,"pressure":0.0,"pressed":false,"script":null)
]
}
back={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
]
}
cycle_camera={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
]
}
@@ -152,8 +155,10 @@ shadow_filter=3
[rendering]
textures/vram_compression/import_etc2_astc=true
lights_and_shadows/directional_shadow/size=8192
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=3
lights_and_shadows/directional_shadow/soft_shadow_filter_quality.mobile=1
textures/default_filters/anisotropic_filtering_level=4
textures/default_filters/texture_mipmap_bias=-0.5
textures/decals/filter=1
@@ -161,3 +166,5 @@ environment/defaults/default_clear_color=Color(0.133333, 0.133333, 0.133333, 1)
anti_aliasing/quality/msaa_3d=2
anti_aliasing/quality/use_debanding=true
environment/default_environment="res://default_env.tres"
anti_aliasing/quality/msaa_3d.mobile=0
scaling_3d/scale.mobile=0.67

View File

@@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/cement.webp-a59028ca151ccfb7e6020be6c141b163.
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true

View File

@@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/grass.webp-0ccf2a619a3f121234da585c8abbfdba.c
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=32 format=3 uid="uid://d0ygmqpylq0wy"]
[gd_scene load_steps=36 format=3 uid="uid://d0ygmqpylq0wy"]
[ext_resource type="PackedScene" uid="uid://dfdgytsvtqxwv" path="res://town/truck_town.glb" id="1_x0dmm"]
[ext_resource type="Script" path="res://spedometer.gd" id="2"]
@@ -12,6 +12,24 @@ action = &"cycle_speedometer_unit"
[sub_resource type="Shortcut" id="Shortcut_msvqx"]
events = [SubResource("InputEventAction_a4722")]
[sub_resource type="Gradient" id="Gradient_jks6h"]
offsets = PackedFloat32Array(0)
colors = PackedColorArray(1, 1, 1, 0.25098)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_m8ylb"]
gradient = SubResource("Gradient_jks6h")
width = 128
height = 128
[sub_resource type="Gradient" id="Gradient_1rnu2"]
offsets = PackedFloat32Array(0.00645161)
colors = PackedColorArray(1, 0, 0, 0.25098)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_xu6xc"]
gradient = SubResource("Gradient_1rnu2")
width = 128
height = 128
[sub_resource type="BoxMesh" id="BoxMesh_x3c0g"]
size = Vector3(4096, 1, 4096)
@@ -102,7 +120,7 @@ data = PackedVector3Array(-2, 1, 2, 2, -1, 2, -2, -1, 2, -2, 1, -2, -2, -1, -2,
[node name="TruckTown" parent="." instance=ExtResource("1_x0dmm")]
[node name="InstancePos" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 14, 6, -40)
transform = Transform3D(1.31134e-07, 0, -1, 0, 1, 0, 1, 0, 1.31134e-07, 8, 3.36405, -16)
[node name="Spedometer" type="Button" parent="."]
custom_minimum_size = Vector2(140, 40)
@@ -118,10 +136,10 @@ offset_bottom = -24.0
grow_horizontal = 0
grow_vertical = 0
focus_mode = 0
shortcut_in_tooltip = false
action_mode = 0
shortcut = SubResource("Shortcut_msvqx")
shortcut_feedback = false
shortcut_in_tooltip = false
text = "Speed: ???"
script = ExtResource("2")
@@ -132,6 +150,63 @@ offset_right = 92.0
offset_bottom = 56.0
text = "« Back"
[node name="TouchTurnLeft" type="Control" parent="."]
layout_mode = 3
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
grow_vertical = 2
[node name="TurnLeft" type="TouchScreenButton" parent="TouchTurnLeft"]
modulate = Color(1, 1, 1, 0)
position = Vector2(0, -256)
scale = Vector2(2.5, 4)
texture_normal = SubResource("GradientTexture2D_m8ylb")
texture_pressed = SubResource("GradientTexture2D_xu6xc")
passby_press = true
action = "turn_left"
visibility_mode = 1
[node name="TouchReverse" type="Control" parent="."]
layout_mode = 3
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
[node name="Reverse" type="TouchScreenButton" parent="TouchReverse"]
modulate = Color(1, 1, 1, 0)
position = Vector2(-256, -256)
scale = Vector2(4, 4)
texture_normal = SubResource("GradientTexture2D_m8ylb")
texture_pressed = SubResource("GradientTexture2D_xu6xc")
passby_press = true
action = "reverse"
visibility_mode = 1
[node name="TouchTurnRight" type="Control" parent="."]
layout_mode = 3
anchors_preset = 6
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
grow_horizontal = 0
grow_vertical = 2
[node name="TurnRight" type="TouchScreenButton" parent="TouchTurnRight"]
modulate = Color(1, 1, 1, 0)
position = Vector2(-320, -256)
scale = Vector2(2.5, 4)
texture_normal = SubResource("GradientTexture2D_m8ylb")
texture_pressed = SubResource("GradientTexture2D_xu6xc")
passby_press = true
action = "turn_right"
visibility_mode = 1
[node name="Environment" type="WorldEnvironment" parent="."]
environment = ExtResource("3_t0mbp")

View File

@@ -26,6 +26,7 @@ skins/use_named_skins=false
animation/import=false
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={
"materials": {
@@ -91,3 +92,4 @@ _subresources={
}
}
}
gltf/embedded_image_handling=1

View File

@@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/blob_shadow.png-543236f87c8fdb7d06671b1460d39
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=3 uid="uid://c1uai3rvx8hul"]
[gd_scene load_steps=19 format=3 uid="uid://c1uai3rvx8hul"]
[ext_resource type="Script" path="res://vehicles/vehicle.gd" id="1_r806m"]
[ext_resource type="Texture2D" uid="uid://d4ostmqwgytk" path="res://vehicles/particle_smoke.png" id="2_1gkvk"]
@@ -34,9 +34,11 @@ stream_3/weight = 1.0
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_fuuj3"]
transparency = 1
shading_mode = 0
vertex_color_use_as_albedo = true
albedo_color = Color(0.462745, 0.462745, 0.462745, 0.501961)
albedo_texture = ExtResource("2_1gkvk")
billboard_mode = 3
billboard_keep_scale = true
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = false
@@ -47,9 +49,12 @@ proximity_fade_distance = 0.5
material = SubResource("StandardMaterial3D_fuuj3")
[sub_resource type="Curve" id="Curve_4j5vd"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="Gradient" id="Gradient_p5xtl"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[node name="CarBase" type="Node3D"]
[node name="Body" type="VehicleBody3D" parent="."]
@@ -133,7 +138,7 @@ shape = SubResource("BoxShape3D_x74tc")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.97449, 0)
[node name="Camera3D" type="Camera3D" parent="Body/CameraBase"]
transform = Transform3D(-0.709652, -0.170177, 0.683691, -2.11161e-08, 0.970391, 0.241539, -0.704552, 0.171409, -0.68864, 3.44908, 2.03236, -4.39379)
transform = Transform3D(-1, 2.11495e-08, -8.48259e-08, 0, 0.970296, 0.241922, 8.74228e-08, 0.241922, -0.970296, 0, 2.032, -4.394)
fov = 74.0
near = 0.1
script = ExtResource("4_6igu8")
@@ -155,7 +160,8 @@ attenuation_filter_cutoff_hz = 20500.0
[node name="CPUParticles3D" type="CPUParticles3D" parent="Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.201696, -0.022867, -1.10448)
amount = 100
amount = 125
lifetime = 1.25
mesh = SubResource("QuadMesh_30wks")
direction = Vector3(0, 1, -0.5)
gravity = Vector3(0, 0, 0)
@@ -165,10 +171,11 @@ damping_min = 0.05
damping_max = 0.05
angle_max = 360.0
scale_amount_curve = SubResource("Curve_4j5vd")
color_ramp = SubResource("Gradient_p5xtl")
[node name="BlobShadow" type="Decal" parent="Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.05)
extents = Vector3(0.8, 2, 1.5)
size = Vector3(1.6, 4, 3)
texture_albedo = ExtResource("11_3ryw5")
upper_fade = 2.0
lower_fade = 1.0

View File

@@ -26,6 +26,7 @@ skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={
"materials": {
@@ -99,3 +100,4 @@ _subresources={
}
}
}
gltf/embedded_image_handling=1

View File

@@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/particle_smoke.png-740721ed7d039c3c932866a66d
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=27 format=3 uid="uid://bh7765vrq5muf"]
[gd_scene load_steps=28 format=3 uid="uid://bh7765vrq5muf"]
[ext_resource type="Script" path="res://vehicles/vehicle.gd" id="1_qhfnb"]
[ext_resource type="ArrayMesh" uid="uid://bqrwin8ccgptt" path="res://vehicles/meshes/wheel.res" id="2_uwuq1"]
@@ -32,9 +32,11 @@ stream_3/weight = 1.0
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_atib4"]
transparency = 1
shading_mode = 0
vertex_color_use_as_albedo = true
albedo_color = Color(0.462745, 0.462745, 0.462745, 0.501961)
albedo_texture = ExtResource("10_lfosv")
billboard_mode = 3
billboard_keep_scale = true
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = false
@@ -45,9 +47,12 @@ proximity_fade_distance = 0.5
material = SubResource("StandardMaterial3D_atib4")
[sub_resource type="Curve" id="Curve_kr6si"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="Gradient" id="Gradient_38b5g"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="CapsuleMesh" id="CapsuleMesh_i2aww"]
radius = 0.05
height = 0.42
@@ -163,7 +168,7 @@ mesh = ExtResource("3_tv0o3")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.97449, 0)
[node name="Camera3D" type="Camera3D" parent="Body/CameraBase"]
transform = Transform3D(-0.709652, -0.170177, 0.683691, -2.11161e-08, 0.970391, 0.241539, -0.704552, 0.171409, -0.68864, 3.44908, 2.03236, -4.39379)
transform = Transform3D(-1, 2.11495e-08, -8.48259e-08, 0, 0.970296, 0.241922, 8.74227e-08, 0.241922, -0.970295, 0, 2.032, -4.394)
current = true
fov = 74.0
near = 0.1
@@ -191,7 +196,8 @@ attenuation_filter_cutoff_hz = 20500.0
[node name="CPUParticles3D" type="CPUParticles3D" parent="Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.201696, -0.022867, -1.10448)
amount = 100
amount = 125
lifetime = 1.25
mesh = SubResource("QuadMesh_xsbig")
direction = Vector3(0, 1, -0.5)
gravity = Vector3(0, 0, 0)
@@ -201,10 +207,11 @@ damping_min = 0.05
damping_max = 0.05
angle_max = 360.0
scale_amount_curve = SubResource("Curve_kr6si")
color_ramp = SubResource("Gradient_38b5g")
[node name="BlobShadow" type="Decal" parent="Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00169557, -0.222867, 0.145518)
extents = Vector3(0.8, 2, 1.5)
size = Vector3(1.6, 4, 3)
texture_albedo = ExtResource("11_5ul8v")
upper_fade = 2.0
lower_fade = 1.0
@@ -386,7 +393,7 @@ shape = SubResource("BoxShape3D_hbuqf")
[node name="BlobShadow" type="Decal" parent="Body2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00169557, -0.122867, 0.0251799)
extents = Vector3(0.8, 2, 1.5)
size = Vector3(1.6, 4, 3)
texture_albedo = ExtResource("11_5ul8v")
upper_fade = 2.0
lower_fade = 1.0

File diff suppressed because one or more lines are too long

View File

@@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/truck_trailer.png-37383ff0a7e2053e450f6ec8ff2
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true

View File

@@ -2,6 +2,7 @@ extends VehicleBody3D
const STEER_SPEED = 1.5
const STEER_LIMIT = 0.4
const BRAKE_STRENGTH = 2.0
@export var engine_force_value := 40.0
@@ -10,7 +11,6 @@ var _steer_target := 0.0
@onready var desired_engine_pitch: float = $EngineSound.pitch_scale
func _physics_process(delta: float):
var fwd_mps := (linear_velocity * transform.basis).x
@@ -30,7 +30,8 @@ func _physics_process(delta: float):
for joypad in Input.get_connected_joypads():
Input.start_joy_vibration(joypad, 0.0, 0.5, 0.1)
if Input.is_action_pressed(&"accelerate"):
# Automatically accelerate when using touch controls (reversing overrides acceleration).
if DisplayServer.is_touchscreen_available() or Input.is_action_pressed(&"accelerate"):
# Increase engine force at low speeds to make the initial acceleration faster.
var speed := linear_velocity.length()
if speed < 5.0 and not is_zero_approx(speed):
@@ -38,26 +39,22 @@ func _physics_process(delta: float):
else:
engine_force = engine_force_value
# Apply analog throttle factor for more subtle acceleration if not fully holding down the trigger.
engine_force *= Input.get_action_strength(&"accelerate")
if not DisplayServer.is_touchscreen_available():
# Apply analog throttle factor for more subtle acceleration if not fully holding down the trigger.
engine_force *= Input.get_action_strength(&"accelerate")
else:
engine_force = 0.0
if Input.is_action_pressed(&"reverse"):
# Increase engine force at low speeds to make the initial acceleration faster.
if fwd_mps >= -1.0:
var speed := linear_velocity.length()
if speed < 5.0 and not is_zero_approx(speed):
engine_force = -clampf(engine_force_value * 5.0 / speed, 0.0, 100.0)
else:
engine_force = -engine_force_value
# Apply analog brake factor for more subtle braking if not fully holding down the trigger.
engine_force *= Input.get_action_strength(&"reverse")
# Increase engine force at low speeds to make the initial reversing faster.
var speed := linear_velocity.length()
if speed < 5.0 and not is_zero_approx(speed):
engine_force = -clampf(engine_force_value * BRAKE_STRENGTH * 5.0 / speed, 0.0, 100.0)
else:
brake = 0.0
else:
brake = 0.0
engine_force = -engine_force_value * BRAKE_STRENGTH
# Apply analog brake factor for more subtle braking if not fully holding down the trigger.
engine_force *= Input.get_action_strength(&"reverse")
steering = move_toward(steering, _steer_target, STEER_SPEED * delta)