人物排队bug修复(潜在的排队后不走)

This commit is contained in:
joylink_zhaoerwei 2024-07-17 11:23:34 +08:00
parent af7c44305b
commit 11c78bc818
8 changed files with 104 additions and 51 deletions

View File

@ -65,3 +65,15 @@ func _on_area_3d_area_exited(area: Area3D) -> void:
AreaExit.emit(area)
if currentExerciseType == Exercise_type.navigation and area.is_in_group('needStopWalk') :
goToTarget()
var frontPeople = 0
func _on_people_front_area_3d_area_entered(area: Area3D) -> void:
var peopleWalkFollow = area.get_parent().get_parent()
if ( area.is_in_group('player') and peopleWalkFollow.id != self.get_parent().id ) or area.is_in_group('needStopWalk') :
frontPeople += 1
func _on_people_front_area_3d_area_exited(area: Area3D) -> void:
var peopleWalkFollow = area.get_parent().get_parent()
if ( area.is_in_group('player') and peopleWalkFollow.id != self.get_parent().id ) or area.is_in_group('needStopWalk') :
frontPeople -= 1

View File

@ -16,7 +16,7 @@ var generateArea = 'A'
var speed:float = 1
#生成时候的id
var id = 0
var id = '0A'
##设置路线点坐标
func setPathPoints(points : Array,angle :Vector3 = Vector3()) -> void:
@ -52,7 +52,7 @@ func _on_path_follow_timer_timeout() -> void:
func _on_player_area_enter(area: Area3D) -> void:
if player.currentExerciseType == player.Exercise_type.pathFollow and (area.is_in_group('needStopWalk') or area.is_in_group('player')):
if player.currentExerciseType == player.Exercise_type.pathFollow and (area.is_in_group('needStopWalk') or area.is_in_group('player') ) and player.frontPeople == 1 :
peopleStopWalk()
var waitTimeWalkAgain = 0.2

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://c6noskjp3ks4p"]
[gd_scene load_steps=8 format=3 uid="uid://c6noskjp3ks4p"]
[ext_resource type="Script" path="res://sceen/people/Player.gd" id="1_pursd"]
[ext_resource type="PackedScene" uid="uid://ql5aokids4f6" path="res://sceen/people/people.tscn" id="2_ggqm4"]
@ -9,6 +9,9 @@
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_n25t3"]
radius = 0.4
[sub_resource type="BoxShape3D" id="BoxShape3D_ywkfy"]
size = Vector3(0.113147, 0.145019, 0.102899)
[node name="Player" type="CharacterBody3D"]
script = ExtResource("1_pursd")
@ -45,6 +48,15 @@ height = 2.0
[node name="NavigationTimer" type="Timer" parent="."]
wait_time = 0.05
[node name="PeopleFrontArea3D" type="Area3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.00255, -0.378363)
[node name="CollisionShape3D" type="CollisionShape3D" parent="PeopleFrontArea3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00299683, -0.0159907, 0.00346985)
shape = SubResource("BoxShape3D_ywkfy")
[connection signal="area_entered" from="Area3D" to="." method="_on_area_3d_area_entered"]
[connection signal="area_exited" from="Area3D" to="." method="_on_area_3d_area_exited"]
[connection signal="timeout" from="NavigationTimer" to="." method="_on_navigation_timer_timeout"]
[connection signal="area_entered" from="PeopleFrontArea3D" to="." method="_on_people_front_area_3d_area_entered"]
[connection signal="area_exited" from="PeopleFrontArea3D" to="." method="_on_people_front_area_3d_area_exited"]

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
extends Node3D
##
##闸机
class_name GateDoor
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
## 门的状态枚举
## 闸机门的状态枚举
enum Gate_Door_STATE{
opening,# 正在开门
open,#开到位
@ -14,7 +14,7 @@ enum Gate_Door_STATE{
close,# 关到位
}
##门的状态
##闸机门的状态
@onready var gateDoorState : Gate_Door_STATE = Gate_Door_STATE.close :
set(value):
if gateDoorState != value:
@ -27,13 +27,28 @@ enum Gate_Door_STATE{
right_animation_player.play("rightClose")
##打开
##打开闸机
func openGateDoor ()-> void:
if gateDoorState == Gate_Door_STATE.close :
gateDoorState = Gate_Door_STATE.open
##关闭
##关闭闸机
func closeGateDoor ()-> void:
if gateDoorState == Gate_Door_STATE.open :
gateDoorState=Gate_Door_STATE.close
var waitPeopleCount = 0
func _on_area_3d_area_entered(area: Area3D) -> void:
var peopleWalkFollow = area.get_parent().get_parent()
if peopleWalkFollow is PlayerPathFollow :
waitPeopleCount += 1
openGateDoor()
func _on_area_3d_area_exited(area: Area3D) -> void:
var peopleWalkFollow = area.get_parent().get_parent()
if peopleWalkFollow is PlayerPathFollow :
waitPeopleCount -= 1
if waitPeopleCount==0 :
closeGateDoor()

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://c0368j6203bj8"]
[gd_scene load_steps=17 format=3 uid="uid://c0368j6203bj8"]
[ext_resource type="Script" path="res://sceen/platform/gate/gateDoor.gd" id="1_b8ekv"]
[ext_resource type="Texture2D" uid="uid://dwjh85d7n6c6d" path="res://Model/trainingLargePassengerFlow/textures/DKL_zhaji.jpg" id="1_uqk0r"]
@ -90,12 +90,12 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
"values": [Vector3(0, 0, -0.0872665)]
}
[sub_resource type="Animation" id="Animation_hyiee"]
resource_name = "leftClose"
length = 0.8
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
@ -103,7 +103,7 @@ tracks/0/path = NodePath("left:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.8),
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 0, 0.506145), Vector3(0, 0, -0.0872665)]
@ -111,7 +111,7 @@ tracks/0/keys = {
[sub_resource type="Animation" id="Animation_0sy4u"]
resource_name = "leftOpen"
length = 0.8
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
@ -119,7 +119,7 @@ tracks/0/path = NodePath("left:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.8),
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 0, -0.0872665), Vector3(0, 0, 0.506145)]
@ -144,12 +144,12 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
"values": [Vector3(0, 0, 0.0872665)]
}
[sub_resource type="Animation" id="Animation_60d8m"]
resource_name = "rightClose"
length = 0.8
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
@ -157,7 +157,7 @@ tracks/0/path = NodePath("right:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.8),
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 0, -0.506145), Vector3(0, 0, 0.0872665)]
@ -165,7 +165,7 @@ tracks/0/keys = {
[sub_resource type="Animation" id="Animation_oxrhd"]
resource_name = "rightOpen"
length = 0.8
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
@ -173,7 +173,7 @@ tracks/0/path = NodePath("right:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.8),
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 0, 0.0872665), Vector3(0, 0, -0.506145)]
@ -186,17 +186,20 @@ _data = {
"rightOpen": SubResource("Animation_oxrhd")
}
[sub_resource type="BoxShape3D" id="BoxShape3D_qkt18"]
size = Vector3(0.754211, 0.91748, 0.72006)
[node name="GateDoor" type="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.4, 0)
script = ExtResource("1_b8ekv")
[node name="left" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.3, 0, 0)
transform = Transform3D(0.996195, 0.0871557, 0, -0.0871557, 0.996195, 0, 0, 0, 1, -0.3, 0, 0)
mesh = SubResource("ArrayMesh_rgh8h")
skeleton = NodePath("")
[node name="right" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3, 0, 0)
transform = Transform3D(0.996195, -0.0871557, 0, 0.0871557, 0.996195, 0, 0, 0, 1, 0.3, 0, 0)
mesh = SubResource("ArrayMesh_eyu4m")
skeleton = NodePath("")
@ -209,3 +212,12 @@ libraries = {
libraries = {
"": SubResource("AnimationLibrary_ppdod")
}
[node name="Area3D" type="Area3D" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.000457764, 0.0412598, 0.376033)
shape = SubResource("BoxShape3D_qkt18")
[connection signal="area_entered" from="Area3D" to="." method="_on_area_3d_area_entered"]
[connection signal="area_exited" from="Area3D" to="." method="_on_area_3d_area_exited"]

View File

@ -71,9 +71,9 @@ const areaInfo = {
'passage':Vector3(3,5.22,41),
'stationHallExit':Vector3(3,5.22,18.74),
'ticketingArea':[Vector3(-11.27,5.22,18.74)],
'entranceGateArea':[Vector3(-11.27,5.22,17.25),Vector3(36,5.22,17.25),Vector3(36,5.22,14)],
'entranceGateArea':[Vector3(-11.27,5.22,17.25),Vector3(36,5.22,17.25),Vector3(36,5.22,14.48)],
'gangwayUpArea':[Vector3(36,5.22,7.45),Vector3(31,5.22,7.45)],
'gangwayDownArea': [Vector3(14.12,0.85,7.45)]
'gangwayDownArea': [Vector3(14.12,0.85,7.45),Vector3(11.6,0.85,7.45)]
},
'B':{
'entrance':[ Vector3(-54.8,9.8,-67.3),Vector3(-50,9.8,-64),Vector3(-30.1,9.8,-62.3)],
@ -88,9 +88,9 @@ const areaInfo = {
'passage':Vector3(93.38,5.22,39.55),
'stationHallExit':Vector3(93.38,5.22,21.04),
'ticketingArea':[Vector3(99,5.22,14.25),Vector3(99,5.22,7.86),Vector3(109.26,5.22,7.86)],
'entranceGateArea':[Vector3(109.26,5.22,6.86),Vector3(92,5.22,6.86),Vector3(92,5.22,12.98),Vector3(78.33,5.22,17.29),Vector3(56,5.22,17.29),Vector3(56,5.22,14)],
'entranceGateArea':[Vector3(109.26,5.22,6.86),Vector3(92,5.22,6.86),Vector3(92,5.22,12.98),Vector3(78.33,5.22,17.29),Vector3(56.29,5.22,17.29),Vector3(56.29,5.22,14.48)],
'gangwayUpArea':[Vector3(56,5.22,7.45),Vector3(61.46,5.22,7.45)],
'gangwayDownArea': [Vector3(77,0.85,7.45)]
'gangwayDownArea': [Vector3(77,0.85,7.45),Vector3(81.2,0.85,7.45)]
}
}
@ -125,7 +125,7 @@ func playerGoToNextArea(peopleWalkFollow:PlayerPathFollow,nextArea: PlayerWalkAr
peopleWalkFollow.waitTimeWalkAgain = 0.5
walkByPathFollow(targetAreaInfo.entranceGateArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
await get_tree().create_timer(0.2).timeout
await get_tree().create_timer(0.5).timeout
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.gangwayUpArea)
PlayerWalkArea3D.gangwayUpArea:
walkByPathFollow(targetAreaInfo.gangwayUpArea,peopleWalkFollow)
@ -134,6 +134,7 @@ func playerGoToNextArea(peopleWalkFollow:PlayerPathFollow,nextArea: PlayerWalkAr
PlayerWalkArea3D.gangwayDownArea:
walkByPathFollow(targetAreaInfo.gangwayDownArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.queue_free()
#playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.screenDoorWaitArea)
PlayerWalkArea3D.screenDoorWaitArea:
goToScreenDoorAreaAndWaitTrain(peopleWalkFollow,0)
@ -234,20 +235,24 @@ func walkByPathFollow(allTargetPos:Array,peopleWalkFollow:PlayerPathFollow,curve
var people_scene = preload("res://sceen/people/peopleWalkFollow.tscn")
func startGeneratePeople() -> void:
$AllTimer/generatePeopleAEntranceTimer.start()
$AllTimer/generatePeopleBEntranceTimer.start()
$AllTimer/generatePeopleCEntranceTimer.start()
$AllTimer/generatePeopleDEntranceTimer.start()
$AllTimer/generatePeopleAtBTicketingArea.start()
##A入口生成
var totalOfAEntrance=0
func generatePeopleAtAEntrance() -> void:
if $AllAreaDetection/APassageAreaDetection.passPeopleCount< 0 and currentActiveCameraOfLarge != Camera_name.APassage:
if $AllAreaDetection/APassageAreaDetection.passPeopleCount< 1 and currentActiveCameraOfLarge != Camera_name.APassage:
generatePeopleAPassage()
if $AllAreaDetection/TicketingLfetAreaDetection.passPeopleCount< 0 and currentActiveCameraOfLarge != Camera_name.BTVM:
if $AllAreaDetection/TicketingLfetAreaDetection.passPeopleCount< 1 and currentActiveCameraOfLarge != Camera_name.BTVM:
generatePeopleAtBTVM()
totalOfAEntrance += 1
if totalOfAEntrance > 15:
if totalOfAEntrance > 10:
$AllTimer/generatePeopleAEntranceTimer.wait_time = 10
var peoplePosition = Vector3(-80,9.8,40.5)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'A',totalOfAEntrance)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'A','A{0}'.format([totalOfAEntrance]))
##A通道生成
@ -255,23 +260,25 @@ var totalOfAPassage=0
func generatePeopleAPassage() -> void:
totalOfAPassage += 1
var peoplePosition = Vector3(3,5.22,41)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.stationHallExit,'A')
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.stationHallExit,'A','A{0}'.format([totalOfAPassage]))
##A闸机生成
var totalOfBTVM=0
func generatePeopleAtBTVM() -> void:
totalOfBTVM += 1
var peoplePosition = Vector3(-11.27,5.22,18.74)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entranceGateArea,'A')
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entranceGateArea,'A','A{0}'.format([totalOfBTVM]))
##售票厅循环排队
var totalOfBTicketingArea = 8
var totalOfBTicketingArea = 0
func generatePeopleAtBTicketingArea() -> void:
if $AllAreaDetection/TicketingAreaDetection.waitPeopleCount < totalOfBTicketingArea:
if $AllAreaDetection/TicketingAreaDetection.waitPeopleCount < 8:
var peoplrInstance = people_scene.instantiate()
add_child(peoplrInstance)
peoplrInstance.global_position = Vector3(1,5.22,15.84)
peoplrInstance.buildPos = Vector3(1,5.22,15.84)
totalOfBTicketingArea += 1
peoplrInstance.id = 'A{0}'.format([totalOfBTicketingArea])
walkByPathFollow([Vector3(-11.27,5.22,15.84)],peoplrInstance)
await peoplrInstance.player.ArriveTargetPos
await get_tree().create_timer(5).timeout
@ -288,7 +295,7 @@ func generatePeopleAtDownPlatform() -> void:
if totalOfDownPlatform > 0:
totalOfDownPlatform -= 1
var peoplePosition = Vector3(13.54,0.85,11.2)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.screenDoorWaitArea,'A')
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.screenDoorWaitArea,'A','A{0}'.format([totalOfDownPlatform]))
else :
$AllTimer/generatePeopleDownPlatformTimer.stop()
@ -298,7 +305,7 @@ func generatePeopleAtBEntrance() -> void:
if totalOfBEntrance> 0:
totalOfBEntrance -= 1
var peoplePosition = Vector3(-54.8,9.8,-61)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'B',totalOfAEntrance)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'B','B{0}'.format([totalOfDownPlatform]))
else :
$AllTimer/generatePeopleBEntranceTimer.stop()
@ -308,22 +315,21 @@ func generatePeopleAtCEntrance() -> void:
if totalOfCEntrance> 0:
totalOfCEntrance -= 1
var peoplePosition = Vector3(146.12,9.8,-60)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'C',totalOfAEntrance)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'C','C{0}'.format([totalOfDownPlatform]))
else :
$AllTimer/generatePeopleCEntranceTimer.stop()
##D入口生成
var totalOfDEntrance=15
var totalOfDEntrance = 0
func generatePeopleAtDEntrance() -> void:
if totalOfDEntrance > 0:
totalOfDEntrance -= 1
totalOfDEntrance += 1
if totalOfDEntrance > 10:
$AllTimer/generatePeopleDEntranceTimer.wait_time = 10
var peoplePosition = Vector3(146.12,9.8,46)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'D',totalOfAEntrance)
else :
$AllTimer/generatePeopleDEntranceTimer.stop()
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'D','D{0}'.format([totalOfDownPlatform]))
##在指定区域增加人
func generatePeopleAtDesignatedArea(peoplePosition:Vector3, goToNextArea: PlayerWalkArea3D,generateArea:String, peopleId:int=0) -> void:
func generatePeopleAtDesignatedArea(peoplePosition:Vector3, goToNextArea: PlayerWalkArea3D,generateArea:String, peopleId:String='0A') -> void:
var peoplrInstance = people_scene.instantiate()
add_child(peoplrInstance)
peoplrInstance.global_position = peoplePosition

View File

@ -144,19 +144,15 @@ wait_time = 2.0
[node name="generatePeopleBEntranceTimer" type="Timer" parent="AllTimer"]
wait_time = 10.0
autostart = true
[node name="generatePeopleCEntranceTimer" type="Timer" parent="AllTimer"]
wait_time = 10.0
autostart = true
[node name="generatePeopleDEntranceTimer" type="Timer" parent="AllTimer"]
wait_time = 2.0
autostart = true
[node name="generatePeopleAtBTicketingArea" type="Timer" parent="AllTimer"]
wait_time = 2.0
autostart = true
[node name="generatePeopleDownPlatformTimer" type="Timer" parent="AllTimer"]
wait_time = 2.0