How should I go about fixing the error "Ensure condition failed: MyOwnerWorld" when cooking my project?

Hey Andriucha,

So what appears to be happening here is the actor that you are adding a component to (or attempting to) does not have a valid world for whatever reason. It could be an issue with order of operations, such as attempting to add the component is taking place before the actor has been initialized in the world.

Here is the code for that ensure:

UWorld* MyOwnerWorld = (MyOwner ? MyOwner->GetWorld() : nullptr);

	if (ensure(MyOwnerWorld))
	{
		RegisterComponentWithWorld(MyOwnerWorld);
	}

Basically it’s checking to see if the owner of the actor component has a valid world, or else it sets the world to null. If the world is null, then the ensure will fail like you’re seeing in your logs. I’d recommend putting some IsValid checks in place (if you’re using blueprints) or making sure to check the validity of the world before spawning any actors or adding any components.

Let me know if you have any further questions.

3 Likes