türen die wieder richtig öffnen und so
This commit is contained in:
parent
c97104eb30
commit
270ec3c32a
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.
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.
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.
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.
Binary file not shown.
|
@ -9,81 +9,77 @@
|
|||
// Sets default values for this component's properties
|
||||
UOpenDoor::UOpenDoor()
|
||||
{
|
||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||
// off to improve performance if you don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||
// off to improve performance if you don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
|
||||
// ...
|
||||
// ...
|
||||
}
|
||||
|
||||
// Called when the game starts
|
||||
void UOpenDoor::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
// ...
|
||||
//if(PressurePlate->IsOverlappingActor(ActorThatOpens)) // kann nullpointer + UE4 crash geben
|
||||
//if(PressurePlate && PressurePlate->IsOverlappingActor(ActorThatOpens)) //prüft erst, ob es ein actor gibt
|
||||
//UE_LOG(LogTemp, Display, TEXT("%f Total Weight"), TotalMass());
|
||||
if (TotalMass() >= MassToOpenDoor)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("%f Total Weight"), TotalMass());
|
||||
OpenDoor();
|
||||
//DoorLastOpened When the door was opened
|
||||
doorLastOpened = GetWorld()->GetTimeSeconds();
|
||||
}
|
||||
// ...
|
||||
//if(PressurePlate->IsOverlappingActor(ActorThatOpens)) // kann nullpointer + UE4 crash geben
|
||||
//if(PressurePlate && PressurePlate->IsOverlappingActor(ActorThatOpens)) //prüft erst, ob es ein actor gibt
|
||||
//UE_LOG(LogTemp, Display, TEXT("%f Total Weight"), TotalMass());
|
||||
if (TotalMass() >= MassToOpenDoor)
|
||||
{
|
||||
//UE_LOG(LogTemp, Display, TEXT("%f Total Weight"), TotalMass());
|
||||
OpenDoor();
|
||||
//DoorLastOpened When the door was opened
|
||||
doorLastOpened = GetWorld()->GetTimeSeconds();
|
||||
}
|
||||
|
||||
else if(open)
|
||||
{
|
||||
//if door has been open longer than DoorCloseDelay
|
||||
//if(GetWorld()->GetTimeSeconds() > DoorLastOpened + DoorDelay)
|
||||
if (GetWorld()->GetTimeSeconds() - doorLastOpened > RotationDelay)
|
||||
CloseDoor();
|
||||
}
|
||||
else if (open)
|
||||
{
|
||||
//if door has been open longer than DoorCloseDelay
|
||||
//if(GetWorld()->GetTimeSeconds() > DoorLastOpened + DoorDelay)
|
||||
if (GetWorld()->GetTimeSeconds() - doorLastOpened > RotationDelay)
|
||||
CloseDoor();
|
||||
}
|
||||
}
|
||||
|
||||
void UOpenDoor::OpenDoor()
|
||||
{
|
||||
FRotator rotation = GetOwner()->GetActorRotation();
|
||||
rotation.Yaw = TargetAngle;
|
||||
Rotate(rotation);
|
||||
open = true;
|
||||
FRotator rotation = GetOwner()->GetActorRotation();
|
||||
rotation.Yaw = TargetAngle;
|
||||
Rotate(rotation);
|
||||
open = true;
|
||||
}
|
||||
|
||||
void UOpenDoor::CloseDoor()
|
||||
{
|
||||
FRotator rotation = GetOwner()->GetActorRotation();
|
||||
rotation.Yaw = 0.0f;
|
||||
Rotate(rotation);
|
||||
open = false;
|
||||
FRotator rotation = GetOwner()->GetActorRotation();
|
||||
rotation.Yaw = 0.0f;
|
||||
Rotate(rotation);
|
||||
open = false;
|
||||
}
|
||||
|
||||
float UOpenDoor::TotalMass() const
|
||||
{
|
||||
float TotalMass = 0.f;
|
||||
float TotalMass = 0.f;
|
||||
|
||||
//find All Overlapping Actors
|
||||
TArray<AActor*> OverlapingActors;
|
||||
//find All Overlapping Actors
|
||||
TArray<AActor*> OverlapingActors;
|
||||
|
||||
if (!PressurePlate) { return TotalMass; }
|
||||
PressurePlate->GetOverlappingActors(OUT OverlapingActors);
|
||||
if (!PressurePlate) { return TotalMass; }
|
||||
PressurePlate->GetOverlappingActors(OUT OverlapingActors);
|
||||
|
||||
//Add Up Their Masses
|
||||
for (AActor* Actor : OverlapingActors)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("%s Actor"), *Actor->GetName());
|
||||
if (Actor->FindComponentByClass<UPrimitiveComponent>()->IsAnySimulatingPhysics())//probably why doors wont open
|
||||
{
|
||||
TotalMass =+ Actor->FindComponentByClass<UPrimitiveComponent>()->GetMass();
|
||||
}
|
||||
|
||||
}
|
||||
//Add Up Their Masses
|
||||
for (AActor* Actor : OverlapingActors)
|
||||
{
|
||||
//UE_LOG(LogTemp, Display, TEXT("Actor: %s"), *Actor->GetName());
|
||||
TotalMass += Actor->FindComponentByClass<UPrimitiveComponent>()->GetMass();
|
||||
}
|
||||
|
||||
return TotalMass;
|
||||
}
|
||||
return TotalMass;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue