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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Why does SweepSingleByChannel not work with a Box?

 FCollisionShape StructureCollision = StructureMesh->GetCollisionShape();
             
 FHitResult Hit; 
     
 FVector CollisionLocation;
 CollisionLocation = GetActorLocation();
 CollisionLocation.Z += StructureCollision.GetBox().Z;
     
 bool bHasHit = GetWorld()->SweepSingleByChannel(Hit, CollisionLocation, CollisionLocation, FQuat::Identity, ECollisionChannel::ECC_GameTraceChannel2, StructureCollision); //<--
     
 DrawDebugBox(GetWorld(), CollisionLocation, StructureCollision.GetExtent(), (bHasHit ? FColor::Green : FColor::Red), true, 5.f);
     

What I am expecting: When StructureMesh (Static Mesh) is overlapping with another actor in the scene that respons to the appropriate channel (and this code is called) the debug box should be green.alt text

What happens instead: The debug box does not turn green and therefore no hit results are generated. But replacing

 bool bHasHit = GetWorld()->SweepSingleByChannel(Hit, CollisionLocation, CollisionLocation, FQuat::Identity, ECollisionChannel::ECC_GameTraceChannel2, StructureCollision);

with

 bool bHasHit = GetWorld()->SweepSingleByChannel(Hit, CollisionLocation, CollisionLocation, FQuat::Identity, ECollisionChannel::ECC_GameTraceChannel2, FCollisionShape::MakeSphere(300.f));

does lead to the debug color turning green. alt text

Note: Using FCollisionShape::MakeBox(300.f, 300.f, 300.f) doesn't work either.

How can I fix this?

Product Version: UE 4.15
Tags:
more ▼

asked May 10 '17 at 03:02 PM in C++ Programming

avatar image

ShiroiTenshio
53 3 4 8

avatar image eyosido Sep 25 '17 at 08:45 AM

I think box collision is working now (4.17), I have made some testing with foliage collision and it seems to be working.

avatar image ShiroiTenshio Sep 25 '17 at 11:35 PM

I have used blueprint as a workaround for this. In 4.17. I haven't encountered it so far.

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

1 answer: sort voted first

start and end location need to be different. add a small increment (0.001f) to the Z-axis on the start location, and then set that as the end. good luck

more ▼

answered Nov 29 '18 at 11:34 PM

avatar image

anonymoussalt
181 3 10 36

(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