Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "WaterAnimation.h"
- #include <cmath>
- // Sets default values
- AWaterAnimation::AWaterAnimation()
- {
- UE_LOG(LogTemp, Warning, TEXT("Constructor"));
- // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
- PrimaryActorTick.bCanEverTick = true;
- ConstructorHelpers::FObjectFinder<UStaticMesh> ModelPath1(TEXT("StaticMesh'/Game/Objects/Dam/Water/Mesh/fluid_animation_open_000580.fluid_animation_open_000580'"));
- frame1 = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("waterFrame1"));
- frame1->SetStaticMesh(ModelPath1.Object);
- frame1->SetCollisionEnabled(ECollisionEnabled::NoCollision);
- frame1->AttachTo(RootComponent);
- ConstructorHelpers::FObjectFinder<UStaticMesh> ModelPath2(TEXT("StaticMesh'/Game/Objects/Dam/Water/Mesh/fluid_animation_open_000500.fluid_animation_open_000500'"));
- frame2 = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("waterFrame2"));
- frame2->SetStaticMesh(ModelPath2.Object);
- frame2->SetCollisionEnabled(ECollisionEnabled::NoCollision);
- frame2->AttachTo(RootComponent);
- }
- // Called when the game starts or when spawned
- void AWaterAnimation::BeginPlay()
- {
- UE_LOG(LogTemp, Warning, TEXT("Begin Play"));
- Super::BeginPlay();
- }
- // Called every frame
- void AWaterAnimation::Tick(float DeltaTime)
- {
- UE_LOG(LogTemp, Warning, TEXT("Tick"));
- Super::Tick(DeltaTime);
- currentTime += DeltaTime;
- float elapsedTime = currentTime - startingTime;
- if ((((int)floor(elapsedTime)) % 2) == 0) {
- frame2->SetVisibility(true);
- frame1->SetVisibility(false);
- }
- else {
- frame1->SetVisibility(true);
- frame2->SetVisibility(false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement