Commit 13703aff authored by Robin 's avatar Robin

Updated the decal dynamic material instance for better code flow.

Updated .gitignore to ignore vscode editor files.
parent fb1a3790
......@@ -71,4 +71,6 @@ Intermediate/*
Plugins/*/Intermediate/*
# Cache files for the editor to use
DerivedDataCache/*
\ No newline at end of file
DerivedDataCache/*
.vscode
*.code-workspace
......@@ -48,8 +48,8 @@ ADodgeSoundCharacter::ADodgeSoundCharacter()
static ConstructorHelpers::FObjectFinder<UMaterial> DecalMaterialAsset(TEXT("Material'/Game/TopDownCPP/Blueprints/M_Cursor_Decal.M_Cursor_Decal'"));
if (DecalMaterialAsset.Succeeded())
{
decalMaterial = DecalMaterialAsset.Object;
CursorToWorld->SetDecalMaterial(decalMaterial);
decalDynamicMaterial = UMaterialInstanceDynamic::Create(DecalMaterialAsset.Object, NULL);
CursorToWorld->SetDecalMaterial(decalDynamicMaterial);
}
CursorToWorld->DecalSize = FVector(16.0f, 32.0f, 32.0f);
CursorToWorld->SetRelativeRotation(FRotator(90.0f, 0.0f, 0.0f).Quaternion());
......@@ -73,22 +73,16 @@ void ADodgeSoundCharacter::Tick(float DeltaSeconds)
FRotator CursorR = CursorFV.Rotation();
CursorToWorld->SetWorldLocation(TraceHitResult.Location);
CursorToWorld->SetWorldRotation(CursorR);
UMaterialInstanceDynamic* material = UMaterialInstanceDynamic::Create(decalMaterial, CursorToWorld); //UMaterialInstanceDynamic::Create(CursorToWorld->GetMaterial(0), CursorToWorld->GetOwner());
if (TraceHitResult.GetActor()) {
/*if (tags.Num() > 0) {
UE_LOG(LogTemp, Warning, TEXT("%s"), *TraceHitResult.GetActor()->Tags[0].ToString());
}*/
if (TraceHitResult.GetActor()->ActorHasTag(FName(TEXT("Enemy")))) {
UE_LOG(LogTemp, Warning, TEXT("Hovering over an enemy."));
material->SetVectorParameterValue(TEXT("DecalColor"), FLinearColor::Red);
decalDynamicMaterial->SetVectorParameterValue(TEXT("DecalColor"), FLinearColor::Red);
}
else {
material->SetVectorParameterValue(TEXT("DecalColor"), FLinearColor::Green);
else
{
decalDynamicMaterial->SetVectorParameterValue(TEXT("DecalColor"), FLinearColor::Green);
}
CursorToWorld->SetDecalMaterial(material);
CursorToWorld->SetDecalMaterial(decalDynamicMaterial);
}
}
}
......
......@@ -37,6 +37,6 @@ private:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UDecalComponent* CursorToWorld;
UMaterial* decalMaterial;
UMaterialInstanceDynamic* decalDynamicMaterial;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment