Skip to content

Commit

Permalink
Clean up and fix Truck Town
Browse files Browse the repository at this point in the history
  • Loading branch information
jtnicholl committed Aug 30, 2022
1 parent 044afe7 commit 8c299ee
Show file tree
Hide file tree
Showing 53 changed files with 553 additions and 2,335 deletions.
Binary file removed 3d/truck_town/Images/choose_tow.png
Binary file not shown.
Binary file removed 3d/truck_town/Images/choose_trailer.png
Binary file not shown.
Binary file removed 3d/truck_town/Images/choose_van.png
Binary file not shown.
6 changes: 0 additions & 6 deletions 3d/truck_town/Materials/car_blue_body.tres

This file was deleted.

5 changes: 0 additions & 5 deletions 3d/truck_town/Materials/car_grill.tres

This file was deleted.

5 changes: 0 additions & 5 deletions 3d/truck_town/Materials/car_orange_body.tres

This file was deleted.

5 changes: 0 additions & 5 deletions 3d/truck_town/Materials/car_red_body.tres

This file was deleted.

7 changes: 0 additions & 7 deletions 3d/truck_town/Materials/car_window.tres

This file was deleted.

7 changes: 0 additions & 7 deletions 3d/truck_town/Materials/car_yellow_body.tres

This file was deleted.

9 changes: 0 additions & 9 deletions 3d/truck_town/Materials/cement.tres

This file was deleted.

6 changes: 0 additions & 6 deletions 3d/truck_town/Materials/door.tres

This file was deleted.

9 changes: 0 additions & 9 deletions 3d/truck_town/Materials/grass.tres

This file was deleted.

6 changes: 0 additions & 6 deletions 3d/truck_town/Materials/house.tres

This file was deleted.

6 changes: 0 additions & 6 deletions 3d/truck_town/Materials/roof.tres

This file was deleted.

6 changes: 0 additions & 6 deletions 3d/truck_town/Materials/roof2.tres

This file was deleted.

6 changes: 0 additions & 6 deletions 3d/truck_town/Materials/windows.tres

This file was deleted.

6 changes: 1 addition & 5 deletions 3d/truck_town/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
This is a demo implementing different types of trucks of
varying complexity using vehicle physics.

Do not be surprised if everything is bouncy and glitchy,
Godot's physics system is not polished and will likely be
reworked in the future.

Language: GDScript

Renderer: GLES 2
Renderer: Vulkan Clustered

Check out this demo on the asset library: https://godotengine.org/asset-library/asset/524

Expand Down
127 changes: 17 additions & 110 deletions 3d/truck_town/car_base.tscn

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions 3d/truck_town/car_select.gd
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
extends Control

var town = null
var town: Node3D = null

func _process(_delta):
func _process(_delta: float):
if Input.is_action_just_pressed(&"back"):
_on_Back_pressed()
_on_back_pressed()


func _load_scene(car):
var tt = load(car).instantiate()
tt.name = &"car"
func _load_scene(car_path: String):
var car: Node3D = load(car_path).instantiate()
car.name = &"car"
town = load("res://town_scene.tscn").instantiate()
town.get_node(^"InstancePos").add_child(tt)
town.get_node(^"Back").connect(&"pressed", self._on_Back_pressed)
town.get_node(^"InstancePos").add_child(car)
town.get_node(^"InstancePos/Panel/Spedometer").car_body = car.get_child(0)
town.get_node(^"Back").pressed.connect(_on_back_pressed)

get_parent().add_child(town)
hide()


func _on_Back_pressed():
func _on_back_pressed():
if is_instance_valid(town):
# Currently in the town, go back to main menu.
town.queue_free()
Expand All @@ -27,13 +29,13 @@ func _on_Back_pressed():
get_tree().quit()


func _on_MiniVan_pressed():
func _on_mini_van_pressed():
_load_scene("res://car_base.tscn")


func _on_TrailerTruck_pressed():
func _on_trailer_truck_pressed():
_load_scene("res://trailer_truck.tscn")


func _on_TowTruck_pressed():
func _on_tow_truck_pressed():
_load_scene("res://tow_truck.tscn")
82 changes: 46 additions & 36 deletions 3d/truck_town/car_select.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[gd_scene load_steps=5 format=3 uid="uid://bbpqesu2qnd2j"]
[gd_scene load_steps=5 format=3 uid="uid://dgjvvywy4m0jo"]

[ext_resource type="Script" path="res://car_select.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://bh7b4n4lg1uqt" path="res://Images/choose_van.png" id="2"]
[ext_resource type="Texture2D" uid="uid://hvkcmpdq1t0k" path="res://Images/choose_trailer.png" id="3"]
[ext_resource type="Texture2D" uid="uid://de7itkxhl0u28" path="res://Images/choose_tow.png" id="4"]
[ext_resource type="Texture2D" uid="uid://bh7b4n4lg1uqt" path="res://textures/choose_van.png" id="2"]
[ext_resource type="Texture2D" uid="uid://hvkcmpdq1t0k" path="res://textures/choose_trailer.png" id="3"]
[ext_resource type="Texture2D" uid="uid://de7itkxhl0u28" path="res://textures/choose_tow.png" id="4"]

[node name="CarSelect" type="Control"]
layout_mode = 3
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
Expand All @@ -14,41 +16,49 @@ offset_left = -512.0
offset_top = -300.0
offset_right = 512.0
offset_bottom = 300.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 2
size_flags_vertical = 2
script = ExtResource( "1" )
__meta__ = {
"__editor_plugin_screen__": "2D",
"_edit_use_anchors_": false
}
script = ExtResource("1")

[node name="MiniVan" type="Button" parent="."]
offset_left = 4.0
offset_top = 160.0
offset_right = 340.0
offset_bottom = 400.0
size_flags_horizontal = 2
size_flags_vertical = 2
icon = ExtResource( "2" )
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 14
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
alignment = 1

[node name="TrailerTruck" type="Button" parent="."]
offset_left = 344.0
offset_top = 160.0
offset_right = 680.0
offset_bottom = 401.0
size_flags_horizontal = 2
size_flags_vertical = 2
icon = ExtResource( "3" )
[node name="MiniVan" type="Button" parent="HBoxContainer"]
layout_mode = 2
offset_left = 5.0
offset_right = 333.0
offset_bottom = 243.0
size_flags_horizontal = 6
size_flags_vertical = 4
icon = ExtResource("2")

[node name="TowTruck" type="Button" parent="."]
offset_left = 684.0
offset_top = 160.0
offset_right = 1020.0
offset_bottom = 400.0
size_flags_horizontal = 2
size_flags_vertical = 2
icon = ExtResource( "4" )
[node name="TrailerTruck" type="Button" parent="HBoxContainer"]
layout_mode = 2
offset_left = 347.0
offset_right = 675.0
offset_bottom = 243.0
size_flags_horizontal = 6
size_flags_vertical = 4
icon = ExtResource("3")

[node name="TowTruck" type="Button" parent="HBoxContainer"]
layout_mode = 2
offset_left = 690.0
offset_right = 1018.0
offset_bottom = 243.0
size_flags_horizontal = 6
size_flags_vertical = 4
icon = ExtResource("4")

[connection signal="pressed" from="MiniVan" to="." method="_on_MiniVan_pressed"]
[connection signal="pressed" from="TrailerTruck" to="." method="_on_TrailerTruck_pressed"]
[connection signal="pressed" from="TowTruck" to="." method="_on_TowTruck_pressed"]
[connection signal="pressed" from="HBoxContainer/MiniVan" to="." method="_on_mini_van_pressed"]
[connection signal="pressed" from="HBoxContainer/TrailerTruck" to="." method="_on_trailer_truck_pressed"]
[connection signal="pressed" from="HBoxContainer/TowTruck" to="." method="_on_tow_truck_pressed"]
6 changes: 4 additions & 2 deletions 3d/truck_town/default_env.tres
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)

[sub_resource type="Sky" id="Sky_1gf0c"]
sky_material = SubResource( "ProceduralSkyMaterial_2k12y" )
sky_material = SubResource("ProceduralSkyMaterial_2k12y")

[resource]
background_mode = 2
sky = SubResource( "Sky_1gf0c" )
sky = SubResource("Sky_1gf0c")
tonemap_mode = 2
glow_enabled = true
glow_intensity = 0.5
glow_blend_mode = 1
29 changes: 8 additions & 21 deletions 3d/truck_town/follow_camera.gd
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
extends Camera3D

@export var min_distance = 2.0
@export var max_distance = 4.0
@export var angle_v_adjust = 0.0

var collision_exception = []
@export var height = 1.5
@export var min_distance := 2.0
@export var max_distance := 4.0
@export var angle_v_adjust := 0.0
@export var height := 1.5

func _ready():
# Find collision exceptions for ray.
var node = self
while(node):
if (node is RigidDynamicBody3D):
collision_exception.append(node.get_rid())
break
else:
node = node.get_parent()

# This detaches the camera transform from the parent spatial node.
set_as_top_level(true)


func _physics_process(_delta):
var target = get_parent().get_global_transform().origin
var pos = get_global_transform().origin
var target: Vector3 = get_parent().global_transform.origin
var pos := global_transform.origin

var from_target = pos - target
var from_target := pos - target

# Check ranges.
if from_target.length() < min_distance:
Expand All @@ -40,6 +29,4 @@ func _physics_process(_delta):
look_at_from_position(pos, target, Vector3.UP)

# Turn a little up or down
var t = get_transform()
t.basis = Basis(t.basis[0], deg2rad(angle_v_adjust)) * t.basis
set_transform(t)
transform.basis = Basis(transform.basis[0], deg_to_rad(angle_v_adjust)) * transform.basis
Binary file modified 3d/truck_town/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions 3d/truck_town/icon.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
9 changes: 9 additions & 0 deletions 3d/truck_town/materials/cement.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://dwpeihw7c20hb"]

[ext_resource type="Texture2D" uid="uid://deeixbwehify0" path="res://textures/cement.png" id="1"]

[resource]
resource_name = "Cement"
albedo_texture = ExtResource("1")
roughness = 0.8
uv1_scale = Vector3(2, 2, 2)
9 changes: 9 additions & 0 deletions 3d/truck_town/materials/grass.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://dy1i6vuu24ovq"]

[ext_resource type="Texture2D" uid="uid://cltpie6eq33br" path="res://textures/grass.png" id="1"]

[resource]
resource_name = "Grass"
albedo_texture = ExtResource("1")
roughness = 0.8
uv1_scale = Vector3(2, 2, 2)
7 changes: 7 additions & 0 deletions 3d/truck_town/materials/truck_trailer.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://cebi0gcdtlo4k"]

[ext_resource type="Texture2D" uid="uid://q7uvsiqefkwr" path="res://textures/truck_trailer.png" id="1_jkh55"]

[resource]
albedo_texture = ExtResource("1_jkh55")
roughness = 0.6
1 change: 1 addition & 0 deletions 3d/truck_town/meshes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.res
Binary file added 3d/truck_town/meshes/meshes.glb
Binary file not shown.
Loading

0 comments on commit 8c299ee

Please sign in to comment.