[4.6.1] Does IsValid check whether the object is fully constructed?
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?
asked Jan 17 '15 at 02:09 PM in Blueprint Scripting
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.
answered Jan 17 '15 at 03:38 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here