Minor - Modifie la trajectoire de la centipede - V2.1.0
Ajuste le déplacement de la centipede en modifiant le calcul de sa trajectoire. La centipede se déplace désormais horizontalement, ce qui améliore sa visibilité.
This commit is contained in:
@@ -10,7 +10,6 @@ AM4_CentipedeBody::AM4_CentipedeBody()
|
||||
GetStaticMeshComponent()->SetStaticMesh(MeshRef.Object);
|
||||
}
|
||||
|
||||
// Charger les matériaux par défaut (ajustez les chemins selon vos assets)
|
||||
static ConstructorHelpers::FObjectFinder<UMaterialInterface> HeadMatRef(TEXT("/Game/CTP/05_Material/MI_Head.MI_Head"));
|
||||
if (HeadMatRef.Succeeded())
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ void UM4_CentipedeController::StartCentipede(FVector SpawnLocation)
|
||||
|
||||
for (int32 i = 0; i < BodyCount; ++i)
|
||||
{
|
||||
FVector SegmentLocation = SpawnLocation - FVector(0.f, 0.f, i * CellSize);
|
||||
FVector SegmentLocation = SpawnLocation - FVector(0.f, i * CellSize, 0.f);
|
||||
|
||||
AM4_CentipedeBody* Body = GetWorld()->SpawnActor<AM4_CentipedeBody>(
|
||||
AM4_CentipedeBody::StaticClass(),
|
||||
@@ -57,8 +57,7 @@ void UM4_CentipedeController::StartCentipede(FVector SpawnLocation)
|
||||
Body->SetAsHead(i == 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialiser l'historique
|
||||
|
||||
SegmentHistory.SetNum(BodyCount);
|
||||
for (int32 i = 0; i < BodyCount; ++i)
|
||||
{
|
||||
@@ -66,7 +65,6 @@ void UM4_CentipedeController::StartCentipede(FVector SpawnLocation)
|
||||
{
|
||||
FVector InitialPos = BodySegments[i]->GetActorLocation();
|
||||
|
||||
// Remplir avec position initiale
|
||||
int32 InitialHistorySize = SegmentSpacing * (i + 1) + MaxHistorySize;
|
||||
for (int32 j = 0; j < InitialHistorySize; ++j)
|
||||
{
|
||||
@@ -138,8 +136,7 @@ void UM4_CentipedeController::Tick(float DeltaTime)
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
if (BodySegments.Num() == 0) return;
|
||||
|
||||
// Déplacer la tête
|
||||
|
||||
AM4_CentipedeBody* Head = BodySegments[0];
|
||||
if (Head && Head->bIsHead)
|
||||
{
|
||||
@@ -161,22 +158,19 @@ void UM4_CentipedeController::Tick(float DeltaTime)
|
||||
FVector NewPos = CurrentPos + FVector(0.f, SegmentDirection.Y * CentipedeSpeed * DeltaTime, 0.f);
|
||||
Head->SetActorLocation(NewPos);
|
||||
}
|
||||
|
||||
// Enregistrer position de la tête
|
||||
|
||||
SegmentHistory[0].Add(Head->GetActorLocation());
|
||||
if (SegmentHistory[0].Num() > MaxHistorySize)
|
||||
{
|
||||
SegmentHistory[0].RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Faire suivre les autres segments
|
||||
|
||||
for (int32 i = 1; i < BodySegments.Num(); ++i)
|
||||
{
|
||||
AM4_CentipedeBody* Segment = BodySegments[i];
|
||||
if (!Segment) continue;
|
||||
|
||||
// Récupérer position dans l'historique du segment précédent
|
||||
|
||||
int32 PrevIndex = i - 1;
|
||||
int32 HistoryLookback = SegmentSpacing;
|
||||
|
||||
@@ -186,8 +180,7 @@ void UM4_CentipedeController::Tick(float DeltaTime)
|
||||
FVector TargetPos = SegmentHistory[PrevIndex][HistoryIndex];
|
||||
|
||||
Segment->SetActorLocation(TargetPos);
|
||||
|
||||
// Enregistrer position actuelle
|
||||
|
||||
SegmentHistory[i].Add(Segment->GetActorLocation());
|
||||
if (SegmentHistory[i].Num() > MaxHistorySize)
|
||||
{
|
||||
|
||||
@@ -85,8 +85,7 @@ void AM4_Gamemode::BeginPlay()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn centipede controller
|
||||
|
||||
PRINT_SCREEN(TEXT("Spawning Centipede Controller"), FColor::Green);
|
||||
|
||||
FVector CentipedeSpawnLocation = FVector(
|
||||
|
||||
Reference in New Issue
Block a user