CharacterStateMachine.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Components/InputComponent.h"
#include "CharacterStateMachine.generated.h"
UCLASS(Blueprintable)
class ODYSSEYSHOOT_API ACharacterStateMachine : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
ACharacterStateMachine();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
private:
enum GameStates
{
IDLE,
INJURED,
DEATH
};
GameStates State = GameStates::IDLE;
enum GameEvents
{
ON_ENTER,
ON_UPDATE
};
GameEvents Event = GameEvents::ON_ENTER;
void ODSUpdate()

本文档详细介绍了如何在Unreal Engine 4(UE4)中使用C++实现角色的逻辑状态机。通过CharacterStateMachine.h和CharacterStateMachine.cpp文件的代码示例,展示了如何定义和管理角色在不同游戏状态间的转换,包括移动、攻击、防御等行为。通过对状态机的设计和实现,可以更好地组织和控制角色的行为逻辑。
最低0.47元/天 解锁文章
4332

被折叠的 条评论
为什么被折叠?



