UCLASS() class CLIMBINGSYSTEM_API UClimbingPawnMovementComponent : public UCharacterMovementComponent { GENERATED_UCLASS_BODY() public: UFUNCTION(BlueprintCallable, Category = "ClimbingMovement") void SetClimbMode(EClimbingMode _ClimbingMode); UFUNCTION(BlueprintPure, Category = "ClimbingMovement") EClimbingMode GetClimbingMode() const; UFUNCTION(BlueprintPure, Category = "ClimbingMovement") bool CanSetClimbMode(EClimbingMode ClimbingMode); /*Offset from top of climbing surfase*/ UPROPERTY(Category = "ClimbingMovement|Climb", EditAnywhere, BlueprintReadWrite) int32 ClimbDeltaZ; /*Velocyty of climb movement*/ UPROPERTY(Category = "ClimbingMovement|Climb", EditAnywhere, BlueprintReadWrite) float ClimbVelocyty; /*Velocyty of jump from climb state*/ UPROPERTY(Category = "ClimbingMovement|Climb", EditAnywhere, BlueprintReadWrite) float ClimbJumpVelocyty; /*Angle from center when state can change in degres*/ UPROPERTY(Category = "ClimbingMovement|WallRun", EditAnywhere, BlueprintReadWrite) float WallRunLimitAngle; /*Offset from Wall when Wall Run*/ UPROPERTY(Category = "ClimbingMovement|WallRun", EditAnywhere, BlueprintReadWrite) int32 WallOffset; /*Fall Gravity Scale when charecter run on wall*/ UPROPERTY(Category = "ClimbingMovement|WallRun", EditAnywhere, BlueprintReadWrite) float WallRunFallGravityScale; /*Multiplier input vector when charecter run on wall*/ UPROPERTY(Category = "ClimbingMovement|WallRun", EditAnywhere, BlueprintReadWrite) int32 WallRunInputVelocyty; /*Velocyty of jump near wall*/ UPROPERTY(Category = "ClimbingMovement|WallRun", EditAnywhere, BlueprintReadWrite) float WallRunJumpZVelocyty; /*Velocyty of jump from wall run state*/ UPROPERTY(Category = "ClimbingMovement|WallRun", EditAnywhere, BlueprintReadWrite) float WallRunJumpVelocyty; /*Offset from rope of zip line*/ UPROPERTY(Category = "ClimbingMovement|ZipLine", EditAnywhere, BlueprintReadWrite) int32 ZipLineDeltaZ; /*Velocyty*/ UPROPERTY(Category = "ClimbingMovement|ZipLine", EditAnywhere, BlueprintReadWrite) float ZipLineVelocyty; /*Velocyty of jump from Zip Line state*/ UPROPERTY(Category = "ClimbingMovement|ZipLine", EditAnywhere, BlueprintReadWrite) float ZipLineJumpVelocyty; /*Angle of surfase when character slide*/ UPROPERTY(Category = "ClimbingMovement|InclinedSlide", EditAnywhere, BlueprintReadWrite) float InclinedSlideAngle; UPROPERTY(Category = "ClimbingMovement|InclinedSlide", EditAnywhere, BlueprintReadWrite) float InclinedSlideVelosytyForward; UPROPERTY(Category = "ClimbingMovement|InclinedSlide", EditAnywhere, BlueprintReadWrite) float InclinedSlideVelosytyRight; UPROPERTY(Category = "ClimbingMovement|InclinedSlide", EditAnywhere, BlueprintReadWrite) float InclinedJumpVelocyty; /*Velocyty of Run movement*/ UPROPERTY(Category = "ClimbingMovement", EditAnywhere, BlueprintReadWrite) float RunSpeed; /*delay before Run movement in sec*/ UPROPERTY(Category = "ClimbingMovement", EditAnywhere, BlueprintReadWrite) float RunDelay; /*Velocyty of jump near wall*/ UPROPERTY(Category = "ClimbingMovement", EditAnywhere, BlueprintReadWrite) float UnderWallJumpZVelocyty; UPROPERTY(Category = "ClimbingMovement", EditAnywhere, BlueprintReadWrite) FRuntimeFloatCurve SlideVelocytyCurve; /*UCharacterMovementComponent Interfase*/ virtual bool DoJump(bool bReplayingMoves) override; virtual float GetMaxSpeed() const override; virtual void BeginPlay() override; virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; private: EClimbingMode ClimbingMode; EClimbingMode LastClimbingMode; bool BlockClimb; bool BlockWallRun; bool BlockInclinedSlide; FTimerHandle RunTimerHandle; bool bIsRun; float MinSlideTime; float MaxSlideTime; FTimerHandle InclinedSlideTimerHandle; void SetRun(); void DefineClimbMode(); bool SetMode(EClimbingMode ClimbingMode); void UnSetMode(EClimbingMode ClimbingMode); void UnBlockInclinedSlide(); void UnblockClimbState(); void UnblockWallRunState(); bool CheckDeltaVectorInCurrentState(const FVector& InputDeltaVector, FVector& CheckDeltaVector, FRotator& CheckRotation); //Check climb is possibly from Approximate coordinate and return realy coordinate bool CheckDeltaVectorInCurrentState(FVector& CheckDeltaVector, FRotator& CheckRotation); //Check climb is possibly in current character location coordinate and return realy coordinate bool CheckDeltaVectorInCurrentState();//Check climb is possibly in current character location without return new coordinates void MoveTo(const FVector& Delta, const FRotator& NewRotation); };
UCLASS() class CLIMBINGSYSTEM_API AClimbingCharacter : public ACharacter { GENERATED_BODY() public: UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly) USpringArmComponent* CameraSpringArm; UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly) UCameraComponent* Camera; // Sets default values for this pawn's properties //AClimbingCharacter(); AClimbingCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); // 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* InputComponent) override; void MoveForward(float AxisValue); void MoveRight(float AxisValue); void CameraPitch(float AxisValue); void CameraYaw(float AxisValue); UFUNCTION(BlueprintCallable, Category = "Pawn|Character") virtual void Jump() override; UFUNCTION(BlueprintCallable, Category = "ClimbingCharacter") void ChangeView(bool FistPirson); void SwitchView(); void CrouchFunk(); void UnCrouchFunk(); virtual void NotifyActorBeginOverlap(AActor* OtherActor) override; private: /** Pointer to climbing movement component*/ UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) class UClimbingPawnMovementComponent* ClimbingMovement; class AOverlapObject* OverlopObject; class AZipLine* ZipLine; bool bFistPirsonView; USkeletalMeshComponent* ClimbMesh; UCapsuleComponent* ClimbCapsule; friend class UClimbingPawnMovementComponent; };
AClimbingCharacter::AClimbingCharacter(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {
AClimbingCharacter::AClimbingCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer.SetDefaultSubobjectClass<UClimbingPawnMovementComponent>(ACharacter::CharacterMovementComponentName)) {
UCLASS() class CLIMBINGSYSTEM_API AOverlapObject : public AActor { GENERATED_BODY() public: enum EClimbingMode GetObjectType() const; protected: UPROPERTY(Category = ObjectType, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) TEnumAsByte<enum EClimbingMode> ObjectType; };
UCLASS() class CLIMBINGSYSTEM_API AZipLine : public AOverlapObject { GENERATED_BODY() public: AZipLine(); virtual void OnConstruction(const FTransform& Transform) override; virtual void PostEditMove(bool bFinished) override; /** The main skeletal mesh associated with this Character (optional sub-object). */ UPROPERTY(Category = ZipLine, VisibleDefaultsOnly, BlueprintReadOnly) class UStaticMeshComponent* StartBase; UPROPERTY(Category = ZipLine, VisibleDefaultsOnly, BlueprintReadOnly) class UStaticMeshComponent* EndBase; UPROPERTY(Category = ZipLine, VisibleDefaultsOnly, BlueprintReadOnly) class USplineComponent* Spline; UPROPERTY(Category = ZipLine, VisibleDefaultsOnly, BlueprintReadOnly) USceneComponent* Pivot; UPROPERTY(Category = ZipLine, VisibleDefaultsOnly, BlueprintReadOnly) UBoxComponent* EndBox; UPROPERTY(Category = ZipLine, EditAnywhere, BlueprintReadOnly) UStaticMesh* RopeMesh; UPROPERTY(Category = ZipLine, EditAnywhere, BlueprintReadOnly) float SplineHeight; #if WITH_EDITORONLY_DATA UPROPERTY() class UArrowComponent* ArrowComponent; #endif protected: TArray<class USplineMeshComponent*> AddedSplineMeshComponents; void SetupSpline(); };
Source: https://habr.com/ru/post/303394/
All Articles