x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

GetWorld()-> ComponentSweepMulti (...) ignore Rotation. Why?? ((

GetWorld()->ComponentSweepMulti(...) ignore Rotation. Why?? ((

Product Version: Not Selected
Tags:
more ▼

asked Apr 09 '15 at 02:19 PM in Bug Reports

avatar image

BingoBongo
62 9 8 11

avatar image Doug E ♦♦ STAFF Apr 09 '15 at 06:46 PM

Hey BingoBongo-

How are you using ComponentSweepMulti? Is this inside of a character or actor class? Could you provide more information on what you're trying to do and what exactly is happening?

Cheers

Doug Wilson

avatar image BingoBongo Apr 10 '15 at 07:58 AM

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: alt text

situation.jpg (247.2 kB)
avatar image Doug E ♦♦ STAFF Apr 16 '15 at 08:14 PM

Hey BingoBongo-

It appears you're trying to detect if something is blocking the door before it opens, correct? How is the function SetDoorRotation() being called? Also, what is the value of the rotator that is being passed into the function? Additionally, the start and end locations of the trace are along the Z-axis. This trace won't detect something blocking the door along its opening path.

An alternative method you could use would be to use the door's collision to check either an OnHit or OnOverlap event and if the event is triggered, then stop how the door is opening (if it's an animation or you're setting a new rotation).

Cheers

Doug Wilson

avatar image BingoBongo Apr 17 '15 at 08:22 AM

Door have states:

     enum E_STATE
     {
         ES_CLOSING,
         ES_CLOSED,
         ES_CLOSING_STOP,
         ES_OPENING,
         ES_OPENED,
         ES_OPENING_STOP,
     } state;
 

Tick function:

 void AFlatDoor::Tick(float DeltaTime)
 {
     Super::Tick(DeltaTime);
 
     if (state == ES_OPENING)
     {
         FRotator rotate = StaticMeshDoorComponent->GetRelativeTransform().GetRotation().Rotator();
         float localSpeed = DeltaTime*OPEN_ANGULAR_SPEED;
 
         if (fabsf(rotate.Yaw + localSpeed) >= fabsf(GetOpenAngle()))
         {
             if (SetDoorRotation(rotate + FRotator(0.0f, 0.0f, GetOpenAngle()), true))
                 OpenNow();
             else
                 state = ES_OPENING_STOP;
         }
         else
         {
             rotate.Yaw += (bLeftSided ? -localSpeed : localSpeed);
 
             if(!SetDoorRotation(rotate,true))
                 state = ES_OPENING_STOP;
         }
     }
     else if (state == ES_CLOSING)
     {
         FRotator rotate = StaticMeshDoorComponent->GetRelativeTransform().GetRotation().Rotator();
         float localSpeed = DeltaTime*OPEN_ANGULAR_SPEED;
 
         if (fabsf(rotate.Yaw) <= localSpeed)
         {
             if (SetDoorRotation(FRotator(0.0f, 0.0f, 0.0f),false))
                 CloseNow();
             else
                 state = ES_CLOSING_STOP;
         }
         else
         {
             rotate.Yaw += (rotate.Yaw<0.0f ? localSpeed : -localSpeed);
 
             if(!SetDoorRotation(rotate,false))
                 state = ES_CLOSING_STOP;
         }
     }
 }

I eventually replaced "ComponentSweepMulti()" on "LineTraceMulti()" in function "SetDoorRotation()".

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hey BingoBongo-

Were you able to get the behavior you were looking for by switching to using LineTraceMulti()? What exactly was the behavior you were looking for and what behavior did you have when using ComponentSweetMulti()? If you were able to solve the problem by using a different function would it be acceptable if I closed this post for tracking purposes?

more ▼

answered Apr 27 '15 at 02:08 PM

avatar image BingoBongo Apr 27 '15 at 06:49 PM

Ok. Close it.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question