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"

Selecting Existing uStructs from dropdown

So im working on a spaceship game and I have a list of CrewPositions (pilot, gunner, systems operator, mechanic, ect) and a list of crew members. Both are custom UStructs with unique data. One variable in CrewPositions is AssignedCrewMember, I would like to have that be a dropdown in blueprints of only the CrewMembers variables which is a TArray that can add or subtract from.

 UENUM(BlueprintType)
 enum class ECrewPosition : uint8
 {
     Pilot         UMETA(DisplayName = "Pilot"),
     CoPilot UMETA(DisplayName = "Co-Pilot"),
     Gunner UMETA(DisplayName = "Gunner"),
     Commander UMETA(DisplayName = "Commander"),
     SystemsOperator UMETA(DisplayName = "Systems Operator"),
     Engineer UMETA(DisplayName = "Engineer"),
     Passenger UMETA(DisplayName = "Passenger")
 
 };

 USTRUCT()
 struct FCrewMember
 {
     GENERATED_BODY()
         
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
     FString CrewName;
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
     int32 CrewLevel;
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
     int32 CrewBaseAttackBonus;
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
     int32 CrewSkillInitiative;
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
     int32 CrewSkillMechanics;
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
     int32 CrewSkillPerception;
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
     int32 CrewSkillPilot;
 
 };
 
 
 USTRUCT()
 struct FCrewPosition
 {
     GENERATED_BODY()
 
         UPROPERTY(BlueprintReadWrite, EditAnywhere)
         FString PositionName;
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
         TArray<ECrewPosition> Positions;
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
         TArray<int32> ControlledWeaponSlots;
 
 //Here I want to be able to select from the Crew variables that are created in AStarship
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
         FCrewMember AssignedCrewMember;
 
 
 };
 
 UCLASS()
 class POCKETSTARSHIP_API AStarship : public AActor
 {
     GENERATED_BODY()
     
 public:
 
 //A bunch of completely unrelated variables go here but took out for readability
     
     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
         TArray<FCrewMember> Crew;
     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
         TArray<FCrewPosition> CrewPositions;
 
 //A bunch of functions go here but are unrelated so took out for readability
     
 };
Product Version: UE 4.14
Tags:
more ▼

asked Jan 18 '17 at 01:18 PM in C++ Programming

avatar image

Ostoril
16 1 2 3

avatar image Spiris Jan 19 '17 at 08:02 AM

I mulled this one over for a bit but was unable to find a direct solution to your problem.
UE4 has a problem with trying to jam derived structs into a parent array, or struct slot in edit variables, if you are looking for true polymorphism you may want to go the class route, which means uobject derived classes for blueprints, but is still doable and may be the way to go if you want to be able to do game code alongside your crew data. Getting the dropdown to derived classes at that point should be a matter of using TSubclassOf.

This still doesnt really answer your question though. You could try assigning things inside of a construction script that runs after the initial assignment. If I am ever doing something similar I tend to lean toward the usage of TMap and registering at runtime based on simple sign up or if I am feeling really ambitious, qualifications.

I also suppose you could reorganize your structs to use pointers to the data that you want them to point to, but even then you are going to have trouble pointing to things outside of runtime. This is generally what blueprint graphs, as opposed to defaults, tend to be used for, so don't be afraid to assign these things in there if you so desire.

I hope I at least offered some avenue of thought to look down, Good luck!

-Spiris

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

0 answers: sort voted first
Be the first one to answer this question
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