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 c3dca92..e85a712 100644 Binary files a/Content/Levels/FactoryHall.umap and b/Content/Levels/FactoryHall.umap differ diff --git a/Content/Levels/Raum4.umap b/Content/Levels/Raum4.umap index 45a896d..0d09424 100644 Binary files a/Content/Levels/Raum4.umap and b/Content/Levels/Raum4.umap differ diff --git a/Content/Levels/VillaDesign.umap b/Content/Levels/VillaDesign.umap index 771ecf9..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 acad991..6206e66 100644 --- a/Source/BuildingEscape/MovingActor.cpp +++ b/Source/BuildingEscape/MovingActor.cpp @@ -15,28 +15,56 @@ void UMovingActor::BeginPlay() void UMovingActor::Move() { + if(moving) return; + UE_LOG(LogTemp, Warning, TEXT("start")) targetLocation = GetOwner()->GetActorLocation(); + if(!Negative && !Up) + { + this->targetLocation.X += MovementTarget; + this->tempLocation = FVector(MovementSpeed, 0.0f, 0.0f); + } if (Negative) { - targetLocation.Y += MovementTarget; - tempLocation = FVector(0.0f, MovementSpeed, 0.0f); - } - if(!Negative) - { - targetLocation.X += MovementTarget; - tempLocation = FVector(MovementSpeed, 0.0f, 0.0f); + this->targetLocation.Y += MovementTarget; + this->tempLocation = FVector(0.0f, MovementSpeed, 0.0f); } if(Up) { - targetLocation.Z += MovementTarget; - tempLocation = FVector(0.0f, 0.0f, MovementSpeed); + this->targetLocation.Z += MovementTarget; + this->tempLocation = FVector(0.0f, 0.0f, MovementSpeed); + } - this->targetLocation = targetLocation; this->moving = true; - UE_LOG(LogTemp, Warning, TEXT("%f %f %f"), targetLocation.X, targetLocation.Y, targetLocation.Z) - UE_LOG(LogTemp, Warning, TEXT("%f"), MovementSpeed) + 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); @@ -48,8 +76,8 @@ 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 { @@ -59,7 +87,6 @@ void UMovingActor::Move() soundHasBeenPlayed = true; } - void UMovingActor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); @@ -67,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 bbe1b40..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, @@ -40,8 +43,10 @@ public: bool Up = false; private: - bool moving; + bool moving = false; bool soundHasBeenPlayed; FVector targetLocation; FVector tempLocation; + + void PlaySound(); };