ComponentSweepMulti does not return the correct location of colliders if the component that is passed in has been rotated at all. The actual collision on the object in the game will be correct.

Steps to Reproduce
  1. Create a new code project using the first person template, no starter content.
  2. Add a new Input action mapping named Sweep. Map it to an unused key on the keyboard.
  3. Create a duplicate copy of the default CubeMesh static mesh. Name the new mesh TestCube.
  4. Open TestCube in the static mesh editor and add two additional box colliders.
  5. Scale and position the colliders so that one is along the top sideof the cube and the other two are on opposite vertical sides of the cube.
  6. Add a new Actor class to the project named TestCubeActor.
  7. Add a UStaticMeshComponent to TestCubeActor and name it TheMesh.
  8. In the Editor, create a Blueprint of the class TestCubeActor. Name the Blueprint TestCubeActor_BP.
  9. In TestCubeActor_BP, set TheMesh to use TestCube.
  10. In the header file for the character class that was included when the project was created, add the following line of code at the bottom of the class: void RunSweep();
  11. In the source file for the character class, add the following line at the top of the file: #include "TestCubeActor.h"
  12. Add the following line in the SetupPlayerInputComponent function: InputComponent->BindAction("Sweep", IE_Pressed, this, &ATestCompSweepMultiCharacter::RunSweep);
  13. Add the following function at the bottom of the character source file:
    void ATestCompSweepMultiCharacter::RunSweep()
    	TArray<AActor*> TestCubeActorArray;
    	UGameplayStatics::GetAllActorsOfClass(this->GetWorld(), ATestCubeActor::StaticClass(), TestCubeActorArray);
    	GetWorld()->DebugDrawTraceTag = "DebugTraceTag";
    	FComponentQueryParams ComponentParams;
    	ComponentParams.TraceTag = FName("DebugTraceTag");
    	TArray<FHitResult> Hits;
    	ATestCubeActor* TheActor = Cast<ATestCubeActor>(TestCubeActorArray[0]);
    	TheActor->GetWorld()->ComponentSweepMulti(Hits, TheActor->TheMesh, this->GetActorLocation(), TheActor->TheMesh->GetComponentLocation(), TheActor->TheMesh->GetComponentRotation(), ComponentParams);
  14. In the Editor, place a single instance of TestCubeActor_BP into the level.
  15. Rotate TestCubeActor_BP around one or more axes.
  16. Start PIE mode.
  17. Press the input key set in step 2.

The colliders drawn by the debug trace do not match the position of the colliders on the object.

The colliders drawn by the debug trace match the position of the colliders on the object.

Have Comments or More Details?

Head over to the existing Questions & Answers thread and let us know what's up.

Login to Vote

ComponentUE - Simulation - Physics
Affects Versions4.7.64.9
Target Fix4.9
Fix Commit2605171
CreatedMay 14, 2015
ResolvedJul 10, 2015
UpdatedApr 27, 2018