diff --git a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/SlideDoorButton_BP.uasset b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/SlideDoorButton_BP.uasset index 7a68b01..ecdb096 100644 Binary files a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/SlideDoorButton_BP.uasset and b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/SlideDoorButton_BP.uasset differ diff --git a/Content/Levels/FactoryHall.umap b/Content/Levels/FactoryHall.umap index f1fd701..e85a712 100644 Binary files a/Content/Levels/FactoryHall.umap and b/Content/Levels/FactoryHall.umap differ diff --git a/Content/Levels/FactoryHall_BuiltData.uasset b/Content/Levels/FactoryHall_BuiltData.uasset index 4e8f2df..deb1ce2 100644 Binary files a/Content/Levels/FactoryHall_BuiltData.uasset and b/Content/Levels/FactoryHall_BuiltData.uasset differ diff --git a/Content/Levels/PersistentLevel.umap b/Content/Levels/PersistentLevel.umap index 0d3d448..706f85f 100644 Binary files a/Content/Levels/PersistentLevel.umap and b/Content/Levels/PersistentLevel.umap differ diff --git a/Content/Levels/PersistentLevel_BuiltData.uasset b/Content/Levels/PersistentLevel_BuiltData.uasset index 654e2b2..4ba5d37 100644 Binary files a/Content/Levels/PersistentLevel_BuiltData.uasset and b/Content/Levels/PersistentLevel_BuiltData.uasset differ diff --git a/Content/Levels/Raum4.umap b/Content/Levels/Raum4.umap index f3383a3..0d09424 100644 Binary files a/Content/Levels/Raum4.umap and b/Content/Levels/Raum4.umap differ diff --git a/Content/Levels/Untitled.umap b/Content/Levels/Untitled.umap index e512b39..65688ec 100644 Binary files a/Content/Levels/Untitled.umap and b/Content/Levels/Untitled.umap differ diff --git a/Content/Levels/VillaDesign.umap b/Content/Levels/VillaDesign.umap index e205ed0..d9e222c 100644 Binary files a/Content/Levels/VillaDesign.umap and b/Content/Levels/VillaDesign.umap differ diff --git a/Source/BuildingEscape/MovingActor.cpp b/Source/BuildingEscape/MovingActor.cpp index e54120e..6206e66 100644 --- a/Source/BuildingEscape/MovingActor.cpp +++ b/Source/BuildingEscape/MovingActor.cpp @@ -15,18 +15,56 @@ void UMovingActor::BeginPlay() void UMovingActor::Move() { + if(moving) return; + UE_LOG(LogTemp, Warning, TEXT("start")) targetLocation = GetOwner()->GetActorLocation(); - targetLocation.X += MovementTarget; - tempLocation = FVector(MovementSpeed, 0.0f, 0.0f); + if(!Negative && !Up) + { + this->targetLocation.X += MovementTarget; + this->tempLocation = FVector(MovementSpeed, 0.0f, 0.0f); + } if (Negative) { - targetLocation.X -= MovementTarget; - targetLocation.Y += MovementTarget; - tempLocation = FVector(0.0f, MovementSpeed, 0.0f); + this->targetLocation.Y += MovementTarget; + this->tempLocation = FVector(0.0f, MovementSpeed, 0.0f); } - this->targetLocation = targetLocation; - this->moving = true; + if(Up) + { + this->targetLocation.Z += MovementTarget; + this->tempLocation = FVector(0.0f, 0.0f, MovementSpeed); + } + this->moving = true; + UE_LOG(LogTemp, Warning, TEXT("%f %f %f"), targetLocation.X, targetLocation.Y, targetLocation.Z) + PlaySound(); +} + +void UMovingActor::MoveBack() +{ + if(moving) return; + this->targetLocation = GetOwner()->GetActorLocation(); + if(!Negative && !Up) + { + this->targetLocation.X -= MovementTarget; + this->tempLocation = FVector(-MovementSpeed, 0.0f, 0.0f); + } + if (Negative) + { + this->targetLocation.Y -= MovementTarget; + this->tempLocation = FVector(0.0f, -MovementSpeed, 0.0f); + } + if(Up) + { + this->targetLocation.Z -= MovementTarget; + this->tempLocation = FVector(0.0f, 0.0f, -MovementSpeed); + + } + this->moving = true; + PlaySound(); +} + +void UMovingActor::PlaySound() +{ TArray Audios; GetOwner()->GetComponents(Audios); @@ -38,19 +76,17 @@ void UMovingActor::Move() if (Audio->ComponentHasTag("location")) { UGameplayStatics::PlaySoundAtLocation(GetOwner(), Audio->Sound, GetOwner()->GetActorLocation(), - GetOwner()->GetActorRotation(), 1, 1, 0, - Audio->AttenuationSettings, nullptr, GetOwner()); + GetOwner()->GetActorRotation(), 1, 1, 0, + Audio->AttenuationSettings, nullptr, GetOwner()); } else { Audio->Play(); } } - soundHasBeenPlayed = true; } - void UMovingActor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); @@ -58,7 +94,7 @@ void UMovingActor::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom if (moving) { FVector Location = GetOwner()->GetActorLocation(); - if (Location.Equals(targetLocation, 1.0f)) + if (Location.Equals(targetLocation, 5.0f)) { moving = false; } diff --git a/Source/BuildingEscape/MovingActor.h b/Source/BuildingEscape/MovingActor.h index 0c3be18..a0f5a3b 100644 --- a/Source/BuildingEscape/MovingActor.h +++ b/Source/BuildingEscape/MovingActor.h @@ -22,6 +22,9 @@ protected: UFUNCTION(BlueprintCallable) void Move(); + UFUNCTION(BlueprintCallable) + void MoveBack(); + public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, @@ -36,9 +39,14 @@ public: UPROPERTY(EditAnywhere) bool Negative = false; + UPROPERTY(EditAnywhere) + bool Up = false; + private: - bool moving; + bool moving = false; bool soundHasBeenPlayed; FVector targetLocation; FVector tempLocation; + + void PlaySound(); };