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"

How can I use UFUNCTION(Exec) from within UActorComponent?

Hello!--

I am trying to enable a debug flag on my component using the Console

I am able to see my function by flagging it as EXEC, however it does not execute when run.

  • I attempted both a static and non-static implementation of my function with no success

Any solutions or work-arounds would be greatly appreciated.

Thanks in advance :)


For Devs: If possible, I would also like to request further Documentation on the Exec feature. The doc states it only works in some classes, but that information is unavailable so far as I can tell.

Product Version: Not Selected
Tags:
more ▼

asked May 19 '14 at 05:00 AM in C++ Programming

avatar image

JDizzleSTiX
68 4 6 9

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

2 answers: sort voted first

That doesnt work by default, you'd have to hook it up yourself. To do so you could override ProcessConsoleExec on your player pawn to forward it to your component (just find the components you want and call ProcessConsoleExec on them if the super returns false

more ▼

answered May 19 '14 at 09:58 PM

avatar image

[Epic]Ben Zeigler STAFF
1.3k 30 131 75

avatar image JDizzleSTiX May 20 '14 at 05:26 AM

Thanks, Ben! I will give this a shot.

Fingers cross that I can just shoot them at all the Components and see which one will handle it.

avatar image JDizzleSTiX May 20 '14 at 05:46 AM

I can now confirm that this does work:

added to my PlayerController .h file:

 virtual bool ProcessConsoleExec(const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor) OVERRIDE;

added to my PlayerController .cpp file:

 bool AMyPlayerController::ProcessConsoleExec(const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor)
 {
     bool Result = false;
     APawn* const Pawn = GetPawn();
     TArray<UActorComponent*> Components;
     Pawn->GetComponents<UActorComponent>(Components);
     for (UActorComponent* Comp : Components)
     {
         Result = Comp->ProcessConsoleExec(Cmd, Ar, Executor) || Result;
     }
     return Result;
 }

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

Hi JDizzleSTiX,

I spoke with a member of our Documentation team, and they confirmed that the page for the Exec function specifier is one that they have targeted for improvement. They were also able to provide me with a list of classes that look for exec functions, and those classes are: Pawn, PlayerController, CheatManager, GameMode, PlayerInput, and HUD. I do not have any information regarding what you can try to do as a work around for this. Would you be able to provide more details regarding exactly what end result you are looking for, and how you are currently trying to achieve that (some code snippets would be great)?

Thanks, Tim

more ▼

answered May 19 '14 at 03:09 PM

avatar image JDizzleSTiX May 20 '14 at 05:25 AM

Thank you for the response, Tim! Love hearing that the team is looking into improving this.


Code snippets would be simple here. Imagine defining a Component variable (static or non-static) that an Exec function can set to true/false. As an example: a variable that enables debug drawing to visualize a frontal perception cone of an AActor.


It may be more worthwhile to explain what I am trying to achieve.

I am investigating the creation of a standalone Plugin with multiple Modules...

...responsible for various UActorComponents and their associated UObjects/Data. The goal is to conveniently attach these to any Actor within any given Project. Each component then has their own self-contained debug to visualize parameters and output on the owning AActor.

The scenario I am trying to avoid is...

...needing to create an additional module that includes my whole Plugin and implements a CheatManager/Pawn/GameMode where all the debug functionality must reside and all Projects must inherit from.

  • In general, I hope to keep my modules separate and only include one-another when functionality between one-another is required.

  • I am worried that if the debug is not within the Component, I will need to provide various methods for private/protected data that the debug content must access.


That all said, recommendations would be greatly appreciated if you feel this may be the wrong path. I would love to hear how a Staffer would approach a solution to this :)

Thanks in advance! J

(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