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"

Custom nodes (C++)

Hey! I don't know but my code doesn't work for some reason, I've tried so many different things and gave up. Any help you be awsome :-) thanks in advance :-)

header file:

 #pragma once

 #include "GameFramework/Actor.h"
 #include "multiRun.generated.h"
 #include "EMultiRunEnum.h"
 
 UCLASS(meta = (BlueprintSpawnableComponent))
 class UNKNOWN_API AmultiRun : public ActorComponent
 {
     GENERATED_BODY()
 
 public:
     UFUNCTION(BlueprintPure, Meta = (FriendlyName = "MultiRun", CompactNodeTitle = "MultiRun", Keywords = "Multi Run", ExpandEnumAsExecs = "Branches"), Category = Game)
         bool MultiRun(bool active, TEnumAsByte<EMultiRunEnum>& Branches);
 };

cpp file:

 #include "unknown.h"
 #include "multiRun.h"
 #include "EMultiRunEnum.h"
 
 
 void multiRun::MultiRun(bool active, TEnumAsByte<EMultiRunEnum>& Branches)
 {
     if (active)
     {
         Branches = EMultiRunEnum::BranchA;
         Branches = EMultiRunEnum::BranchB;
     }
 }

Product Version: UE 4.8
Tags:
more ▼

asked Aug 12 '15 at 06:50 AM in C++ Programming

Xillez gravatar image

Xillez
52 4 7 56

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

3 answers: sort voted first

Change BlueprintPure to BlueprintCallable. BlueprintPure is only for marking functions so that they appear to not need an exec pin when used in Blueprint.

They are analogous to 'const' functions in C++, but sometimes you actually need to do something non-const in your C++ code even though you want it to appear as a const function in Blueprint. In that case you would use BlueprintPure. But since your Blueprint function is specifically not const function (in fact, it exists only to modify control flow), you need to use BlueprintCallable, otherwise weird things will happen, such as a Blueprint compiler/intepreter discarding your function usage in the Blueprint graph.

more ▼

answered Aug 12 '15 at 10:13 AM

cancel gravatar image

cancel
2.1k 96 64 104

Xillez gravatar image Xillez Aug 16 '15 at 02:25 PM +

Still didn't work sorry, for some reason UE4 does not like my nodes so... yea idk what to do at this point... I modified the code because it looked like it was conflicting with a different node but... nothing happened :-( Header:

     #pragma once
     #include "GameFramework/Actor.h"
     #include "multiBranch.generated.h"
     #include "EMultiBranchEnum.h"
     
     UCLASS(meta = (BlueprintSpawnableComponent))
     class UNKNOWN_API AmultiBranch : public ActorComponent
     {
         GENERATED_BODY()
     
     public:
         UFUNCTION(BlueprintCallable, Meta = (FriendlyName = "MultiBranch", CompactNodeTitle = "MultiBranch", Keywords = "Multi Branch", ExpandEnumAsExecs = "Branches"), Category = Game)
             void MultiRun(bool active, TEnumAsByte<EMultiBranchEnum>& Branches);
     };

CPP file:

 #pragma once
 #include "unknown.h"
 #include "multiBranch.h"
 #include "EMultiBranchEnum.h"

 void AmultiBranch::MultiBranch(bool active, TEnumAsByte<EMultiBranchEnum>& Branches)
 {
     if (active)
     {
         Branches = EMultiBranchEnum::BranchA;
         Branches = EMultiBranchEnum::BranchB;
     }
 }


my Enums:

 #pragma once

 #include "GameFramework/Actor.h"
 #include "multiBranch.generated.h"
 
 UENUM(BlueprintActor)
 enum class EMultiBranchEnum
 {
 public: 
     BranchA,
     BranchB
 };

any help would be amazin XD

cancel gravatar image cancel Aug 21 '15 at 02:54 PM

Get rid of CompactNodeTitle, you shouldn't use compact node styling if it has exec pins.

Shadowriver gravatar image Shadowriver ♦ Aug 21 '15 at 03:38 PM +

What exactly is going on? Node does not appear or what? how does it not work? You didn't said.

Also post reponce to anwser by posting comment to anwser, not as another anwser

Xillez gravatar image Xillez Aug 21 '15 at 06:52 PM

The Node doesn't show in the editor.

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

You placing function in component, so it wont show up in context menu unles from pin containing object of that component. Your node should be visible in Pallet tab which contains all function nodes should be visible. Pallet tab is closed by default, you need to open it from "Window" manu.

more ▼

answered Aug 21 '15 at 07:25 PM

Shadowriver gravatar image

Shadowriver ♦
24.1k 880 108 991

Xillez gravatar image Xillez Aug 22 '15 at 07:34 AM

ok, but what do I need to switch out in the code?

Shadowriver gravatar image Shadowriver ♦ Aug 22 '15 at 04:09 PM

nothing, it should be there, your code looks ok

Xillez gravatar image Xillez Aug 22 '15 at 09:34 PM

ok? because it still isn't there XD

cancel gravatar image cancel Aug 22 '15 at 09:44 PM

Because it's declared as a non-static member function on your UAmultiBranch (I'm assuming you lost the U prefix on the name when copying/pasting somehow, otherwise it wouldn't compile) component class, it will only show up if you drag a blue pin/wire off of a reference to a UAmultiBranch component instance and then search for it in the popup window for adding nodes. It's likely that you aren't doing this, which is why you don't see it when you right click in the Blueprint editor and try to add a node. You MUST find a blue pin/win wire that is a reference to a component instance and create the node from there, or from the node palette within the correct scope.

If you send a screenshot showing that this is not happening, then it's a bug in UE4, but it's almost certain that you're misunderstanding what's going on and doing it incorrectly from the Blueprint editor.

Shadowriver gravatar image Shadowriver ♦ Aug 23 '15 at 12:28 AM

Well i told him to look on Pallet window, all function nodes (not sure about custom K2Nodes) are visible there regardless of class they came from

cancel gravatar image cancel Aug 23 '15 at 12:30 AM

Yeah I think he is just doing something wrong or looking in the wrong place

Shadowriver gravatar image Shadowriver ♦ Aug 23 '15 at 12:37 AM

Well your code looks ok, only think that looks odd is ActorComponent without U prefix, but that would trow you a error. you could try removing CompactNodeTitle = "MultiBranch" as Cancel said, but it's just cosmetic feature, so it should not matter and besides if theres something invalid in UFUNCTION, UHT would not let you build your code.

Only idea that popup in my head just now is that this code file does not compile at all (which would explain why you not getting error from incorrect naming of UActorComponent), this happens when you add file using VS which will create file in Intermediate directory where UBT don't look for code files. Can you check if you got that file in Source directory (but don't look in VS, look in some disk browser)?

cancel gravatar image cancel Aug 23 '15 at 12:44 AM

Yeah that was my next thought -- his file isn't compiling at all

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

Ok, sorry, took a small break from development, but: I made an if instead, incase there is any incompatible use of branches (two branches that are called at the same time). The code now: EMultiBranchEnum.h:

 #pragma once
 
 #include "GameFramework/Actor.h"
 #include "multiBranch.generated.h"
 
 UENUM(BlueprintActor)
 enum class EMultiBranchEnum
 {
 public: 
     BranchA,
     BranchB
 };

multiBranch.h:

 #pragma once
 
 #include "GameFramework/Actor.h"
 #include "multiBranch.generated.h"
 #include "EMultiBranchEnum.h"
 
 UCLASS(meta = (BlueprintSpawnableComponent))
 class UNKNOWN_API UAmultiBranch : public UActorComponent
 {
     GENERATED_BODY()
 
 public:
     UFUNCTION(BlueprintCallable, Meta = (FriendlyName = "Multi Branch", Keywords = "Multi Branch", ExpandEnumAsExecs = "Branches", ShortTooltip = "An IF node"), Category = Game)
         bool multiBranch(bool active, TEnumAsByte<EMultiBranchEnum>& Branches);
 };
 

multiBranch.cpp:

 #include "unknown.h"
 #include "multiBranch.h"
 #include "EMultiBranchEnum.h"

 bool UAmultiBranch::multiBranch(bool active, TEnumAsByte<EMultiBranchEnum>& Branches)
 {
     if (active)
     {
         Branches = EMultiBranchEnum::BranchA;
     }
     else
     {
         Branches = EMultiBranchEnum::BranchB;
     }
     return active;
 }

I've check the placement of the files and all lies inside the Source folder. I corrected the ActorComponent to UActorComponent and AmultiBranch to UAmultiBranch. I looked in the pallet window and searched for "multi" but it only showed up with "add Multi Branch": The Pallet and I pulled out a branch wire and got the same thing. It looked like this: (view the node picture)

more ▼

answered Aug 27 '15 at 05:20 PM

Xillez gravatar image

Xillez
52 4 7 56

(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