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; 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) void AProjectileBullet::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{ {
ACharacter* OwnerCharacter = Cast<ACharacter>(GetOwner()); ACharacter* OwnerCharacter = Cast<ACharacter>(GetOwner());

View File

@ -18,6 +18,10 @@ public:
AProjectileBullet(); AProjectileBullet();
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& Event) override;
#endif
protected: protected:
virtual void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) override; virtual void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) override;

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() void AProjectileRocket::BeginPlay()
{ {
Super::BeginPlay(); Super::BeginPlay();

View File

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