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"

Blueprint and C++. Am I doing this right?

Hey guys, So I am part of the programming team. We are working on a game with a complex fighting system with many different spells. For sanity reasons I have written some C++ classes and exposed them to Blueprint for the artists to set up meshes, collision etc. inside the editor and NOT in C++. No additional coding was done inside Blueprints. Then after BeginPlay I want to create an instance of these spells. Can I use the C++ baseclass for that and still have the correct meshes specified by the artists? If not how do you deal with that?

Product Version: Not Selected
more ▼

asked Jul 17 '16 at 01:44 PM in C++ Programming

avatar image

10 5 8 9

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

1 answer: sort voted first

Hey DaOnlyOwner,

At least in general, it sound like you're doing it fine! The problem is that C++ doesn't really have access to the selections that your artists have made in the editor right now. Let's assume that you have a Spell struct that looks something like (my struct will be combat animation struct, but you could name it spell animation struct or whatever you like):

 struct FCombatAnimationStruct

         UPROPERTY(EditAnywhere, BlueprintReadWrite)
         UAnimMontage* Animation;

     UPROPERTY(EditAnywhere, BlueprintReadWrite)
         float DamageOnHit = 20.0f;

     UPROPERTY(EditAnywhere, BlueprintReadWrite)
         float DamagReduction = 0.0f;

     UPROPERTY(EditAnywhere, BlueprintReadWrite)
         float AnimationSpeed = 1.0f;

     UPROPERTY(EditAnywhere, BlueprintReadWrite)
         UMeshComponent* Mesh;

 class MELEEGAME_API AMGCharacter : public ACharacter

     // Sets default values for this character's properties

     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     // Called every frame
     virtual void Tick( float DeltaSeconds ) override;

     // Called to bind functionality to input
     virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

     UPROPERTY(EditAnywhere, BlueprintReadWrite)
         FCombatAnimationStruct PrimaryAttack;

     UPROPERTY(EditAnywhere, BlueprintReadWrite)
         FCombatAnimationStruct SecondaryAttack;

     UPROPERTY(EditAnywhere, BlueprintReadWrite)
         TArray<FCombatAnimationStruct> AvailableAttacks;

     UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
         FCombatAnimationStruct PlayingAnimation;


Now if I open up a blueprint that extends the MGCharacter, the artists will be able to set particular values:

alt text

Now since this isn't actually a reference to an actor but instead to arbitrary struct, I won't be able to instantiate it. But if you have a reference to an actor it will work the same way. Make sure the actor has uproperties with the EditAnywhere or EditDefaultsOnly flag. At BeginPlay you will be able to spawn that referenced actors wherever you like. I would use the BeginPlay in the character class that the spells are associated with.

more ▼

answered Jul 17 '16 at 06:13 PM

avatar image

447 36 39 67

avatar image DaOnlyOwner Jul 17 '16 at 08:43 PM

Sure thing, looks great ;) I know get what you mean!! this is great :D

(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