#im gonna try
1 messages · Page 1 of 1 (latest)
also just just a little tipp that I've also received here
Don't use StaticClass() but rather TargetClass
still crashes
And maybe extract this into a higher level:
TArray<AActor*> FoundRooms;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ARoom::StaticClass(), FoundRooms);
So you dont do this every time (could also be that the trash collection does not catch up the same way).
If you have a "somewhat" fixed amount of possible rooms you could also try to use the objectpool pattern
editor freezes and slowly uses full ram
incresing ram using
okay
no crash report
Do you have a fixed amount of rooms?
or are you dynamically creating more without destroying them?
wait im trying open project again
no im doing just find some random rooms
so from start to finish you have the exact same amount of rooms?
wait its not crashed
after 2 seconds i got that error ```Unhandled Exception: EXCEPTION_STACK_OVERFLOW
UE4Editor_Navmesh
UE4Editor_NavigationSystem
UE4Editor_NavigationSystem
UE4Editor_NavigationSystem
UE4Editor_NavigationSystem
UE4Editor_AIModule
UE4Editor_AIModule
UE4Editor_HNUE4CPPTemplate!ASosed::MoveToLocation() [G:\HNUE4CPPTemplate\HNUE4CPPTemplate 4.27\Source\HNUE4CPPTemplate\Sosed.cpp:639]
UE4Editor_HNUE4CPPTemplate!<lambda_962772a619d7a889246110be9f064c46>::operator()() [G:\HNUE4CPPTemplate\HNUE4CPPTemplate 4.27\Source\HNUE4CPPTemplate\Sosed.cpp:1902]
UE4Editor_HNUE4CPPTemplate!TBaseFunctorDelegateInstance<void __cdecl(FAIRequestID,FPathFollowingResult const &),FDefaultDelegateUserPolicy,<lambda_962772a619d7a889246110be9f064c46> >::ExecuteIfSafe() [G:\oyun\UE_4.27\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:838]
UE4Editor_AIModule
UE4Editor_AIModule
UE4Editor_AIModule
UE4Editor_AIModule
UE4Editor_HNUE4CPPTemplate!ASosed::MoveToLocation() [G:\HNUE4CPPTemplate\HNUE4CPPTemplate 4.27\Source\HNUE4CPPTemplate\Sosed.cpp:639]
UE4Editor_HNUE4CPPTemplate!<lambda_962772a619d7a889246110be9f064c46>::operator()() [G:\HNUE4CPPTemplate\HNUE4CPPTemplate 4.27\Source\HNUE4CPPTemplate\Sosed.cpp:1902]
UE4Editor_HNUE4CPPTemplate!TBaseFunctorDelegateInstance<void __cdecl(FAIRequestID,FPathFollowingResult const &),FDefaultDelegateUserPolicy,<lambda_962772a619d7a889246110be9f064c46> >::ExecuteIfSafe() [G:\oyun\UE_4.27\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:838]
UE4Editor_AIModule
UE4Editor_AIModule
UE4Editor_AIModule
UE4Editor_AIModule
UE4Editor_HNUE4CPPTemplate!ASosed::MoveToLocation() [G:\HNUE4CPPTemplate\HNUE4CPPTemplate 4.27\Source\HNUE4CPPTemplate\Sosed.cpp:639]
UE4Editor_HNUE4CPPTemplate!<lambda_962772a619d7a889246110be9f064c46>::operator()() [G:\HNUE4CPPTemplate\HNUE4CPPTemplate 4.27\Source\HNUE4CPPTemplate\Sosed.cpp:1902]```
repeats
ok
i can send video crash report output log is very long
No need
Ok first off. I would make FoundRooms to a property of ASosed
and then fill it once when all rooms are setup
so i suppose that would be in begin play
you can still fetch a random room from the class property
that would already reduce the complexity a lot
Yeah
U dont neccessarily need to make it a UPROPERTY, but thats fine
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ARoom::StaticClass(), FoundRooms); put this somewhere, where you know that all rooms have been created
another question. is ASosed an AI controlled class?
yeah
using ai controller
Severity Level Code Description Project File Line Hiding Status
Error (active) E0434 A reference of type "TArray<AActor *, FDefaultAllocator> &" (not qualified as const) cannot be initialized with a value of type "TArray<ARoom *, FDefaultAllocator>" HNUE4CPPTemplate G:\HNUE4CPPTemplate\HNUE4CPPTemplate 4.27\Source\HNUE4CPPTemplate\ Sosed.cpp 201```
hmmm never seen such a thing
if i check the error code on google it says its a rust error
could you send me the class file over?
so h + cpp
wdym by class fike over?
ok i removed
i also think that it should be TArray<ARoom> indead of ``TArray<ARoom*>`
Edit: no its definetly also possible with pointers
just checked some code of a project of mine and im doing it as well
// Select a random clean room ARoom* RandomRoom = FoundCleanRooms[FMath::RandRange(0, FoundCleanRooms.Num() - 1)];
Severity Level Code Description Project File Line Hiding Status Error C2440 'initializing': Cannot convert 'ARoom' to 'ARoom *' HNUE4CPPTemplate G:\HNUE4CPPTemplate\HNUE4CPPTemplate 4.27\Source\HNUE4CPPTemplate\Sosed.cpp 1832 Severity Level Code Description Project File Line Hiding Status Error C2440 'initializing': Cannot convert 'ARoom' to 'ARoom *' HNUE4CPPTemplate G:\HNUE4CPPTemplate\HNUE4CPPTemplate 4.27\Source\HNUE4CPPTemplate\Sosed.cpp 1832
im not spawning ai finding random rooms
but if you do GetAllActorsOfClass those actors must be spawned already within the game
duplicated AAIController* AIController = Cast<AAIController>(GetController());
and also path following component
firstoff make your code more readable.
i would do something like this
void ASosed::OnWashFloorAnimFinished()
{
GetMesh()->PlayAnimation(WashFloorAnim, false);
GetWorldTimerManager().SetTimer(TimerHandle_WashFloor, this, &ASosed::ResetAnim, WashFloorAnim->GetPlayLength(), false);
MoveToLocation(TargetMop->GetActorLocation());
AAIController* AIController = Cast<AAIController>(GetController());
if (!AIController)
return;
UPathFollowingComponent* PathFollowingComp = AIController->GetPathFollowingComponent();
if (!PathFollowingComp)
return;
FPathFollowingResult Result1;
FPathFollowingResult Result2;
PathFollowingComp->OnRequestFinished.AddLambda([this](FAIRequestID RequestID, const FPathFollowingResult& Result1);
if (Result1.IsSuccess())
{
TargetMop->DetachFromActor(FDetachmentTransformRules::KeepWorldTransform);
TargetMop->Mesh->SetSimulatePhysics(true);
TargetMop->SetActorEnableCollision(true);
MoveToLocation(TargetBucket->GetActorLocation());
PathFollowingComp->OnRequestFinished.AddLambda([this](FAIRequestID RequestID, const FPathFollowingResult& Result2)
if (Result2.IsSuccess())
{
TargetBucket->DetachFromActor(FDetachmentTransformRules::KeepWorldTransform);
TargetBucket->Mesh->SetSimulatePhysics(true);
TargetBucket->SetActorEnableCollision(true);
StartRandomTask();
}
}
}
could be that I've missed some parentheses since i just get errors everywhere as i do not have the full code
then u can also return explicit errors
and do not request everything 3-4 times
i think there is error about finding random rooms
when he gonna try random room
editor freezes
void ASosed::OnBucketLocationReached()
{
if (!TargetBucket || !TargetBucket->Mesh)
{
return;
}
// Durabilen fizik özellikleri kapat
TargetBucket->Mesh->SetSimulatePhysics(false);
TargetBucket->SetActorEnableCollision(false);
// GetMesh() ile bağla, "SosedBucket" sockete bağla
TargetBucket->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, TEXT("SosedBucket"));
// Eğer FoundCleanRooms boşsa, ARoom aktörlerini al
if (FoundCleanRooms.Num() == 0)
{
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ARoom::StaticClass(), FoundCleanRooms);
}
if (FoundCleanRooms.Num() > 0)
{
// Rastgele bir oda seç
ARoom* RandomRoom = Cast<ARoom>(FoundCleanRooms[FMath::RandRange(0, FoundCleanRooms.Num() - 1)]);
if (RandomRoom)
{
// Odaya hareket et
MoveToLocation(RandomRoom->GetActorLocation());
// AIController al
AAIController* AIController = Cast<AAIController>(GetController());
if (AIController)
{
// PathFollowingComponent al
UPathFollowingComponent* PathFollowingComp = AIController->GetPathFollowingComponent();
if (PathFollowingComp)
{
PathFollowingComp->OnRequestFinished.AddLambda([this](FAIRequestID RequestID, const FPathFollowingResult& Result)
{
if (Result.IsSuccess())
{
OnRoomLocationReached();
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to reach the room location."));
}
});
}
}
}
}
}
``` i did that and in header file
` static TArray<AActor*> FoundCleanRooms;``
why static?
The only other advice i can give you is adding a breakpoint and stepping though the code
then u might see where its hanging
i guess there is some kind of loop
either the rooms are not setup correctly or you have some circular stuff going on. the other point would be the constant allocation and disallocation of the rooms that you had before, clogging up the garbagecollection.
i gotta leave right now. I will text you later to see if you fixed your problem.
sorry 😦
one more thing you should try to see if it works fine with a fixed room