How can I have a static mesh generate collisions if the player is not moving?

Hello,

I’m working on implementing a door (it is not using physics) and I’d like to have its rotation halted if it hits the player. I’m testing this with the SM_Door starter content. Which appears to come with a collision primitive built into it. I’ve also added UE_LOG’s in my OnComponentHit. Using those logs I’ve confirmed that collisions are registering if a moving player hits the door, but not the other way around. If the door is opening and the player is “in the way” no collision is detected.

I had seen this older post as well as this one that seem similar but don’t appear to help with my issue.

I’m sure I’m just missing a setting or something but I’ve been surfing the documentation for the last hour and haven’t been able to come up with a solution. Is there an easy way to get collisions (specifically OnHit collisions) to register for moving static mesh’s if the AActor they hit is stationary?

Thanks in advance!

UPDATE: I’ve added some logging statements to my Player’s OnComponentHit and it seems that the hit is sometimes being registered after the door passes through the player. I initially thought this was an issue with normals but it’s reproducible on both sides of the door. It’s very inconsistent behavior.

Here is the code for the door’s hit binding (bound to the static mesh on hit):

void ADefaultDoor::OnComponentHit(
	UPrimitiveComponent* HitComp,
	AActor* OtherActor,
	UPrimitiveComponent* OtherComponent,
	FVector NormalImpulse,
	const FHitResult& Hit)
{
	// TODO: Remove debug messages
	UE_LOG(LogTemp, Warning, TEXT("---------------------------"));
	UE_LOG(LogTemp, Warning, TEXT("Hit!"));
	UE_LOG(LogTemp, Warning, TEXT("HitComp: %s"), *HitComp->GetName());
	UE_LOG(LogTemp, Warning, TEXT("OtherActor: %s"), *OtherActor->GetName());
	UE_LOG(LogTemp, Warning, TEXT("OtherComponent: %s"), *OtherComponent->GetName());
	UE_LOG(LogTemp, Warning, TEXT("NormalImpulse: %s"), *NormalImpulse.ToString());
	UE_LOG(LogTemp, Warning, TEXT("Hit: %s"), *Hit.ToString());
}

Here is the code for the Player’s hit binding (bound to the capsule component on hit):

void APlayerCharacter::OnComponentHit(UPrimitiveComponent* HitComp, AActor* OtherActor,
	UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
	UE_LOG(LogTemp, Warning, TEXT("PLAYER HIT REGISTERED!"));
}

Here is the output when a hit is registered when the player is moving and the door is stationary:

LogTemp: Warning: ---------------------------
LogTemp: Warning: Hit!
LogTemp: Warning: HitComp: Door
LogTemp: Warning: OtherActor: BP_PlayerCharacter_C_0
LogTemp: Warning: OtherComponent: CollisionCylinder
LogTemp: Warning: NormalImpulse: X=0.000 Y=0.000 Z=0.000
LogTemp: Warning: Hit: bBlockingHit:True bStartPenetrating:False Time:0.084244 Location:X=989.612 Y=317.838 Z=131.879 ImpactPoint:X=998.506 Y=349.757 Z=194.116 Normal:X=0.444 Y=0.896 Z=-0.000 ImpactNormal:X=0.444 Y=0.896 Z=-0.000 TraceStart:X=989.196 Y=317.986 Z=131.879 TraceEnd:X=991.440 Y=317.188 Z=131.879 PenetrationDepth:0.000000 Item:-1 PhysMaterial:None Actor:BP_TestDefaultDoor_C_1 Component:Door BoneName:None FaceIndex:-1
LogTemp: Warning: Forward Vector Force: 0.987892
LogTemp: Warning: Rel Impact Normal X: 1.000000, Y: 0.000000, Z: 1.000000
LogTemp: Warning: PLAYER HIT REGISTERED!

Here is the output when a hit is registered when the player is stationary and the door is moving (this one seems to occur inconsistently):


LogTemp: Warning: PLAYER HIT REGISTERED!
LogTemp: Warning: ---------------------------
LogTemp: Warning: Hit!
LogTemp: Warning: HitComp: Door
LogTemp: Warning: OtherActor: BP_PlayerCharacter_C_0
LogTemp: Warning: OtherComponent: CollisionCylinder
LogTemp: Warning: NormalImpulse: X=0.000 Y=0.000 Z=0.000
LogTemp: Warning: Hit: bBlockingHit:True bStartPenetrating:True Time:0.000000 Location:X=1002.221 Y=341.246 Z=89.650 ImpactPoint:X=1008.502 Y=341.778 Z=74.566 Normal:X=-0.686 Y=-0.727 Z=-0.000 ImpactNormal:X=-0.686 Y=-0.727 Z=-0.000 TraceStart:X=1002.221 Y=341.246 Z=89.650 TraceEnd:X=988.412 Y=318.658 Z=89.650 PenetrationDepth:29.697197 Item:-1 PhysMaterial:None Actor:BP_TestDefaultDoor_C_1 Component:Door BoneName:None FaceIndex:-1
LogTemp: Warning: Hit while opening!
LogTemp: Warning: New working min! 58.560001

I can’t see the code for opening doors, but do you have bSweep set to true?

Also, in my experience with UE I really try to avoid Hit Events for detecting stuff as it’s always somehow frustrating to get it work. I can’t say it’s not working, but I always need to fiddle around a lot to get the expected results.
That’s why for your case I would suggest creating a secondary box trigger and detecting its overlap event. But again - it’s my preference.

So, I do have sweep enabled however I’m just now noticing that the documentation for AddRelativeRotation (which is what I’m using to perform the rotation) says the following:

bSweep → Whether we sweep to the destination (currently not supported for rotation).

I guess they’re using a common signature for this family of functions but I had expected bSweep to work given that it’s listed as an argument…

I wonder why it’s still present in the Add/Set*Rotation() methods if it’s not implemented?

I think I will move to your solution and use a separate overlap event. Thanks for the suggestion!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.