Merge
This commit is contained in:
commit
5b6ac89872
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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<UAudioComponent*> Audios;
|
||||
GetOwner()->GetComponents<UAudioComponent>(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;
|
||||
}
|
||||
|
@ -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();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user