I have followed this tutorial: Programming Quick Start | Unreal Engine Documentation
However, when I play my scene, the cone seems to get stuck below the floor of the default scene with the 2 chairs, and I initially set it above the table.
The code is exactly the same as what is on the tutorial. It could be some property on the cone or actor instance.
void AFloatingActor::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
FVector newLocation = GetActorLocation();
float DeltaHeight = (FMath::Sin(runningTime + DeltaTime) - FMath::Sin(runningTime));
newLocation.Z = DeltaHeight * 20.0f;
runningTime += DeltaTime;
SetActorLocation(newLocation);
}
and in the header file:
class CODEINTRO_API AFloatingActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AFloatingActor();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
float runningTime;
};
I didn’t touch the beginPlay and other auto functions in the class. I have attached a picture of the floatingActor in the level editor.