Hello! Currently, I’m trying to replace part of my player blueprints with C++ but I’m having trouble figuring out how to even set it up. For example, should I use a TArray or a UStruct, etc? Here’s a picture of my blueprints to show you what I’m trying to accomplish.
Firstly in my player.h file I tried setting up a USTRUCT
UFUNCTION()
void Block1();
UFUNCTION()
void Block2();
UFUNCTION()
void Block3();
UFUNCTION()
void Block4();
UFUNCTION()
void SetShieldLocation();
USTRUCT()
struct MyShieldQuadrants
{
UPROPERTY(EditAnywhere)
FVector BlockLocation1;
UPROPERTY(EditAnywhere)
FVector BlockLocation2;
UPROPERTY(EditAnywhere)
FVector BlockLocation3;
UPROPERTY(EditAnywhere)
FVector BlockLocation4;
UPROPERTY()
FVector ShieldLocation; //current shield location
void ShieldQuadrants()
{
ShieldLocation = (BlockLocation1, BlockLocation2, BlockLocation3, BlockLocation4);
}
//FVector Quadrants()
};
In my player.cpp I tried ( I already have block1-4 Bind Actions set up)
MyShieldQuadrants::ShieldLocation = TArray<FVector> array;
BlockLocation1 = FVector(60.0f, -25.0f, -10.0f);
BlockLocation2 = FVector(60.0f, 16.0f, -10.0f);
BlockLocation3 = FVector(60.0f, -25.0f, -80.0f);
BlockLocation4 = FVector(60.0f, 16.0f, -80.0f);
void ATerraBase::SetShieldLocation()
{
FVector NewLocation, ShieldLocation[0]
}
TArray I tried this for the player.h file
TArray<FVector> RootShields;
RootShields.Append(BlockLocation1, BlockLocation2, BlockLocation3, BlockLocation4);
I’ve been looking through posts on here and other documentation from Unreal which is how I came up with the code I did. However, what I’m doing does not seem correct and I keep getting thrown errors. How should I set up an array for this function between player.h and player.cpp files?
I also understand I can accomplish the same thing without an array for what is shown in the blueprints. However the same values are used for many different functions which is why I’m trying to set it up the same way as seen in the blueprints. Thanks for the help!