UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a ghost"
// Create a ghost AGhost::AGhost() { PrimaryActorTick.bCanEverTick = true; MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh Component")); RootComponent = MeshComponent; GhostMaterial = CreateDefaultSubobject<UMaterial>(TEXT("Ghost Material")); GhostMaterial->SetVectorParameterValue(TEXT("Color"), FLinearColor(0.0f, 0.0f, 0.0f, 0.5f)); MeshComponent->SetMaterial(0, GhostMaterial); } void AGhost::Tick(float DeltaTime) { Super::Tick(DeltaTime); // Fade the ghost in and out float Alpha = FMath::Abs(FMath::Sin(RunningTime)); GhostMaterial->SetVectorParameterValue(TEXT("Color"), FLinearColor(1.0f, 1.0f, 1.0f, Alpha)); RunningTime += DeltaTime; }