Skip to content
This repository was archived by the owner on Jun 19, 2020. It is now read-only.

Commit 1b07501

Browse files
author
Chris Conway
committed
Quick update to examples to make animated plane a little simpler.
1 parent 543f3cd commit 1b07501

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

Content/Maps/RMC_Examples_Map.umap

-472 Bytes
Binary file not shown.

Source/RMC_Examples/Actors/AnimatedTerrain.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,21 @@ void AAnimatedTerrain::Tick( float DeltaTime )
5757
Generate();
5858
}
5959

60-
float ScaleFactor = 1.0f;
61-
float AnimationSpeedX = 4.0f;
62-
float AnimationSpeedY = 4.5f;
60+
float AnimationStepX = 5;
61+
float AnimationStepY = 6;
6362

64-
CurrentAnimationFrameX += DeltaTime * AnimationSpeedX;
65-
CurrentAnimationFrameY += DeltaTime * AnimationSpeedY;
63+
AnimationOffsetX += DeltaTime * AnimationStepX;
64+
AnimationOffsetY += DeltaTime * AnimationStepY;
6665

6766

6867
int32 Index = 0;
6968
for (int32 YIndex = -HalfWidth; YIndex < HalfWidth; YIndex++)
7069
{
7170
for (int32 XIndex = -HalfWidth; XIndex < HalfWidth; XIndex++)
7271
{
73-
float ValueOne = FMath::Cos((XIndex + CurrentAnimationFrameX)*ScaleFactor) + FMath::Sin((YIndex + CurrentAnimationFrameY)*ScaleFactor);
74-
float ValueTwo = FMath::Cos((XIndex + CurrentAnimationFrameX*0.7f)*ScaleFactor*2.5f) + FMath::Sin((YIndex - CurrentAnimationFrameY*0.7f)*ScaleFactor*2.5f);
72+
float Scale = FMath::Cos(XIndex + AnimationOffsetX) + FMath::Sin(YIndex + AnimationOffsetY);
7573

76-
77-
Positions[Index++].Z = ((ValueOne + ValueTwo) / 2) * Height;
74+
Positions[Index++].Z = Scale * Height;
7875
}
7976
}
8077

Source/RMC_Examples/Actors/AnimatedTerrain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class RMC_EXAMPLES_API AAnimatedTerrain : public ARuntimeMeshObjectBase
3030

3131
void Generate();
3232

33-
float CurrentAnimationFrameX = 0.0f;
34-
float CurrentAnimationFrameY = 0.0f;
33+
float AnimationOffsetX = 0.0f;
34+
float AnimationOffsetY = 0.0f;
3535

3636
int32 HalfWidth = 20;
3737

0 commit comments

Comments
 (0)