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?

Hey ,

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:

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.

Sure thing, looks great :wink: I know get what you mean!! this is great :smiley: