错误列表:
MSB3075 命令“G:\UnrealEngine\UE_4.18\Engine\Build\BatchFiles\Build.bat C_FPSEditor Win64 Development “G:\UE4_project\C_Project\C_FPS\C_FPS.uproject” -waitmutex”已退出,代码为 5。请验证您是否拥有运行此命令的足够权限。 C_FPS C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets 44
1.emphasized text **.hemphasized text:
#UnrealHeaderTool
#pragma once
#include “CoreMinimal.h”
#include “GameFramework/Character.h”
#include “MyCharacter.generated.h”
UCLASS()
class C_FPS_API AMyCharacter : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character’s properties
AMyCharacter();
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;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite) //定义弹簧
class USpringArmComponent * springArn;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly) //定义摄像机
class UCameraComponent * qshCamera;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite) //定义摄像机
class USkeletalMeshComponent * qshWeapon;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly) //定义一个bool变量,是否进入瞄准姿态;
bool isHip;
UPROPERTY(VisibleAnywhere, BlueprintReadwrite) //定义一个bool变量,是否进入瞄准姿态;
bool isIdle = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class UAnimMontage * fireMontage;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class USoundBase * fireSound;
void MyMoveForward(float value);
void MyMoveRight(float value);
void MyJumpStart();
void CrouchDown();
void CrouchUp();
void IronsightUP();
void IronsightDown();
void fire();
};
emphasized textcpp:
#Unreal cpp;
#include “MyCharacter.h”
#include “GameFramework/SpringArmComponent.h”
#include “Camera/CameraComponent.h”
#include “Kismet/KismetMathLibrary.h”
#include “GameFramework/CharacterMovementComponent.h”
#include “Components/SkeletalMeshComponent.h”
#include “Engine/Engine.h”
#include “Sound/SoundBase.h”
#include “Animation/AnimMontage.h”
#include “Kismet/GameplayStatics.h”
// Sets default values
AMyCharacter::AMyCharacter()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;
this->bUseControllerRotationYaw = false;
springArn=CreateDefaultSubobject<USpringArmComponent>(TEXT("springArn"));
springArn->bUsePawnControlRotation = true;
qshCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("qshCamera"));
qshCamera->SetupAttachment(springArn);
GetCharacterMovement()->bOrientRotationToMovement = true;
GetCharacterMovement()->RotationRate = FRotator(0.f, 540.f, 0.f);
qshWeapon = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("qshweapon"));
qshWeapon->SetupAttachment(GetMesh(),TEXT("weapon"));
}
// Called when the game starts or when spawned
void AMyCharacter::BeginPlay()
{
Super::BeginPlay();
isIdle = true;
}
// Called every frame
void AMyCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis(TEXT("MoveForward"),this,&AMyCharacter::MyMoveForward); //将Moverforward绑定
PlayerInputComponent->BindAxis(TEXT("MoveRight"),this,&AMyCharacter::MyMoveRight); //将Moverforward绑定
PlayerInputComponent->BindAxis(TEXT("Turn"),this,&AMyCharacter::AddControllerYawInput); //将Turn的值直接传输到AddControllerYawInput
PlayerInputComponent->BindAxis(TEXT("Lookat"),this,&AMyCharacter::AddControllerPitchInput); //将Lookat的值直接传输到AddControllerRollInput
PlayerInputComponent->BindAction(TEXT("Jump"),IE_Pressed,this,&AMyCharacter::MyJumpStart); //按下空格调用Myjumpstart函数执行Jump;
PlayerInputComponent->BindAction(TEXT("Crouch"),IE_Pressed,this,&AMyCharacter::CrouchDown); //按下空格调用Myjumpstart函数执行Jump;
PlayerInputComponent->BindAction(TEXT("Crouch"),IE_Released,this,&AMyCharacter::CrouchUp); //按下空格调用Myjumpstart函数执行Jump;
PlayerInputComponent->BindAction(TEXT("IronSight"),IE_Pressed,this,&AMyCharacter::IronsightUP); //按下空格调用Myjumpstart函数执行Jump;
PlayerInputComponent->BindAction(TEXT("IronSight"),IE_Released,this,&AMyCharacter::IronsightDown); //按下空格调用Myjumpstart函数执行Jump;
PlayerInputComponent->BindAction(TEXT("Fire"),IE_Pressed,this,&AMyCharacter::fire); //按下空格调用Myjumpstart函数执行Jump;
}
void AMyCharacter::MyMoveForward(float value)
{
AddMovementInput(UKismetMathLibrary::GetForwardVector(GetControlRotation()), value);
}
void AMyCharacter::MyMoveRight(float value)
{
AddMovementInput(UKismetMathLibrary::GetRightVector(GetControlRotation()), value);
}
void AMyCharacter::MyJumpStart()
{
Jump();
}
void AMyCharacter::CrouchDown()
{
Crouch();
isIdle = false;
}
void AMyCharacter::CrouchUp()
{
UnCrouch();
isIdle = true;
}
void AMyCharacter::IronsightUP()
{
isHip = true;
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Black, TEXT("1232"));
GetCharacterMovement()->MaxWalkSpeed = 270;
}
void AMyCharacter::IronsightDown()
{
isHip = false;
GetCharacterMovement()->MaxWalkSpeed = 600;
}
void AMyCharacter::fire()
{
if (isHip)
{
PlayAnimMontage(fireMontage);
UGameplayStatics::PlaySoundAtLocation(this, fireSound, GetActorLocation());
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Black, TEXT(“shide”));
}
}