feat: Add collision for buildings and player and peds
This commit is contained in:
parent
1bc9f30c44
commit
b99ed8c7bb
25
chunk.gd
25
chunk.gd
|
|
@ -6,18 +6,29 @@ var exits: Array = [false, false, false, false]
|
||||||
const STREET_WIDTH: float = 40
|
const STREET_WIDTH: float = 40
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$Mesh.mesh.size.x = Global.chunk_size
|
$Mesh.mesh.size.x = Global.chunk_size
|
||||||
$Mesh.mesh.size.y = Global.chunk_size
|
$Mesh.mesh.size.y = Global.chunk_size
|
||||||
|
|
||||||
#exits = [
|
#var building_area = Area3D.new()
|
||||||
#randi() % 2 == 0,
|
#var building_collision = CollisionShape3D.new()
|
||||||
#randi() % 2 == 0,
|
#var box_shape = BoxShape3D.new()
|
||||||
#randi() % 2 == 0,
|
#var box_mesh = BoxMesh.new()
|
||||||
#randi() % 2 == 0,
|
#var building_mesh = MeshInstance3D.new()
|
||||||
#]
|
#var building_collision_center = Vector3((-STREET_WIDTH/2-Global.chunk_size/2)/2+Global.chunk_size, 0, (STREET_WIDTH/2-Global.chunk_size/2)/2+Global.chunk_size)
|
||||||
|
#building_collision.position = building_collision_center
|
||||||
|
#box_shape.size = Vector3(Global.chunk_size/2-STREET_WIDTH/2, 20, Global.chunk_size/2-STREET_WIDTH/2)
|
||||||
|
#box_mesh.size = Vector3(Global.chunk_size/2-STREET_WIDTH/2, 20, Global.chunk_size/2-STREET_WIDTH/2)
|
||||||
|
#building_collision.shape = box_shape
|
||||||
|
#building_mesh.mesh = box_mesh
|
||||||
|
#$BuildingAreas.add_child(building_area)
|
||||||
|
#
|
||||||
|
#building_area.add_child(building_collision)
|
||||||
|
#building_collision.add_child(building_mesh)
|
||||||
|
|
||||||
|
|
||||||
#update()
|
|
||||||
|
|
||||||
func update() -> void:
|
func update() -> void:
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
|
||||||
54
chunk.tscn
54
chunk.tscn
|
|
@ -3,7 +3,7 @@
|
||||||
[ext_resource type="Script" uid="uid://ndadug5eerju" path="res://chunk.gd" id="1_kdh3y"]
|
[ext_resource type="Script" uid="uid://ndadug5eerju" path="res://chunk.gd" id="1_kdh3y"]
|
||||||
|
|
||||||
[sub_resource type="PlaneMesh" id="PlaneMesh_kdh3y"]
|
[sub_resource type="PlaneMesh" id="PlaneMesh_kdh3y"]
|
||||||
size = Vector2(100, 100)
|
size = Vector2(150, 150)
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_eoxb4"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_eoxb4"]
|
||||||
albedo_color = Color(0.47398567, 0.32202998, 0.25116646, 1)
|
albedo_color = Color(0.47398567, 0.32202998, 0.25116646, 1)
|
||||||
|
|
@ -27,6 +27,12 @@ albedo_color = Color(0, 0, 1, 1)
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_381vs"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_381vs"]
|
||||||
albedo_color = Color(0, 0, 1, 1)
|
albedo_color = Color(0, 0, 1, 1)
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_kdh3y"]
|
||||||
|
size = Vector3(55, 50, 55)
|
||||||
|
|
||||||
|
[sub_resource type="BoxMesh" id="BoxMesh_eat54"]
|
||||||
|
size = Vector3(55, 50, 55)
|
||||||
|
|
||||||
[node name="Chunk" type="Node3D" unique_id=1195945545]
|
[node name="Chunk" type="Node3D" unique_id=1195945545]
|
||||||
script = ExtResource("1_kdh3y")
|
script = ExtResource("1_kdh3y")
|
||||||
|
|
||||||
|
|
@ -36,20 +42,66 @@ surface_material_override/0 = SubResource("StandardMaterial3D_eoxb4")
|
||||||
|
|
||||||
[node name="n" type="MeshInstance3D" parent="." unique_id=1732708017]
|
[node name="n" type="MeshInstance3D" parent="." unique_id=1732708017]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, -45.583553)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, -45.583553)
|
||||||
|
visible = false
|
||||||
mesh = SubResource("PlaneMesh_eat54")
|
mesh = SubResource("PlaneMesh_eat54")
|
||||||
surface_material_override/0 = SubResource("StandardMaterial3D_eat54")
|
surface_material_override/0 = SubResource("StandardMaterial3D_eat54")
|
||||||
|
|
||||||
[node name="s" type="MeshInstance3D" parent="." unique_id=2083422071]
|
[node name="s" type="MeshInstance3D" parent="." unique_id=2083422071]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 45.142174)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 45.142174)
|
||||||
|
visible = false
|
||||||
mesh = SubResource("PlaneMesh_eat54")
|
mesh = SubResource("PlaneMesh_eat54")
|
||||||
surface_material_override/0 = SubResource("StandardMaterial3D_a0kup")
|
surface_material_override/0 = SubResource("StandardMaterial3D_a0kup")
|
||||||
|
|
||||||
[node name="w" type="MeshInstance3D" parent="." unique_id=518228778]
|
[node name="w" type="MeshInstance3D" parent="." unique_id=518228778]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -44.286728, -1, -0.19546509)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -44.286728, -1, -0.19546509)
|
||||||
|
visible = false
|
||||||
mesh = SubResource("PlaneMesh_eat54")
|
mesh = SubResource("PlaneMesh_eat54")
|
||||||
surface_material_override/0 = SubResource("StandardMaterial3D_7yqgf")
|
surface_material_override/0 = SubResource("StandardMaterial3D_7yqgf")
|
||||||
|
|
||||||
[node name="e" type="MeshInstance3D" parent="." unique_id=1202960026]
|
[node name="e" type="MeshInstance3D" parent="." unique_id=1202960026]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 45.81064, -1, -0.17337036)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 45.81064, -1, -0.17337036)
|
||||||
|
visible = false
|
||||||
mesh = SubResource("PlaneMesh_eat54")
|
mesh = SubResource("PlaneMesh_eat54")
|
||||||
surface_material_override/0 = SubResource("StandardMaterial3D_381vs")
|
surface_material_override/0 = SubResource("StandardMaterial3D_381vs")
|
||||||
|
|
||||||
|
[node name="BuildingAreas" type="Node3D" parent="." unique_id=530802888]
|
||||||
|
|
||||||
|
[node name="B_area_1" type="StaticBody3D" parent="BuildingAreas" unique_id=1937669746]
|
||||||
|
collision_mask = 7
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="BuildingAreas/B_area_1" unique_id=1067780811]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -47.5, 0, 47.5)
|
||||||
|
shape = SubResource("BoxShape3D_kdh3y")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="BuildingAreas/B_area_1/CollisionShape3D" unique_id=1873626407]
|
||||||
|
mesh = SubResource("BoxMesh_eat54")
|
||||||
|
|
||||||
|
[node name="B_area_2" type="StaticBody3D" parent="BuildingAreas" unique_id=34391878]
|
||||||
|
collision_mask = 7
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="BuildingAreas/B_area_2" unique_id=1293591314]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 47.5)
|
||||||
|
shape = SubResource("BoxShape3D_kdh3y")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="BuildingAreas/B_area_2/CollisionShape3D" unique_id=1793580624]
|
||||||
|
mesh = SubResource("BoxMesh_eat54")
|
||||||
|
|
||||||
|
[node name="B_area_3" type="StaticBody3D" parent="BuildingAreas" unique_id=1586518106]
|
||||||
|
collision_mask = 7
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="BuildingAreas/B_area_3" unique_id=2115157432]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -47.5, 0, -47.5)
|
||||||
|
shape = SubResource("BoxShape3D_kdh3y")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="BuildingAreas/B_area_3/CollisionShape3D" unique_id=1402165923]
|
||||||
|
mesh = SubResource("BoxMesh_eat54")
|
||||||
|
|
||||||
|
[node name="B_area_4" type="StaticBody3D" parent="BuildingAreas" unique_id=898383723]
|
||||||
|
collision_mask = 7
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="BuildingAreas/B_area_4" unique_id=1612111692]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, -47.5)
|
||||||
|
shape = SubResource("BoxShape3D_kdh3y")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="BuildingAreas/B_area_4/CollisionShape3D" unique_id=1227151220]
|
||||||
|
mesh = SubResource("BoxMesh_eat54")
|
||||||
|
|
|
||||||
2
level.gd
2
level.gd
|
|
@ -3,7 +3,7 @@ extends Node3D
|
||||||
@export var dimension: int = 5
|
@export var dimension: int = 5
|
||||||
@export var path_count: int = 5
|
@export var path_count: int = 5
|
||||||
|
|
||||||
@export var ped_spawn_rate: int = 60
|
@export var ped_spawn_rate: int = 20
|
||||||
|
|
||||||
var pedestrian_scene = preload("res://pedestrian.tscn")
|
var pedestrian_scene = preload("res://pedestrian.tscn")
|
||||||
|
|
||||||
|
|
|
||||||
16
level.tscn
16
level.tscn
|
|
@ -9,12 +9,6 @@
|
||||||
ambient_light_source = 2
|
ambient_light_source = 2
|
||||||
ambient_light_color = Color(1, 1, 1, 1)
|
ambient_light_color = Color(1, 1, 1, 1)
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_vonw3"]
|
|
||||||
size = Vector3(10, 15, 10)
|
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_oi3di"]
|
|
||||||
size = Vector3(10, 7.5, 10)
|
|
||||||
|
|
||||||
[node name="Level" type="Node3D" unique_id=1248504413]
|
[node name="Level" type="Node3D" unique_id=1248504413]
|
||||||
script = ExtResource("1_0b4ue")
|
script = ExtResource("1_0b4ue")
|
||||||
|
|
||||||
|
|
@ -24,19 +18,11 @@ environment = SubResource("Environment_vonw3")
|
||||||
[node name="Player" parent="." unique_id=1536233267 instance=ExtResource("1_u52ul")]
|
[node name="Player" parent="." unique_id=1536233267 instance=ExtResource("1_u52ul")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8361101, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8361101, 0)
|
||||||
|
|
||||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="." unique_id=306152407]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.830486, 7.5, -23.788916)
|
|
||||||
mesh = SubResource("BoxMesh_vonw3")
|
|
||||||
|
|
||||||
[node name="Pedestrian" parent="." unique_id=468620437 instance=ExtResource("4_f2txt")]
|
[node name="Pedestrian" parent="." unique_id=468620437 instance=ExtResource("4_f2txt")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.219554, 2.045658, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.219554, 2.045658, 0)
|
||||||
|
|
||||||
[node name="MeshInstance3D3" type="MeshInstance3D" parent="." unique_id=373905113]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.874296, 3.5, -11.78)
|
|
||||||
mesh = SubResource("BoxMesh_oi3di")
|
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=2083164402]
|
[node name="Camera3D" type="Camera3D" parent="." unique_id=2083164402]
|
||||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 47.751747, 0)
|
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 33, 0)
|
||||||
current = true
|
current = true
|
||||||
fov = 55.0
|
fov = 55.0
|
||||||
script = ExtResource("2_vonw3")
|
script = ExtResource("2_vonw3")
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://beqs2m2yf1igp" path="res://pedestrian.gd" id="1_y5q06"]
|
[ext_resource type="Script" uid="uid://beqs2m2yf1igp" path="res://pedestrian.gd" id="1_y5q06"]
|
||||||
|
|
||||||
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_y5q06"]
|
||||||
|
height = 1.0
|
||||||
|
radius = 1.5
|
||||||
|
|
||||||
[sub_resource type="CylinderMesh" id="CylinderMesh_6pjml"]
|
[sub_resource type="CylinderMesh" id="CylinderMesh_6pjml"]
|
||||||
top_radius = 1.0
|
top_radius = 1.0
|
||||||
bottom_radius = 1.0
|
bottom_radius = 1.0
|
||||||
|
|
@ -12,13 +16,17 @@ albedo_color = Color(0.23, 0.23, 0.23, 1)
|
||||||
|
|
||||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_6pjml"]
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_6pjml"]
|
||||||
height = 0.5
|
height = 0.5
|
||||||
radius = 4.0
|
radius = 2.5
|
||||||
|
|
||||||
[node name="Pedestrian" type="StaticBody3D" unique_id=896871991]
|
[node name="Pedestrian" type="StaticBody3D" unique_id=896871991]
|
||||||
collision_layer = 0
|
collision_layer = 2
|
||||||
collision_mask = 0
|
collision_mask = 3
|
||||||
script = ExtResource("1_y5q06")
|
script = ExtResource("1_y5q06")
|
||||||
|
|
||||||
|
[node name="Collision" type="CollisionShape3D" parent="." unique_id=537549328]
|
||||||
|
shape = SubResource("CylinderShape3D_y5q06")
|
||||||
|
debug_color = Color(0.7909608, 0.32397082, 0.7167154, 0.41960785)
|
||||||
|
|
||||||
[node name="Mesh" type="MeshInstance3D" parent="." unique_id=58534625]
|
[node name="Mesh" type="MeshInstance3D" parent="." unique_id=58534625]
|
||||||
mesh = SubResource("CylinderMesh_6pjml")
|
mesh = SubResource("CylinderMesh_6pjml")
|
||||||
surface_material_override/0 = SubResource("StandardMaterial3D_y5q06")
|
surface_material_override/0 = SubResource("StandardMaterial3D_y5q06")
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
extends CharacterBody3D
|
extends CharacterBody3D
|
||||||
const BASE_STAMINA = 50
|
const BASE_STAMINA = 50
|
||||||
const BASE_SPEED = 50
|
const BASE_SPEED = 20
|
||||||
const SPRINT_MULT = 1.6
|
const SPRINT_MULT = 1.6
|
||||||
const SLOW_MULT = 0.5
|
const SLOW_MULT = 0.5
|
||||||
const STAMINA_COST = 15
|
const STAMINA_COST = 15
|
||||||
|
|
@ -39,7 +39,7 @@ func _on_area_area_entered(area: Area3D) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_area_area_exited(area: Area3D) -> void:
|
func _on_area_area_exited(area: Area3D) -> void:
|
||||||
if area.name == "PedestrianArea":
|
if area.name == "PedestrianArea":
|
||||||
pedestrian_area_count -= 1
|
pedestrian_area_count -= 1
|
||||||
print(pedestrian_area_count)
|
print(pedestrian_area_count)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,14 @@ radius = 1.0
|
||||||
|
|
||||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_onrkg"]
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_onrkg"]
|
||||||
height = 1.0
|
height = 1.0
|
||||||
radius = 25.0
|
radius = 30.0
|
||||||
|
|
||||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_hqtel"]
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_hqtel"]
|
||||||
height = 0.5
|
height = 0.5
|
||||||
radius = 40.0
|
radius = 50.0
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D" unique_id=17046866]
|
[node name="Player" type="CharacterBody3D" unique_id=17046866]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.153225, 0)
|
collision_layer = 4
|
||||||
script = ExtResource("1_4flbx")
|
script = ExtResource("1_4flbx")
|
||||||
|
|
||||||
[node name="Mesh" type="MeshInstance3D" parent="." unique_id=1740724392]
|
[node name="Mesh" type="MeshInstance3D" parent="." unique_id=1740724392]
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,12 @@ player_sprint={
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[layer_names]
|
||||||
|
|
||||||
|
3d_physics/layer_1="Building"
|
||||||
|
3d_physics/layer_2="Pedestrian"
|
||||||
|
3d_physics/layer_3="Player"
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
3d/physics_engine="Jolt Physics"
|
3d/physics_engine="Jolt Physics"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue