#hi guys why is the overlap dont happen

1 messages · Page 1 of 1 (latest)

tame shard
#

Can you clean up your EventGraph and post a better overview, as well as try to explain what you are trying to accomplish? It's not clear from your currently provided information.

fringe otter
#

than why they dont overlap i set all collisions to the overlap

tame shard
#

Ah, nice, you can write here now. I was able to fix it without an admin, woohoo

#

What is inside of them? StaticMeshes or just Collision Components, like a box?

fringe otter
#

here is my full blueprint

fringe otter
tame shard
#

I wonder if it's because they were spawned inside of each other and they would need to move in some way to trigger the overlap from filling the overlap infos that the IsOverlapping node uses

#

fwiw you could try that assumption out by setting the location to the current one and +1 on Z or so.
Just to rule out other potential issues

#

After the SpawnActor node

fringe otter
tame shard
#

Yeah it might really be that the Overlaps aren't refreshed if the Actor isn't moved

fringe otter
#

yea its not moved

tame shard
#

What I don't fully understand in your code is why you always check the same 2 actors if they overlap and not directly the one you Spawned.

fringe otter
tame shard
#

Sure, but how are they relevant to the newly spawned actor?

fringe otter
#

thats why i checked two actors i wanted to see if it works

tame shard
#

Ah, those are a test, I see.

#

Hm, my assumption that the newly spawned Actor has to be moved, even if just a very small distance, to get the overlapinfos to fill in C++, still stands.

fringe otter
#

but it should not be moved because its endless runner : (

tame shard
#

Yeah I know, it's also only just a bit and only to try if that it fixes it in general

#

"a bit" being like 1 unit

fringe otter
#

ok how do i move it set actor location right

tame shard
#

Yeah, you would call "SetActorLocation" on the result of your SpawnActor node, and then for the new Location you can take the Location you already use for spawning and just add a small value to it

#

Again, this is mainly just to test if it's really the reason that your overlaps don't work

fringe otter
#

ok ill try it

tame shard
#

And you want to do that directly after spawn actor, before you test for overlaps

fringe otter
#

still not destroyed but its printing some hellos but they are not enough

tame shard
#

So the Overlap works if you move the Actor a bit ? You should move the spawned Actor though, not necessarily the Train itself, unless you spawned the train there (which I think you didn't cause you said those are for testing only).

fringe otter
fringe otter
tame shard
#

Hm, not sure at the moment, just from the pictures etc. Are the actors visually overlapping?

fringe otter
#

i want the actors to be removed there

tame shard
#

And you are spawning the one that are 90° towards the tracks?

fringe otter
#

and im spawning them both because its array with shuffle

fringe otter
tame shard
#

There are multiple "Train" and "OtherTrain" actors an any given time, right?

tame shard
#

What you could try is, instead of the GetActorOfClass stuff, is to call "GetOverlappingActors" on the newly spawned Train, and then looping over that array.
And casting each of the Elements to either Train or AnotherTrain. If any of the casts succeed, it is overlapping a Train/AnotherTrain and you can destroy it.

tame shard
fringe otter
#

here is the class types

tame shard
#

I am however a bit lost on how to further help you at this point. It's tricky to debug this :P

fringe otter
#

is this right

tame shard
#

No, you only need one of those GetOverlappingActors nodes. And you will want to loop over the result and check if any of those overlapping actors of a class you don#t want to overlap.

#

What you are currently doing is taking the first element, twice, and checking if it basically overlaps itself.

fringe otter
#

ok it works now but it destroy the train how do i destroy another train

#

thank you so much i figure it out by getting actor of class it was a bit hard

tame shard
#

Glad you got a solution. There is def a better way of handling this, but you seem to be learning still and I don't think I have the time to walk you through more complex setups.

fringe otter
rough crane
#

also this code is really heavy, i hope it's a small loop

fringe otter
rough crane
#

is it working as expected ?

fringe otter
rough crane
#

i would do that in the spawn itself, spawn it, check it overlaps with another train if it does, remove it

#

or move it around or something

fringe otter
rough crane
#

so when you spawn a bus... check if it is overlapping with anything then

fringe otter
rough crane
#

ok so train is one of these obstacles ?

fringe otter
rough crane
#

and spawn obstacles is all on the map ?

fringe otter
rough crane
#

what does that function look like because i would do it in the spawn

#

so that it just doesn't overlap in the first place so you don't have to fix it

fringe otter
fringe otter
#

i even put this just to make space higher UE_LOG(LogTemp, Warning, TEXT("Spawning Obstacle at Y Position: %f"), CurrentYPosition);
CurrentYPosition += Parameters.SpacingBetweenObstacles+500.0f;
UE_LOG(LogTemp, Warning, TEXT("Next Obstacle Y Position be: %f"), CurrentYPosition);

rough crane
# fringe otter no it does when the space is low
if (SpawnInfo.ObstacleActorClass)
        {
            FActorSpawnParameters SpawnParams;
            SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
            AActor* SpawnedActor = GetWorld()->SpawnActor<AActor>(SpawnInfo.ObstacleActorClass, SpawnPosition, SpawnInfo.Rotation, SpawnParams);
            SpawnedActor->SetActorScale3D(SpawnInfo.Scale);
            // Set the location and rotation if needed
            SpawnedActor->SetActorLocation(SpawnPosition + SpawnInfo.LocationOffset);
            SpawnedActor->SetActorRotation(SpawnInfo.Rotation);
           
          
            SpawnedActors.Add(SpawnedActor);
            ForwardVector = SpawnedActor->GetActorForwardVector();
            BaseSpawnLocation = SpawnedActor->GetActorLocation();
            PreviouslySpawnedActor = SpawnedActor;
        
        }

this is a bus ?

fringe otter
#

yes i mean the train

rough crane
#

ok so in there, why don't you check for overlapping actors of SpawnedActor

#

if it's overlapping other trains, or anything really, either don't spawn it or move it and check again

#

or if that isn't an option ig you can the route of correcting them like you were doing

#

but i just feel logically that it's best to do it when you spawn so your not needing to clean up stuff afterward in bp

fringe otter
rough crane
#

idk much about c++

#

ig you could just delete them in bp but i'm saying logically it would be best to do it in that function

#

so you could just destroy it it, and don't add it to spawedactors if it overlaps stuff

fringe otter
rough crane
#

right but that will be if anything overlaps with it

#

you may want to restrict that to a certain class or something

#

do you have a parent class for you spawning items ?

fringe otter
fringe otter
rough crane
#

hmmm, interesting

#

i would think that would be some kind of manager

#

and the parent class be something like BP_Spawnable or something like that

fringe otter
rough crane
#

it should work, just don't add it the spawned actor to the array and destroy it

#

it will also be more performant in c

#

i ask about the parent because you should be able to check by the parent class

#

and there you would be checking all spawnable things, might be worth it

fringe otter
rough crane
#

idk what that has to do with checking for overlaps

#

is it because other things are overlapping as well ?

fringe otter
rough crane
#

it will work if you set the class filter to be your parent class of spawnables, so that your just checking for ones with that parent, or you can filter by the train class and just do traings

#

you won't have to change your collision settings to check overlap

#

if it's blockall that should be fine idk if it's a problem

#

your just checking for overlapped acters and filter by a class so it cleans out the rest

fringe otter
#

they dont get destroyed

rough crane
#

you couldn't do it in the cpp ?

fringe otter
#

basically this is the logic in cpp ``` if (SpawnedActor)
{
SpawnedActors.Add(SpawnedActor);

        // Check for overlaps immediately after spawning
        for (AActor* OtherActor : SpawnedActors)
        {
            if (SpawnedActor != OtherActor && SpawnedActor->IsOverlappingActor(OtherActor))
            {
                
           
                OtherActor->Destroy();

                // Remove them from the array
                

                SpawnedActors.Remove(OtherActor);
                break; // Exit the loop as the current actor is no longer valid
            }
        }
    }```
rough crane
fringe otter
rough crane
#

oh i c

fringe otter
rough crane
#

i think so ya

#

you should be able to get all the actors, do a foreach, and check if overlapping actors with a filter is > 0

#

if so then mark it for deletion, and delete them all after

rough crane
#

by all the actors i mean you return from your function

#

after spawning them

#

by mark it for deletion maybe an array of indexes that you remove afterward or something

#

because your not really supposed to remove while looping it

fringe otter
#

do you mean like this

rough crane
#

no

#

take those out

#

and just check length of overlapping actors

#

pull out from the return value of get overlapping actors, and get length

#

then check that is > 0

#

so you want to check if the current one in the foreach is overlapping anything

#

if it is destroy it

#

but you don't want to do that in the foreach

fringe otter
#

like this right

rough crane
#

ya

#

but you'll need to clean up your array

#

you'll have empty references

#

so if you use that array anywhere to do something with the actors

#

you'll need to do some is valid checks

#

i would create a function that removes invalid references

fringe otter
#

ok this works but i couldnt solve the coin proplem it still overlap with the coins

rough crane
fringe otter
#

here is my coins spaen

rough crane
#

you got to first figure out what you want to do

fringe otter
#

obstacle spawner

rough crane
#

not a parent class of your spawnables

#

but whatever is the parent of your spawnables

fringe otter
rough crane
#

so your coins are not part of the obstacles, so they wouldn't be in that array ?

#

they should share a parent like spawnable or something, if not then you could just leave the filter alone and check all overlaps

#

so if it overlaps "anything"

fringe otter
#

ok that will not work because i need that static mesh component

rough crane
#

check for all actors on the overlap, it's a little bit heavy on the game

#

but it should give you if your overlapping the coins

#

but it might give you tracks

#

you could do a second pass

#

checking for coins

#

since your only doing this on load i'm guessing

#

do the same thing on completed, but this time check if your coins have overlaps instead

#

and remove/move them as needed

fringe otter
rough crane
#

all this foreach and get overlapping actor is heavy also

#

if it runs good then thats great but a large level might even break

#

you should be checking things when you spawn them instead but whatever works ig

#

i would spawn your obstacles, then your coins, so you can check each coin if it's overlapping or not

fringe otter
#

i tried this logic to see if anything printed not even single hello wtff

rough crane
#

after you spawn the coin check if it overlaps anything, if it does destroy it

#

this is a lot to do in bp

#

i would try to offload what you can to c

#

once you get it working in bp, just make it in c++ the same

fringe otter
#

something is definatly wrong here it should print at least a hello there

rough crane
#

when does the second image run ?

fringe otter
fringe otter
#

it works on the coin actor itself but not when i do it like this

rough crane
#

what exactly are you trying to do ?

fringe otter
fringe otter
rough crane
#

so your not getting a live value there

#

and in the beginning it's probably false

fringe otter
rough crane
fringe otter
fringe otter
rough crane
#

begin play just runs on load

#

thats it

fringe otter
rough crane
#

the code isn't "live" like update a variable it runs or something