Implémente une caméra orthographique pour une vue 2D. Ajuste le mouvement du joueur pour qu'il soit contraint par les limites du niveau. Remplace l'ancienne caméra dans le PlayerPawn par une nouvelle dans le PlayerController.
33 lines
721 B
C++
33 lines
721 B
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/Pawn.h"
|
|
#include "InputAction.h"
|
|
#include "M4_PlayerPawn.generated.h"
|
|
|
|
class UCameraComponent;
|
|
|
|
UCLASS()
|
|
class AM4_PlayerPawn : public APawn
|
|
{
|
|
GENERATED_BODY()
|
|
public:
|
|
AM4_PlayerPawn();
|
|
|
|
virtual void BeginPlay() override;
|
|
virtual void Tick(float DeltaTime) override;
|
|
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
|
|
void Move(const FInputActionInstance& Instance);
|
|
|
|
protected:
|
|
|
|
UPROPERTY(VisibleAnywhere)
|
|
UStaticMeshComponent* MeshComponent;
|
|
|
|
UPROPERTY()
|
|
UInputAction* MoveAction;
|
|
|
|
float MoveSpeed = 500.f;
|
|
FVector2D MeshScale = FVector2D(0.6f, 0.5f);
|
|
FVector2D LastMoveValue = FVector2D::ZeroVector;
|
|
}; |