195 - Post Edit Change Property

This commit is contained in:
Kingsmedia 2022-05-27 22:52:03 +02:00
parent fec03cfb8e
commit b3f783a453
6 changed files with 43 additions and 0 deletions

View File

@ -16,6 +16,23 @@ AProjectileBullet::AProjectileBullet()
ProjectileMovementComponent->MaxSpeed = InitialSpeed;
}
#if WITH_EDITOR
void AProjectileBullet::PostEditChangeProperty(FPropertyChangedEvent& Event)
{
Super::PostEditChangeProperty(Event);
const FName PropertyName = Event.Property != nullptr ? Event.Property->GetFName() : NAME_None;
if (PropertyName == GET_MEMBER_NAME_CHECKED(AProjectileBullet, InitialSpeed))
{
if (ProjectileMovementComponent)
{
ProjectileMovementComponent->InitialSpeed = InitialSpeed;
ProjectileMovementComponent->MaxSpeed = InitialSpeed;
}
}
}
#endif
void AProjectileBullet::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
ACharacter* OwnerCharacter = Cast<ACharacter>(GetOwner());

View File

@ -17,6 +17,10 @@ class BLASTER_API AProjectileBullet : public AProjectile
public:
AProjectileBullet();
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& Event) override;
#endif
protected:

View File

@ -25,6 +25,23 @@ void AProjectileRocket::Destroyed()
{
}
#if WITH_EDITOR
void AProjectileRocket::PostEditChangeProperty(FPropertyChangedEvent& Event)
{
Super::PostEditChangeProperty(Event);
const FName PropertyName = Event.Property != nullptr ? Event.Property->GetFName() : NAME_None;
if (PropertyName == GET_MEMBER_NAME_CHECKED(AProjectileRocket, InitialSpeed))
{
if (RocketMovementComponent)
{
RocketMovementComponent->InitialSpeed = InitialSpeed;
RocketMovementComponent->MaxSpeed = InitialSpeed;
}
}
}
#endif
void AProjectileRocket::BeginPlay()
{
Super::BeginPlay();

View File

@ -16,6 +16,11 @@ class BLASTER_API AProjectileRocket : public AProjectile
public:
AProjectileRocket();
virtual void Destroyed() override;
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& Event) override;
#endif
protected:
virtual void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) override;