UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a sword"
// Create a Sword void AWeapon::CreateSword() { // Create a static mesh component for the sword SwordMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Sword Mesh")); SwordMesh->SetupAttachment(RootComponent); // Set the sword mesh static ConstructorHelpers::FObjectFinder<UStaticMesh> SwordAsset(TEXT("/Game/Meshes/Sword.Sword")); if (SwordAsset.Succeeded()) { SwordMesh->SetStaticMesh(SwordAsset.Object); } // Set the sword material static ConstructorHelpers::FObjectFinder<UMaterialInterface> SwordMaterial(TEXT("/Game/Materials/Sword.Sword")); if (SwordMaterial.Succeeded()) { SwordMesh->SetMaterial(0, SwordMaterial.Object); } }