hi i am new to ue4 , i tried to implement movement to my character and this is my code:
mycharater.h
#pragma once
#include “CoreMinimal.h”
#include “GameFramework/Character.h”
#include “MyCharacterarrow.generated.h”
class USpringArmComponent;
class UCameracomponent;
class UStaticMeshComponent;
UCLASS()
class ARROW1_0_API AMyCharacterarrow : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character’s properties
AMyCharacterarrow();
UPROPERTY(VisibleAnywhere, BlueprintReadOnly,Category = “Camera”)
USpringArmComponent* SpringArmComp;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
UCameraComponent* CameraComp;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Player")
UStaticMeshComponent* MeshComp;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
void MoveFoward(float Value);
void MoveRight(float Value);
void TurnAtRate(float Value);
void LookUpAtRate(float Value);
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
float BaseTurnRate;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
float BaseLookUpAtRate;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
};
mycharacter.cpp
#include “MyCharacterarrow.h”
#include"GameFramework/SpringArmComponent.h"
#include"Camera/CameraComponent.h"
#include"Components/StaticMeshComponent.h"
#include"Components/InputComponent.h"
#include"GameFramework/Controller.h"
// Sets default values
AMyCharacterarrow::AMyCharacterarrow()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = false;
SpringArmComp = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArmCom"));
SpringArmComp->SetupAttachment(RootComponent);
CameraComp = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComp"));
CameraComp->SetupAttachment(SpringArmComp);
MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PlayerMesh"));
MeshComp->SetupAttachment(RootComponent);
BaseTurnRate = 45.0f;
BaseLookUpAtRate = 45.0f;
}
void AMyCharacterarrow::MoveFoward(float Value)
{
if ((Controller) && (Value != 0.0f))
{
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
}
void AMyCharacterarrow::MoveRight(float Value)
{
if ((Controller) && (Value != 0.0f))
{
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
AddMovementInput(Direction, Value);
}
}
void AMyCharacterarrow::TurnAtRate(float Value)
{
AddControllerYawInput(Value * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}
void AMyCharacterarrow::LookUpAtRate(float Value)
{
AddControllerPitchInput(Value * BaseLookUpAtRate * GetWorld()->GetDeltaSeconds());
}
// Called every frame
void AMyCharacterarrow::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AMyCharacterarrow::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAction(“Jump”, IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction(“Jump”, IE_Released, this, &ACharacter::StopJumping);
PlayerInputComponent->BindAxis("MoveFoward", this, &AMyCharacterarrow::MoveFoward);
PlayerInputComponent->BindAxis("MoveRight", this, &AMyCharacterarrow::MoveRight);
PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
PlayerInputComponent->BindAxis("TurnRate", this, &AMyCharacterarrow::TurnAtRate);
PlayerInputComponent->BindAxis("LookUpRate", this, &AMyCharacterarrow::LookUpAtRate);
}
when i compile in ue4 appear this list of error