Hi! I create a door with “UStaticMeshComponent* StaticMeshDoorComponent”.
define
{
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = FlatDoor)
UStaticMeshComponent* StaticMeshDoorComponent;
}
create
{
StaticMeshDoorComponent =CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMeshDoorComponent"));
StaticMeshDoorComponent->SetSimulatePhysics(false);
StaticMeshDoorComponent->AttachTo(RootComponent);
}
bug function. check collision of StaticMeshDoorComponent with all actors in the world. Door actor have FRotator(0.0f,0.0f,.0.0f) rotation.
bool AFlatDoor::SetDoorRotation(const FRotator& rotator, bool opening)
{
FComponentQueryParams componentParams;
componentParams.AddIgnoredActor(this);
TArray<FHitResult> hits;
if (!GetWorld()->ComponentSweepMulti(
hits,
StaticMeshDoorComponent,
StaticMeshDoorComponent->GetComponentLocation() + FVector(0.0f, 0.0f, 1.0f),
StaticMeshDoorComponent->GetComponentLocation() + FVector(0.0f, 0.0f, 2.0f),
GetActorRotation()+rotator,
componentParams))
{
StaticMeshDoorComponent->SetRelativeRotation(rotator);
return true;
}
else
{
for (int i = 0; i < hits.Num(); i++)
{
DrawDebugPoint(GetWorld(), hits[i].ImpactPoint, 10.0f, FColor(255, 0, 0));
DrawDebugPoint(GetWorld(), hits[i].Location + FVector(0.0f, 0.0f, 5.0f), 10.0f, FColor(0, 0, 255));
GEngine->AddOnScreenDebugMessage(-1, -1.0f, FColor(0, 255, 0), hits[i].Actor->GetName());
}
return false;
}
}
Collision “StaticMeshDoorComponent” with “bpObject69”. Result: