diff --git a/Source/M4_CPP/private/M4_CentipedeBody.cpp b/Source/M4_CPP/private/M4_CentipedeBody.cpp index 3643cfd..df0bdc3 100644 --- a/Source/M4_CPP/private/M4_CentipedeBody.cpp +++ b/Source/M4_CPP/private/M4_CentipedeBody.cpp @@ -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 HeadMatRef(TEXT("/Game/CTP/05_Material/MI_Head.MI_Head")); if (HeadMatRef.Succeeded()) { diff --git a/Source/M4_CPP/private/M4_CentipedeController.cpp b/Source/M4_CPP/private/M4_CentipedeController.cpp index 2c965cf..96b237f 100644 --- a/Source/M4_CPP/private/M4_CentipedeController.cpp +++ b/Source/M4_CPP/private/M4_CentipedeController.cpp @@ -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::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) { diff --git a/Source/M4_CPP/private/M4_Gamemode.cpp b/Source/M4_CPP/private/M4_Gamemode.cpp index 304dfeb..2d97557 100644 --- a/Source/M4_CPP/private/M4_Gamemode.cpp +++ b/Source/M4_CPP/private/M4_Gamemode.cpp @@ -85,8 +85,7 @@ void AM4_Gamemode::BeginPlay() ); } } - - // Spawn centipede controller + PRINT_SCREEN(TEXT("Spawning Centipede Controller"), FColor::Green); FVector CentipedeSpawnLocation = FVector(