Unreal Engine4 學習筆記1 狀態機 動畫藍圖


1.動畫藍圖 包含 狀態機 包含 混合空間BlendSpace,即狀態機包含在動畫藍圖的"動畫圖表中",而混合空間可用於在狀態機中向某(沒)一個狀態輸出最終POSE:

  

動畫藍圖一共包含兩個東西,除了上面提到的動畫圖表,還包括了一個事件圖表。動畫圖表中,狀態機內肯定有一些變量來決定狀態的轉換,比如"isInAir","speed"等。而這些都可以在"事件圖表"中得到並設置:

動畫又是怎么和我們控制的角色關聯起來的呢?

第一種方式是通過Character藍圖,然后如圖有相關選項進行關聯,下圖的例子關聯了動畫和Mesh

 

 

2.新建的c++項目,是不包含Character類的, 但包含一個parent class 為 GameMode的類

關於出生點,最好是在GameMode類的基礎上新建一個GameMode藍圖,然后在藍圖中設置Default Pawn Class:

然后還要在設置->世界設置中進行設置:

 

關於輸入,這樣的代碼出現在Character類中:

void ABatteryCollectorCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
    // Set up gameplay key bindings
    check(InputComponent);
    InputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
    InputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
    InputComponent->BindAction("Collect", IE_Pressed, this, &ABatteryCollectorCharacter::CollectPickups);

    InputComponent->BindAxis("MoveForward", this, &ABatteryCollectorCharacter::MoveForward);
    InputComponent->BindAxis("MoveRight", this, &ABatteryCollectorCharacter::MoveRight);

    // We have 2 versions of the rotation bindings to handle different kinds of devices differently
    // "turn" handles devices that provide an absolute delta, such as a mouse.
    // "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
    InputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
    InputComponent->BindAxis("TurnRate", this, &ABatteryCollectorCharacter::TurnAtRate);
    InputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
    InputComponent->BindAxis("LookUpRate", this, &ABatteryCollectorCharacter::LookUpAtRate);

    // handle touch devices
    InputComponent->BindTouch(IE_Pressed, this, &ABatteryCollectorCharacter::TouchStarted);
    InputComponent->BindTouch(IE_Released, this, &ABatteryCollectorCharacter::TouchStopped);
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM