Prop disposal / IsValid Conditions

I’m working on some test code that tries to access a custom prop I created, but whenever I try to access it to do something, IsValid fails. I don’t know why - there doesn’t seem to be any discussion about what the disposal mechanisms are. So, a few questions:

  1. What are the conditions under which a prop will be disposed by the system?
  2. Are there other conditions that will cause IsValid to fail besides being disposed?
  3. Once disposed, can a prop “come back” or be reset, or is it now gone gone?

Thanks!

1 Like

Could you perhaps provide some code that highlights your specific issue?

In general though, a prop should only be invalid if it was explicitly disposed via verse code or if it was in any other way destroyed (e.g. getting destroyed by a hit, or the level unloading etc.). Once a prop is disposed that particular prop will not be able to “come back”, a creative_prop variable in a verse script can however naturally be valid again after being disposed if it was assigned a new value in-between the calls to IsValid, e.g. like (pseudo code):

GetAProp():creative_prop=
    # ... do stuff here that e.g. finds or spawns a prop

Foo():void=
    var TheProp:creative_prop = GetAProp()
    TheProp.Dispose()
    # TheProp will at this point be invalid
    set TheProp = GetAProp()
    # TheProp will here be valid again if GetAProp() returned a valid prop

There have been some bugs revolving around props being unintentionally and incorrectly disposed by the underlying infrastructure, all known issues of this sort have been fixed in upcoming releases though. It is not the intention that you should ever have to think about a case where “The System” secretly disposes a prop for you. Hope this helps :slight_smile:

1 Like

This code is really basic, just following the gameplay tag example in the docs. I put it in a loop to just test if it was some initialization thing where the props hadn’t been created yet when OnBegin is called and they would become valid later (they don’t).

tag_boxbot := class(tag){}

bot_manager := class(creative_device):

	var PrintTimer : float = 20.0

	# Runs when the device is started in a running game
	OnBegin<override>()<suspends> : void=
		spawn:
			CheckPositions()

	CheckPositions()<suspends> : void=
		loop:
			Sleep(5.0)

			# find all actors with the tag_boxbot
			AllCreativeObjects : []creative_object_interface := GetCreativeObjectsWithTag(tag_boxbot{})

			Print("Found {AllCreativeObjects.Length} items with tag_boxbot")

			# Print the position of all creative_prop actors
			for (Object : AllCreativeObjects):
				if (Prop := creative_prop[Object]):
					if (Prop.IsValid[]):
						Print("Found prop at: {Prop.GetTransform().Translation}")
					else:
						Print("Found disposed prop")

			set PrintTimer -= 5.0
			if (PrintTimer <= 0.0):
				break

		Print("Loop done")

Log

LogVerse: : Found 16 items with tag_boxbot
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop
LogVerse: : Found disposed prop

Image when level starts (those are the boxes in front of me, I wasn’t sure if it was a culling thing.)

Thanks, and hopefully that next update will be coming soon!

Found the issue, although I’m not sure how I got there yet… The props that were disposed showed up as (Instance) in the details box for the object in uefn. There were other props which show up as (Self) and those work okay. I’m not sure if that’s a bug or not, but I have some props I can play with now.

Right, that does sound like a bug is lurking somewhere with respect to the editor not cleaning up instances properly perhaps. Thanks for shining light on it.

1 Like

Hey Megaspace!

Do you happen to have a zip of your project that you can DM me? If not no worries! Trying to get a bit more information on our user reported issues.

Unfortunately, I don’t have the project file in that state anymore.

I spent some time trying to recreate it, and didn’t have much luck. Every time I created a Blueprint class, it came up as (Self) in the details pane.

So, on a lark I tried just doing it with a static mesh, which does show up as (Instance) and then put the same tag on it. It had the same name as the Blueprint Class so I didn’t want to rule out programmer error.

Lo and behold, I have a bunch of “props” that are now returning IsValid fails. I think I most likely created a bunch of static mesh objects by accident instead of props. Unless you know of a way to get Blueprint class objects to show up as (Instance) in the editor.

So, I think my question is - why did the cast to creative_prop not fail? I would have thought it would have been caught there.