#im gonna try

1 messages · Page 1 of 1 (latest)

halcyon temple
#

also just just a little tipp that I've also received here

#

Don't use StaticClass() but rather TargetClass

nimble olive
#

still crashes

halcyon temple
#

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

halcyon temple
#

or is it a silent crash?

nimble olive
#

incresing ram using

halcyon temple
#

okay

nimble olive
#

no crash report

halcyon temple
#

Do you have a fixed amount of rooms?

#

or are you dynamically creating more without destroying them?

nimble olive
#

wait im trying open project again

nimble olive
halcyon temple
#

so from start to finish you have the exact same amount of rooms?

nimble olive
#

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

halcyon temple
#

can u format it pls?

#

hard to read

nimble olive
#

i can send video crash report output log is very long

halcyon temple
#

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

nimble olive
#
    UPROPERTY()
    TArray<ARoom*> FoundRooms;```
#

like this?

halcyon temple
#

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?

nimble olive
#

using ai controller

nimble olive
halcyon temple
#

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

nimble olive
halcyon temple
#

Sosed.cpp and Sosed.h

#

before that

#

remove the UPROPERTY

nimble olive
halcyon temple
#

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

nimble olive
#

// 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

halcyon temple
#

ok

#

Can u show me where you create the rooms (aka. Spawn it)

nimble olive
#

im not spawning ai finding random rooms

halcyon temple
#

no

#

obviously not

nimble olive
halcyon temple
#

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

nimble olive
#

if i remove gives error

#

thats why i hate ai in cpp

#

its just pain

halcyon temple
#

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

nimble olive
#

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;``
halcyon temple
#

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