bewegende türen und so

This commit is contained in:
Johannes Theiner 2020-12-08 12:21:49 +01:00
parent ace9bb7eaa
commit 27d0417015
Signed by: joethei
GPG Key ID: 9D2B9A00FDA85BCD
8 changed files with 34 additions and 11 deletions

View File

@ -18,6 +18,17 @@
{
"Name": "OculusVR",
"Enabled": false
},
{
"Name": "MeshEditor",
"Enabled": true
},
{
"Name": "Shotgun",
"Enabled": true,
"SupportedTargetPlatforms": [
"Win64"
]
}
],
"TargetPlatforms": [

Binary file not shown.

View File

@ -50,7 +50,7 @@ void UOpenDoor::OpenDoor()
{
FRotator rotation = GetOwner()->GetActorRotation();
rotation.Yaw = TargetAngle;
rotate(rotation);
Rotate(rotation);
open = true;
}
@ -58,7 +58,7 @@ void UOpenDoor::CloseDoor()
{
FRotator rotation = GetOwner()->GetActorRotation();
rotation.Yaw = 0.0f;
rotate(rotation);
Rotate(rotation);
open = false;
}

View File

@ -26,16 +26,21 @@ void URotatingActor::TickComponent(float DeltaTime, ELevelTick TickType, FActorC
rotating = false;
}else
{
GetOwner()->AddActorLocalRotation(DeltaTime * RotationSpeed * FRotator(0.0f, 1.0f, 0.0f));
GetOwner()->AddActorLocalRotation(DeltaTime * RotationSpeed * FRotator(0.0f, tempRotation, 0.0f));
}
}
}
void URotatingActor::rotate(FRotator targetRotation)
void URotatingActor::Rotate(const FRotator TargetRotation)
{
this->targetRotation = targetRotation;
this->targetRotation = TargetRotation;
rotating = true;
tempRotation = (TargetRotation.Yaw < 0) ? -1.f : 1.f;
if(Negative)
{
tempRotation = (TargetRotation.Yaw < 0) ? 1.f : -1.f;
}
if(AudioComponent != nullptr && !soundHasBeenPlayed)
{
AudioComponent->Play();
@ -43,10 +48,10 @@ void URotatingActor::rotate(FRotator targetRotation)
}
}
void URotatingActor::rotate()
void URotatingActor::Rotate()
{
FRotator rotation = GetOwner()->GetActorRotation();
rotation.Yaw = TargetAngle;
rotate(rotation);
Rotate(rotation);
}

View File

@ -18,8 +18,11 @@ public:
protected:
virtual void BeginPlay() override;
void rotate(FRotator targetRotation);
void rotate();
void Rotate(FRotator TargetRotation);
UFUNCTION()
void Rotate();
public:
virtual void TickComponent(float DeltaTime, ELevelTick TickType,
@ -37,8 +40,12 @@ public:
UPROPERTY(EditAnywhere)
float RotationDelay = 2.f;
UPROPERTY(EditAnywhere)
bool Negative = false;
private:
FRotator targetRotation;
bool rotating;
bool soundHasBeenPlayed;
float tempRotation;
};

View File

@ -29,6 +29,6 @@ void UTriggerOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType,
TriggerVolume->GetOverlappingActors(overlappingActors);
if (overlappingActors.Num() >= 1)
{
rotate();
Rotate();
}
}