x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[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).

graph 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!

Product Version: Not Selected
Tags:
more ▼

asked Jan 17 '15 at 02:09 PM in Blueprint Scripting

avatar image

MkII
143 15 16 27

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jan 17 '15 at 03:38 PM

avatar image

Furroy
691 26 86 61

avatar image MkII Jan 19 '15 at 12:23 PM

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 :)

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 :D

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question