Why does destroying an object in the world before I get the Variable for it and cast to it work?
Hoping you can help me solve a blueprint mystery. Here's the situation:
Here's the part I don't understand: after I've done all that, I want to remove the initial object that I collided with, the one that was in the world to begin with. I use a destroy actor node, with the proper target set at the end of the sequence but it doesn't work.
Oddly, if I destroy the object that's in the world BEFORE I get the variable from it and cast to it, it works? There must be something going on with the way blueprints work that I do not fully understand, because to my mind, you shouldn't be able to get a variable from an object you just destroyed?
I've tried this with and without adding the item to the array, thinking that maybe once you add an item to an array you can't delete it out of the world possibly, but it still has the same behavior. I've also tried triggering destroying the actor with an event, and doing it before I destroy the other actor I'm spawning. The only configuration that works is destroying it BEFORE I spawn the actor from the Class:Actor variable in it. Any ideas? This one's got my stumped!
SpawnActor node does not require a target Actor.Thats why it is working even after the Actor is destroyed. But Destroy node needs a target and you are passing the Actor whch just got destroyed, which will not work.
In simpler terms, this is what is happening in each case
SpawnActor(class of Youractor, .., ..,) --> notice that YourActor instace is not used here. You only use the classname
YourActor->destroy() --> YourActor is already destroyed so this wont work
However I do agree with you that this is very confusing. In normal code (like C++), you will not get to access any of the member varibales after the object is destoyed. Perhaps the BP compiler works in a different way and calculates values for all output pins for a node before the output execution pin is fired?
Follow this question
Once you sign in you will be able to subscribe for any updates here