[4.6.1] Does IsValid check whether the object is fully constructed?

Hey peeps,

Question for anyone out there who might know - does the IsValid blueprint node check whether the object it’s checking has been fully constructed?

My situation is that I have two identical objects that overlap with each other. In the OnBeginOverlap event, I try to amalgamate the two objects into one object by simply deleting one of them (and adding any useful data to the surviving one).

Here is the relevant graph. Now this works fine except I get errors in the message log when playing tellling me that ‘CollisionSprite’ is not avaiable in the ConstructionScript because the object is pending kill.

It seems to me that the overlap event is being called before both objects have been fully constructed, unless the message log is lying to me about the location of the error (i.e. it’s not in the construction script) which has happened to me before. Also, my construction script is empty, but the component is added in the components tab of the blueprint, which I assume means it’s added during the construction script.

If I add a delay of 0.1s before the destroy actor node, I get no errors, which has lead me to believe that the IsValid nodes are not checking that the objects are fully constructed. Am I correct, and can anyone think of a better way to amalgamate two identical actors when typically they spawn overlapping?

Cheers!

I always assumed IsValid was the same as “not null” as in whether the variable is present or not. It would not guarantee how far along it is in the constructor or anything else about it.

The problem you’re going to have is both actors are going to get a begin overlap event and both are going to try to delete the other one at the same time. I would make a new integer variable and set it in the constructor to a random number from 1 to 9999999. Then in the overlap events, check to see which one has the highest value and keep that one and ignore overlaps on the lower value. If the other hasn’t made it through the constructor it will just have 0 and always lose.

You may still run into trouble if there are more than two and there are crazy overlapping patterns, but hopefully this gets you going for now.

Ah, I had completely not recognised that they would try to destroy each other at the same time! The situation is further complicated by the fact that I have quite a few of these actors overlapping with each other, and so I’m probably ending up with quite a few overlap events on actors that have been marked for destroy but not actually gone yet.

I think my full blown solution will involve a manager for these actors, because there’s quite a few things I want to do with amalgamation which would benefit from something that keeps track of all of them, and I can put deterministic logic into it to choose one actor over another.

Thanks :slight_smile:

Edit: Oh, just worked something awesome out - I set my collision component to NoCollision by default, and in BeginPlay, I set it to enabled. Now, both actors must be fully constructed when the overlap event hits :smiley: