ユーザ用ツール

サイト用ツール

wiki:ue4:tips:500

以前のリビジョンの文書です


C++/Actorクラスの作成

  1. 「コンテンツブラウザ」の「新規追加」から「新規C++ Class…」を選択。
  2. 親クラスに「Actor」を選択して次へ。
  3. 名前を「MyActor」として「クラスを作成」する。

コードの記述とコンパイル

  1. 自動でVisualStudioが開くので、MyActor.h/cppを編集する。
// MyActor.h
class STDPROJECT_API AMyActor : public AActor
{
    GENERATED_BODY()
private:
    // 追加
    float m_fRunningTime;
}
// MyActor.cpp
 
// 生成された時に一度だけ呼ばれる。
void AMyActor::BeginPlay()
{
    Super::BeginPlay();
 
}
 
// 毎フレーム呼ばれる。
void AMyActor::Tick( float DeltaTime )
{
    Super::Tick( DeltaTime );
 
    FVector NewLocation = GetActorLocation();
    float DeltaHeight = (FMath::Sin(m_fRunningTime + DeltaTime) - FMath::Sin(m_fRunningTime));
    NewLocation.Z += DeltaHeight * 20.0f;
    m_fRunningTime += DeltaTime;
    SetActorLocation(NewLocation);
}
Permalink wiki/ue4/tips/500.1427520047.txt.gz · 最終更新: 2015/03/28 05:20 by step

oeffentlich