I’m trying to change the color of a projectile that I’m spawning in C++ code. I have a projectile color property on the projectile class and I’m applying this color to a dynamic material instance which I’m creating inside the constructor. Is it possible to set a value to this property at the time the projectile is spawned in C++?
MyProjectile.h
// Projectile color
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Projectile")
FLinearColor* ProjectileColor;
This is on the character class:
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = this;
AMyProjectile* const Projectile = GetWorld()->SpawnActor<AMyProjectile>(MyProjectileClass, SpawnLocation, SpawnRotation, SpawnParams);
Perhaps there’s a better way of doing this, but I’m not sure how to set the value of the projectile color property so that the MyProjectile constructor can apply it to the dynamic material instance.
Thanks.