以前のリビジョンの文書です
// MyActorComponent.h class STDPROJECT_API UMyActorComponent : public UActorComponent { GENERATED_BODY() private: // 追加 float m_fRunningTime; }
// 開始時に呼ばれる void UMyActorComponent::InitializeComponent() { Super::InitializeComponent(); } // 毎フレーム呼ばれる void UMyActorComponent::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) { Super::TickComponent( DeltaTime, TickType, ThisTickFunction ); // 追加 AActor* pOwner = GetOwner(); FVector NewLocation = pOwner->GetActorLocation(); float DeltaHeight = (FMath::Cos(m_fRunningTime + DeltaTime) - FMath::Cos(m_fRunningTime)); NewLocation.X += DeltaHeight * 20.0f; m_fRunningTime += DeltaTime; pOwner->SetActorLocation(NewLocation); }