场景中所有可操作的物件都是基于actor,类似unity的game object.
关键方法:
GetActorLocation()
GetActorScale()
Tick做actor每帧逻辑操作
// Called every frame
void AFloatingActor::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
FVector newPos = GetActorLocation();
float delatMove = FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(DeltaTime);
newPos.Z += delatMove * 3;
SetActorLocation(newPos);
FVector newScale = GetActorScale();
newScale.Z = FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(DeltaTime);
SetActorScale3D(newScale);
RunningTime += DeltaTime;
}
FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(DeltaTime)实现了重力效果运动。