UE4小游戏3
更改下错误: 上次在创建Collectables实列的时候用的是继承于C++Collectables类的蓝图类,可以直接用C++类。
今天控制主角吃豆子
MyPacManCharacter.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "..\MyPacManCopyGameModeBase.h"
#include "MyPacManCharacter.generated.h"
UCLASS()
class MYPACMANCOPY_API AMyPacManCharacter : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
AMyPacManCharacter();
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;
//创建StaticMesh
/*UPROPERTY()
UStaticMeshComponent* MyPacMan;*/
int Lives;
int CollectableToEat; //可被吃的豆子数目
void MoveXAxis(float AxisValue);
void MoveYAxis(float AxisValue);
//设置碰撞函数
UFUNCTION()
void OnCollision(class UPrimitiveComponent* HitComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int OtherBod