相比较UE4自带的SpringArm中的碰撞,主要特点在于前后推进速度不一样
在碰撞时 向前推进的速度较快,在离开碰撞时 向后退的速度较慢
SpringArm自带的碰撞检测
SpringArm的碰撞检测,在墙角的位置,由于频繁的碰撞和离开,导致来回的闪动
我的碰撞检测组件
推进,后退 使用不同的差值速度,避免相机频繁推拉,视觉感受上更舒适
C++ 代码部分h// TAZORN.COM 2017 ALL RIGHTS RESERVED
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "CameraCollisionComponentBase.generated.h"
/*
相机碰撞组件,可以被Bp继承,继续修改或复写
*/
UCLASS(Blueprintable, BlueprintType, ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class XLABORATORY_API UCameraCollisionComponentBase : public UActorComponent
{
GENERATED_BODY()public:
UCameraCollisionComponentBase();
// SpringArm组件的引用
USpringArmComponent* SpringComponent;
float DesiredDistance;
float CamSpringCurrLength;
float HitLength;
float CameraLerpSpeed;
float Delta;
virtual void BeginPlay() override;
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
U