Skip to content
Snippets Groups Projects
Commit be4a0be3 authored by Till Sittart's avatar Till Sittart
Browse files

Fixing bugs

parent b033c3b9
No related branches found
No related tags found
No related merge requests found
......@@ -706,8 +706,27 @@ void UVHSimpleMovement::TickComponent(float DeltaTime, ELevelTick TickType,
if (HitAgents.Num())
{
int i = 1;
int iFront = 0;
int iBack = 0;
TMap<AVirtualHuman*, float> CurrentRiverChildAgents;
// get list of all current childs that are walking in river formation
for (TPair<AVirtualHuman*, float> Pair : ChildAgents)
{
UVHSimpleMovement* ChildMovement = Pair.Key->FindComponentByClass<UVHSimpleMovement>();
if (ChildMovement && ChildMovement->CurrentMovementFormation == SimpleRiver)
{
CurrentRiverChildAgents.Add(Pair.Key, ChildMovement->CurrentOffset);
}
}
TArray<float> CurrentRiverChildOffsets;
CurrentRiverChildAgents.GenerateValueArray(CurrentRiverChildOffsets);
float MaxOffset;
int MaxIndex;
UKismetMathLibrary::MaxOfFloatArray(CurrentRiverChildOffsets, MaxIndex, MaxOffset);
for (TPair<AVirtualHuman*, float> Pair : ChildAgents)
{
......@@ -721,6 +740,12 @@ void UVHSimpleMovement::TickComponent(float DeltaTime, ELevelTick TickType,
{
float NewOffset = FMath::Abs(ChildMovement->ChildToParentOffset) * -1.f * 1.1f * float(i);
if (CurrentRiverChildOffsets.Contains(NewOffset))
{
i = CurrentRiverChildOffsets.Num() + 1;
NewOffset = FMath::Abs(ChildMovement->ChildToParentOffset) * -1.f * 1.1f * float(i);
}
// check if child is in front or behind pawn
ChildMovement->CurrentOffset = NewOffset;
//VH_LOG("(Moving correction) Change child %s movement formation to SimpleRiver with offset %f", *HitChild->GetName(), NewOffset)
......
......@@ -38,7 +38,7 @@ AVirtualHuman::AVirtualHuman()
PawnCollisionSphere = CreateDefaultSubobject<USphereComponent>(TEXT("PawnCollisionSphere"));
PawnCollisionSphere->InitSphereRadius(150);
PawnCollisionSphere->SetupAttachment(RootComponent);
PawnCollisionSphere->SetRelativeLocation(FVector(270.f, 0.f, 10.f));
PawnCollisionSphere->SetRelativeLocation(FVector(200.f, 0.f, 10.f));
PawnCollisionSphere->SetRelativeScale3D(FVector(1.8f, 0.4f, 1.f));
PawnCollisionSphere->SetGenerateOverlapEvents(true);
PawnCollisionSphere->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment