#hi guys why is the overlap dont happen
1 messages · Page 1 of 1 (latest)
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.
than why they dont overlap i set all collisions to the overlap
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?
here is my full blueprint
static mesh and inside it boxes
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
i even inside the actor itself checked overlap and it didnt
Yeah it might really be that the Overlaps aren't refreshed if the Actor isn't moved
yea its not moved
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.
they are diffrent the first one named train and other one named other train
Sure, but how are they relevant to the newly spawned actor?
i also checked the return value o what i spawned as the target of is overlap and it didnt work
thats why i checked two actors i wanted to see if it works
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.
but it should not be moved because its endless runner : (
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
ok how do i move it set actor location right
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
ok ill try it
And you want to do that directly after spawn actor, before you test for overlaps
still not destroyed but its printing some hellos but they are not enough
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).
the proplem is it even works without set actor location but here is the main proplem its only for 5 or 6 hellos not all the spawned actors
and when i moved the spawned actor and it didnt print out any hello idk why
Hm, not sure at the moment, just from the pictures etc. Are the actors visually overlapping?
here is what im trying to achive
i want the actors to be removed there
And you are spawning the one that are 90° towards the tracks?
yea the 90 degree is the another train and the straight is the train
and im spawning them both because its array with shuffle
..
There are multiple "Train" and "OtherTrain" actors an any given time, right?
yea
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.
Unless that's what you are already doing with this
here is the class types
ok ill try this
I am however a bit lost on how to further help you at this point. It's tricky to debug this :P
is this right
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.
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
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.
ok now how about doing the same thing in cpp and blueprint i tried but it didnt work i just copy that and used for each loop because my actors in array
are you checking if the 1 index on overlapping actors is overlapping itself ?
also this code is really heavy, i hope it's a small loop
yea thats why i want the other thing to be destroyed and yes the code is heavy
can an actor overlap itself tho, that doesn't make sense to me
is it working as expected ?
yea it is solved by making the space between obstacles waves more but that still dont have control between indivisuals as for the overlaps yea it doesnt make sense thats why its not working as expected
ok so you want if a train overlaps another train, to remove it ?
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
yea but i still dont know how this is my logic
..
so when you spawn a bus... check if it is overlapping with anything then
but i spawn in array with another index is the train
ok so train is one of these obstacles ?
yea
and spawn obstacles is all on the map ?
yea
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
no it does when the space is low
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);
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 ?
yes i mean the train
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
but i cant tell cpp that it is the train so i will check if its index 1 destroy it if it overlap with index 0 will this fix it
you just say if overlapping actors length is > 0 then your overlapping stuff
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
ok ill try this if the overlaping length is more than zero destroy actor
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 ?
yea because if the charcter walk on the train it will get destroyed
yea this obstacle spawner is the parent class
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
yes but i neamed it new blueprint i will try this logic and limit the charcter and see if it works
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
i just realized i cant do overlap things because my obstacles has to be block all to make the charcter walk on them
idk what that has to do with checking for overlaps
is it because other things are overlapping as well ?
wait is it supposed to work even if they all have block all
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
than why this dont work even if i moved the coin while simulate
they dont get destroyed
you couldn't do it in the cpp ?
no i could but it didnt destroy
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
}
}
}```
well i quit this channel because they dont seem want to help me i hope i can do this in blueprint
oh i c
is it possible in blueprint
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
ok ill try this
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
do you mean like this
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
like this right
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
ok this works but i couldnt solve the coin proplem it still overlap with the coins
maybe set the filter to the parent class of your spawnables
here is my coins spaen
you got to first figure out what you want to do
oh you mean the obstacles as the parent
obstacle spawner
i mean that should be a manager
not a parent class of your spawnables
but whatever is the parent of your spawnables
ok ill try this
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"
yea but the parent part is static mesh actor so i have to change them
ok that will not work because i need that static mesh component
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
ok ill try this
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
i tried this logic to see if anything printed not even single hello wtff
ok ill try this
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
something is definatly wrong here it should print at least a hello there
so your casting to the character, so are you trying to figure out if your character is overlapping something ?
when does the second image run ?
they both run on event begin play
yes
it works on the coin actor itself but not when i do it like this
well thats your problem, your character probably isn't overlapping on begin play
what exactly are you trying to do ?
it overlaps i print string and it did but when i do it on other actor like in second picture it doesnt
basically see if it ever overlaps
because the code in the second image is run on begin play its only checking basically when it loads up
so your not getting a live value there
and in the beginning it's probably false
oh ok but why even when i add a delay it still doesnt work
so you want when the player overlaps the blueprintttt ?
yea i added delay on the second image it should fire after 20 seconds but it doesnt so there is something wrong with the obstacle spawner blueprint
it doesnt make the bool true why idk
it does, but your checking it on begin play
begin play just runs on load
thats it
wait even with a delay
the code isn't "live" like update a variable it runs or something