commiting Source folder. Got forgotten in previous commits

This commit is contained in:
2026-04-09 21:44:44 +02:00
parent 4338efdb30
commit 563df1ffc8
91 changed files with 6756 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class lost_planetTarget : TargetRules
{
public lost_planetTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V6;
ExtraModuleNames.AddRange( new string[] { "lost_planet" } );
}
}

View File

@@ -0,0 +1,153 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "customCharacterMovementComponent.h"
#include "GameFramework/Character.h"
#include "Components/CapsuleComponent.h"
#include "Engine/World.h"
UCustomCharacterMovementComponent::UCustomCharacterMovementComponent()
{
// Set default values here if needed
}
// Custom movement physics
// Use custom movement 0 for climbing
void UCustomCharacterMovementComponent::PhysCustom(float DeltaTime, int32 Iterations)
{
// Handle custom movement mode physics here
switch (CustomMovementMode)
{
case 0:
{
if (DeltaTime < MIN_TICK_TIME)
{
return;
}
RestorePreAdditiveRootMotionVelocity();
if (!HasAnimRootMotion() && !CurrentRootMotion.HasOverrideVelocity())
{
if (bCheatFlying && Acceleration.IsZero())
{
Velocity = FVector::ZeroVector;
}
//const float Friction = 0.5f * GetPhysicsVolume()->FluidFriction;
constexpr float Friction = 5.f;
CalcVelocity(DeltaTime, Friction, true, GetMaxBrakingDeceleration());
}
ApplyRootMotionToVelocity(DeltaTime);
bJustTeleported = false;
FVector OldLocation = UpdatedComponent->GetComponentLocation();
const FVector Adjusted = Velocity * DeltaTime;
FHitResult Hit(1.f);
SafeMoveUpdatedComponent(Adjusted, UpdatedComponent->GetComponentQuat(), true, Hit);
if (Hit.Time < 1.f)
{
SlideAlongSurface(Velocity * DeltaTime, 1.f - Hit.Time, Hit.Normal, Hit, true);
}
const ACharacter* Character = Cast<ACharacter>(GetOwner());
FHitResult WallHit;
const bool bWallFound = SweepForwardForWall(Character, WallHit);
if (bWallFound)
{
const FVector SurfaceNormal = WallHit.Normal;
// Update Location
const FVector TargetLocation = WallHit.Location + (SurfaceNormal * 0.1f);
const FVector NewLocation = FMath::VInterpTo(UpdatedComponent->GetComponentLocation(), TargetLocation, DeltaTime, 2.f);
UpdatedComponent->SetWorldLocation(NewLocation);
// Update Rotation
const FRotator TargetRotation = FRotationMatrix::MakeFromXZ(-SurfaceNormal, FVector::UpVector).Rotator();
const FRotator NewRotation = FMath::RInterpTo(UpdatedComponent->GetComponentRotation(), TargetRotation, DeltaTime, 2.f);
UpdatedComponent->SetWorldRotation(NewRotation);
}
else
{
// Reset Rotation and set MovementMode to Falling
const FRotator NewRotation = FRotator(0.0f, UpdatedComponent->GetComponentRotation().Yaw, 0.0f);
UpdatedComponent->SetWorldRotation(NewRotation);
SetMovementMode(MOVE_Falling);
}
if (!bJustTeleported && !HasAnimRootMotion() && !CurrentRootMotion.HasOverrideVelocity())
{
Velocity = (UpdatedComponent->GetComponentLocation() - OldLocation) / DeltaTime;
}
break;
}
default:
// For any other custom mode, fallback to base implementation
Super::PhysCustom(DeltaTime, Iterations);
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, TEXT("Movement mode not implemented!"));
break;
}
}
void UCustomCharacterMovementComponent::OnMovementModeChanged(EMovementMode PreviousMovementMode, uint8 PreviousCustomMode)
{
Super::OnMovementModeChanged(PreviousMovementMode, PreviousCustomMode);
if (CharacterOwner)
{
if (MovementMode == MOVE_Custom && CustomMovementMode == 0)
{
CharacterOwner->bUseControllerRotationYaw = false;
}
else if (PreviousMovementMode == MOVE_Custom && PreviousCustomMode == 0)
{
CharacterOwner->bUseControllerRotationYaw = true;
}
}
}
// Sweeps forward from the character's capsule to detect a wall in front.
// Returns true if a blocking hit is found; OutHit contains hit information.
// SweepDistance is how far ahead to check.
bool UCustomCharacterMovementComponent::SweepForwardForWall(const ACharacter* Character, FHitResult& OutHit, const float SweepDistance)
{
if (!Character)
{
return false;
}
const UCapsuleComponent* Capsule = Character->GetCapsuleComponent();
if (!Capsule)
{
return false;
}
const UWorld* World = Character->GetWorld();
if (!World)
{
return false;
}
const FVector Start = Capsule->GetComponentLocation();
const FVector Forward = Character->GetActorForwardVector();
const FVector End = Start + Forward * SweepDistance;
const float CapsuleRadius = Capsule->GetScaledCapsuleRadius();
const float CapsuleHalfHeight = Capsule->GetScaledCapsuleHalfHeight();
const FCollisionShape CapsuleShape = FCollisionShape::MakeCapsule(CapsuleRadius, CapsuleHalfHeight);
const bool bHit = World->SweepSingleByChannel(
OutHit,
Start,
End,
FQuat::Identity,
ECC_Visibility, // Adjust collision channel as needed
CapsuleShape
);
return bHit;
}

View File

@@ -0,0 +1,26 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "customCharacterMovementComponent.generated.h"
/**
*
*/
UCLASS()
class LOST_PLANET_API UCustomCharacterMovementComponent : public UCharacterMovementComponent
{
GENERATED_BODY()
public:
// Constructor
UCustomCharacterMovementComponent();
protected:
// Override PhysCustom to handle custom movement mode behaviors
virtual void PhysCustom(float DeltaTime, int32 Iterations) override;
virtual void OnMovementModeChanged(EMovementMode PreviousMovementMode, uint8 PreviousCustomMode) override;
static bool SweepForwardForWall(const ACharacter* Character, FHitResult& OutHit, float SweepDistance = 100.f);
};

View File

@@ -0,0 +1,23 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class lost_planet : ModuleRules
{
public lost_planet(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}

View File

@@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "lost_planet.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, lost_planet, "lost_planet" );

View File

@@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"

View File

@@ -0,0 +1,15 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class lost_planetEditorTarget : TargetRules
{
public lost_planetEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V6;
ExtraModuleNames.AddRange( new string[] { "lost_planet" } );
}
}