UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"boat bouncing in water"
ABoat::ABoat() { PrimaryActorTick.bCanEverTick = true; StaticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Static Mesh Component")); RootComponent = StaticMeshComponent; SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm")); SpringArm->SetupAttachment(RootComponent); Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera")); Camera->SetupAttachment(SpringArm); } void ABoat::Tick(float DeltaTime) { Super::Tick(DeltaTime); FVector Location = GetActorLocation(); float DeltaHeight = (FMath::Sin(RunningTime DeltaTime) - FMath::Sin(RunningTime)); Location.Z = DeltaHeight * 20.0f; RunningTime = DeltaTime; SetActorLocation(Location); }