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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How do you shape trace without blueprints???

I need to check a box shaped area in front of my player for multiple objects.

I'm looking everywhere for documentation on shape tracing in C++ (or even just using shape components to check for overlap) and there doesn't seem to be anything. No matter what I search, all I can find is information about line tracing or raycasting.

https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/#shapetraces I found that you can include kismet libraries to use blueprint functions, but I haven't found any way to look up how those functions would appear in C++.

I found these functions: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UWorld/ComponentOverlapMulti/1/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UWorld/ComponentSweepMulti/1/index.html but they don't include any examples and I don't understand how the syntax works from these pages.

I'm at a loss and I would much rather keep my shape tracing in C++ than blueprints. I appreciate any help or direction, thanks.

edit: this looks promising: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UWorld/SweepMultiByChannel/index.html but I still don't understand how the parameters work. I'll keep trying in the meantime.

Product Version: UE 4.14
more ▼

asked Jul 10 '17 at 09:12 PM in C++ Programming

avatar image

3 1 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

This is very easy.

First of all you need have to create the shape you want to trace. FCollisionShape Shape = FCollisionShape::MakeBox(FVector(50,50,50));

Then you have to declare your hit result. FHitResult SweepResult;

To trace you just do the following: GetWorld()->SweepSingleByChannel(SweepResult, StartLocation, EndLocation, ShapeRotation, ECC_Visible, Shape)

this returns true if the sweep hit something. If that is the case you can use the SweepResult object to get more information about what you hit. If you want to know about all hits use SweepMultiByChannel. That takes an array of FHitResult.

more ▼

answered Jul 11 '17 at 10:30 AM

avatar image

576 21 10 32

avatar image NicholasCarrow Jul 11 '17 at 11:01 PM

Thank you! This is exactly what I needed. Is there any way to draw this with a debug line or visualize it?

avatar image MatzeOGH Jul 12 '17 at 08:18 AM

Yes. Take a look at the DrawDebugHelpers.h. There you can find all the debug visualizations you need.

avatar image NicholasCarrow Jul 13 '17 at 12:04 AM

Oh that's great thank you so much!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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