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"

Stop runtime on error

Im making a project that needs an actor to find an specific component from certain other actors, and because how unreal engine works the editor crashes if it doesnt have that component (yes even with if (component!=null)) and wnat to know how to make the editor just stop running and throw an error in case that other actor does not have the component. I have read the assertions documentation but do not understand how ot use it correctly or even if it will help me in this case.

Product Version: UE 4.16
Tags:
more ▼

asked Nov 13 '17 at 05:20 AM in C++ Programming

avatar image

ilanegra
7 2 4 7

avatar image Dune Nov 13 '17 at 05:20 PM

Do you have an example of this code at all, and are you trying to do these things in a constructor?

avatar image ilanegra Nov 13 '17 at 09:50 PM
 UActorComponent* tempTargetComp;
     for (int object = 0; object < affectedObjects.Num(); ++object) {
         tempTargetComp = affectedObjects[object]->GetComponentByClass(UAROTarget::StaticClass());
         check(tempTargetComp != nullptr);
         //if (tempTargetComp != nullptr) {
         targetAROComponent[object] = dynamic_cast<UAROTarget*>(tempTargetComp);
         check(targetAROComponent[object] != nullptr);
         //}
     }

That is on a function that is called on BeginPlay() but editor still crashes if affectedObjects[object] does not have a UAROTarget component

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

1 answer: sort voted first

Assertion is simple, simply call check(bool condition); if it's false you will get a crash with failed condition in log

As for stoping it, it's impossible if you can't prevent check() to be called, you can try to overriding function with them. In log you should find location of where triggered check and try to overriding it if it's possible.

Note that those assertion checks are code assumptions, it means forward code is not prepared for other condition then defined in the check function, it means even if you gonna override it, the forward code still might have issue with newly introduced condition

more ▼

answered Nov 13 '17 at 05:53 PM

avatar image

Shadowriver
37.8k 937 172 1123

(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