Add wip rover game

This commit is contained in:
Daniel Snider 2022-08-18 19:14:35 -07:00
parent 8974f0cc56
commit c63377c1dc
15 changed files with 1423 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -183,6 +183,7 @@ open_debug={
3d_physics/layer_3="Player Interact Box"
3d_physics/layer_4="Interactable"
3d_physics/layer_5="Camera Zone"
3d_physics/layer_6="Rock"
[physics]

View File

@ -61,9 +61,7 @@ ssao_enabled = true
ssao_radius = 3.86
ssao_intensity = 0.69
dof_blur_far_enabled = true
dof_blur_far_amount = 0.15
dof_blur_near_enabled = true
dof_blur_near_amount = 0.15
adjustment_contrast = 1.97
[node name="main" type="Spatial"]

View File

@ -697,7 +697,7 @@ mesh = SubResource( 1 )
skin = SubResource( 2 )
[node name="head_bone" type="BoneAttachment" parent="model_transform/DungMan/Armature/Skeleton" index="1"]
transform = Transform( 1, -2.22045e-16, 5.12852e-23, 1.32349e-23, 2.83122e-07, 1, -2.22045e-16, -1, 2.83122e-07, -3.33067e-16, 5.21541e-08, -1.5 )
transform = Transform( 1, -2.22044e-16, -4.27702e-19, 2.64698e-23, -0.00192609, 0.999998, -2.22045e-16, -0.999998, -0.00192609, -3.33198e-16, 0.00261936, -1.49514 )
bone_name = "Item"
[node name="ItemSpawn" type="Spatial" parent="model_transform/DungMan/Armature/Skeleton/head_bone"]

34
scenes/rock.tscn Normal file
View File

@ -0,0 +1,34 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://scripts/rock.gd" type="Script" id=1]
[sub_resource type="PhysicsMaterial" id=9]
friction = 0.75
bounce = 0.5
[sub_resource type="SphereShape" id=7]
radius = 4.0
[sub_resource type="SphereMesh" id=8]
radius = 4.0
height = 8.0
[node name="rock" type="RigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, 0 )
mass = 5.0
physics_material_override = SubResource( 9 )
axis_lock_linear_y = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="."]
shape = SubResource( 7 )
[node name="MeshInstance" type="MeshInstance" parent="."]
mesh = SubResource( 8 )
[node name="hit_box" type="Area" parent="."]
collision_layer = 40
collision_mask = 0
[node name="CollisionShape" type="CollisionShape" parent="hit_box"]
shape = SubResource( 7 )

47
scenes/rover.tscn Normal file
View File

@ -0,0 +1,47 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://scripts/rover.gd" type="Script" id=1]
[sub_resource type="CylinderShape" id=13]
radius = 2.98085
[sub_resource type="CubeMesh" id=2]
size = Vector3( 6, 2, 6 )
[sub_resource type="SpatialMaterial" id=12]
albedo_color = Color( 0.627451, 0.156863, 0.156863, 1 )
[sub_resource type="BoxShape" id=9]
extents = Vector3( 2.90757, 1, 2.12399 )
[node name="rover" type="RigidBody"]
can_sleep = false
axis_lock_linear_y = true
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
linear_damp = 5.0
angular_damp = 5.0
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
shape = SubResource( 13 )
[node name="visual" type="Spatial" parent="."]
[node name="MeshInstance" type="MeshInstance" parent="visual"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
mesh = SubResource( 2 )
skeleton = NodePath("../../..")
material/0 = SubResource( 12 )
[node name="interact_box" type="Area" parent="visual"]
unique_name_in_owner = true
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -3.96067 )
collision_layer = 4
collision_mask = 8
[node name="CollisionShape" type="CollisionShape" parent="visual/interact_box"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.39215 )
shape = SubResource( 9 )

214
scenes/rover_game.tscn Normal file
View File

@ -0,0 +1,214 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://scenes/rover.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/rover_level/RoverGame.glb" type="PackedScene" id=4]
[ext_resource path="res://scripts/rover_camera.gd" type="Script" id=5]
[ext_resource path="res://scripts/rover_game.gd" type="Script" id=6]
[sub_resource type="BoxShape" id=7]
extents = Vector3( 21.7976, 4.38074, 5.34608 )
[sub_resource type="ProceduralSky" id=6]
sky_top_color = Color( 1, 1, 1, 1 )
sky_horizon_color = Color( 0.721569, 0.721569, 0.721569, 1 )
[sub_resource type="Environment" id=5]
background_mode = 2
background_sky = SubResource( 6 )
background_color = Color( 0.752941, 0.752941, 0.752941, 1 )
ssao_enabled = true
ssao_radius = 15.99
ssao_intensity = 3.14
ssao_bias = 0.455
ssao_edge_sharpness = 0.0
[sub_resource type="BoxShape" id=8]
extents = Vector3( 100, 1, 400 )
[node name="rover_game" type="Spatial"]
script = ExtResource( 6 )
[node name="RoverGame" parent="." instance=ExtResource( 4 )]
[node name="rover" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.04923, 50 )
mass = 2.0
[node name="rover_camera" type="Camera" parent="."]
transform = Transform( -4.37114e-08, 0.866025, -0.5, 0, 0.5, 0.866025, 1, 3.78552e-08, -2.18557e-08, -34.343, 66.514, 50 )
current = true
script = ExtResource( 5 )
[node name="collection_area" type="Area" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.988 )
collision_layer = 0
collision_mask = 32
[node name="CollisionShape" type="CollisionShape" parent="collection_area"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.0199232 )
shape = SubResource( 7 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 5 )
[node name="Floor" type="StaticBody" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
[node name="CollisionShape" type="CollisionShape" parent="Floor"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.172523, 0.157974, 349.242 )
shape = SubResource( 8 )
[node name="Timer" type="Timer" parent="."]
wait_time = 60.0
one_shot = true
autostart = true
[node name="UI" type="CanvasLayer" parent="."]
[node name="Control" type="Control" parent="UI"]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="Panel" type="Panel" parent="UI/Control"]
anchor_right = 1.0
margin_bottom = 44.0
[node name="progress_bar" type="ProgressBar" parent="UI/Control/Panel"]
unique_name_in_owner = true
anchor_left = 0.5
anchor_right = 0.5
margin_left = -393.0
margin_right = 393.0
margin_bottom = 43.0
[node name="spawn locations" type="Spatial" parent="."]
[node name="spawn_location" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 72.8999 )
[node name="spawn_location2" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -14.1474, 0, 86.0569 )
[node name="spawn_location3" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 18.2501, 0, 95.3941 )
[node name="spawn_location4" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.749908, 0, 103.394 )
[node name="spawn_location5" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 15.2501, 0, 78.3941 )
[node name="spawn_location6" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 17.7966, 0, 55.7584 )
[node name="spawn_location7" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -23.0892, 0, 38.7815 )
[node name="spawn_location8" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -23.0892, 0, 38.7815 )
[node name="spawn_location9" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 9.46336, 0, 135.092 )
[node name="spawn_location10" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.483337, 0, 158.441 )
[node name="spawn_location11" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 19.4833, 0, 182.441 )
[node name="spawn_location12" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -22.4983, 0, 220.83 )
[node name="spawn_location13" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5.50166, 0, 220.83 )
[node name="spawn_location14" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -18.9689, 0, 237.892 )
[node name="spawn_location15" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7.7439, 0, 291.772 )
[node name="spawn_location16" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 22.1147, 0, 283.915 )
[node name="spawn_location17" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 27.9517, 0, 325.897 )
[node name="spawn_location18" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13.1347, 0, 352.388 )
[node name="spawn_location19" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -17.1729, 0, 361.368 )
[node name="spawn_location20" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -4.60088, 0, 378.654 )
[node name="spawn_location21" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 17.6247, 0, 374.164 )
[node name="spawn_location22" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 17.6247, 0, 374.164 )
[node name="spawn_location23" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -9.0909, 0, 404.921 )
[node name="spawn_location24" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -22.7855, 0, 420.86 )
[node name="spawn_location25" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -14.4789, 0, 436.351 )
[node name="spawn_location26" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.00888, 0, 453.862 )
[node name="spawn_location27" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6.17516, 0, 438.147 )
[node name="spawn_location28" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21.2167, 0, 457.005 )
[node name="spawn_location29" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 15.6042, 0, 469.802 )
[node name="spawn_location30" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 25.0332, 0, 496.517 )
[node name="spawn_location31" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 9.99167, 0, 513.355 )
[node name="spawn_location32" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -18.0709, 0, 527.049 )
[node name="spawn_location33" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -20.0709, 0, 545.049 )
[node name="spawn_location34" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -20.0709, 0, 545.049 )
[node name="spawn_location35" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 30.2172, 0, 526.865 )
[node name="spawn_location36" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13.2172, 0, 528.865 )
[node name="spawn_location37" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -17.0904, 0, 605.195 )
[node name="spawn_location38" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.701813, 0, 602.725 )
[node name="spawn_location39" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 15.0132, 0, 626.747 )
[node name="spawn_location40" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 24.8913, 0, 643.585 )
[node name="spawn_location41" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 15.0132, 0, 664.688 )
[node name="spawn_location42" type="Position3D" parent="spawn locations" groups=["rock_spawn_location"]]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 17.4828, 0, 603.399 )
[connection signal="area_entered" from="collection_area" to="." method="_on_collection_area_area_entered"]
[editable path="RoverGame"]

9
scripts/rock.gd Normal file
View File

@ -0,0 +1,9 @@
extends RigidBody
func _ready():
$hit_box.set_meta("owner", self)
func on_rover_interact(rover: Spatial) -> bool:
apply_central_impulse(rover.heading * 250.0)
return true

23
scripts/rover.gd Normal file
View File

@ -0,0 +1,23 @@
extends RigidBody
const SPEED = 300.0
const TURN = 2.5
var heading := Vector3.FORWARD
func _physics_process(delta):
heading = heading.rotated(Vector3.UP, Input.get_axis("right", "left") * TURN * delta).normalized()
$visual.global_transform = $visual.global_transform.looking_at($visual.global_transform.origin + heading, Vector3.UP)
func _integrate_forces(state):
add_central_force(Input.get_axis("down", "up") * heading * SPEED)
var c_mag = heading.cross(linear_velocity).y
var c = Vector3.UP.cross(heading).normalized() * c_mag
add_central_force(c * 1.0)
func _unhandled_input(event):
if event.is_action_pressed("action"):
for area in $"%interact_box".get_overlapping_areas():
if area.has_meta("owner"):
area = area.get_meta("owner")
if area.on_rover_interact(self):
break

8
scripts/rover_camera.gd Normal file
View File

@ -0,0 +1,8 @@
extends Camera
func _ready():
pass
func _process(delta):
global_transform.origin.z = $"../rover".global_transform.origin.z

21
scripts/rover_game.gd Normal file
View File

@ -0,0 +1,21 @@
extends Spatial
func _ready():
spawn_rocks(10)
func spawn_rocks(count: int):
var locations: Array = get_tree().get_nodes_in_group("rock_spawn_location")
locations.shuffle()
for i in range(min(count, locations.size())):
var location = locations[i]
var rock = preload("res://scenes/rock.tscn").instance()
location.add_child(rock)
func _on_collection_area_area_entered(area):
if area.has_meta("owner"):
area = area.get_meta("owner")
area.queue_free()
func _process(delta):
$"%progress_bar".value = $Timer.time_left * 100.0 / $Timer.wait_time