利用第三方后期处理材质(PostProcess Material)对物体进行描边【UE4】【C++】
完整代码如下: MyPlayer.h
[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include \ #include \
UCLASS()
class OUTLINECPLUSPLUS_API AMyPlayer : public ACharacter {
GENERATED_BODY()
public:
// Sets default values for this character's properties AMyPlayer();
void MoveForward(float val); void MoveRight(float val); void LookYaw(float val);
void LookPitch(float val); void Use();
class AInteractableActor* FindFocusedActor(); void HandleHighlight();
// Called when the game starts or when spawned virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
private:
UPROPERTY(EditDefaultsOnly)
float InteractionDistance = 300.f; // 交互的范围 class AInteractableActor* FocusedActor; // 用于 LineTraceSingleByChannel FCollisionQueryParams TraceParams; };
MyPlayer.cpp
[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
// Fill out your copyright notice in the Description page of Project Settings. #include \ #include \
// Sets default values
AMyPlayer::AMyPlayer() {
// Set this character to call Tick() every frame. You can turn this off to improve performance if you dwww.sm136.comon't need it.
PrimaryActorTick.bCanEverTick = true;
TraceParams = FCollisionQueryParams(FName(TEXT(\ TraceParams.bTraceComplex = false; TraceParams.bTraceAsyncScene = false;
TraceParams.bReturnPhysicalMaterial = false; }
// Called when the game starts or when spawned
void AMyPlayer::BeginPlay() {
Super::BeginPlay(); }
// Called every frame
void AMyPlayer::Tick( float DeltaTime ) {
Super::Tick( DeltaTime );
if (Controller && Controller->IsLocalController()) {
HandleHighlight(); } }
// Called to bind functionality to input
void AMyPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) {
Super::SetupPlayerInputComponent(PlayerInputComponent);
InputComponent->BindAxis(\ InputComponent->BindAxis(\ InputComponent->BindAxis(\ InputComponent->BindAxis(\ InputComponent->BindAction(\ }
// 前后移动
void AMyPlayer::MoveForward(float val) {
FRotator Rotation(0, GetActorRotation().Yaw, 0); // Roll, Yaw, Pitch FVector forward = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X); AddMovementInput(forward, val); }
// 左右移动
void AMyPlayer::MoveRight(float val) {
FRotator Rotation(0, GetActorRotation().Yaw, 0); // Roll, Yaw, Pitch FVector right = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y); AddMovementInput(right, val);