CameraComponent attaches StaticMesh to Actor

Hey in one function i collect all staticmeshcomponents of an actor to make stuff with their meshdata.
now i noticed that the cameracamera component attaches an static mesh to the actor that can#t be seen in the details panel.
I want to exclude this static mesh because i dont need it, but how can i tell that the searched component is from the camera or not?

ActorObject = GetOwner();

ActorObject->GetComponents<UStaticMeshComponent>(MeshComponentList);

tnhanks in advance

Hey!!

Yup Cameracomponent has a static mesh and guess what is that? The Camera itself :slight_smile:
At first if you check source code :

#if WITH_EDITORONLY_DATA
	// The frustum component used to show visually where the camera field of view is
	class UDrawFrustumComponent* DrawFrustum;

	UPROPERTY(transient)
	class UStaticMesh* CameraMesh;

	// The camera mesh to show visually where the camera is placed
	class UStaticMeshComponent* ProxyMeshComponent;
	
	virtual void ResetProxyMeshTransform();

	/** Ensure the proxy mesh is in the correct place */
	void UpdateProxyMeshTransform();
#endif

That meshcomponent is valid only with editor and will not builded in final game :wink:
So dont worry! if you creating a game you will not get that component because that will be invalid… (but maybe will be added to array, but you can check for nullptr)

Another method for check that is a cameramesh…

if (ProxyMeshComponent == nullptr)
		{
			ProxyMeshComponent = NewObject<UStaticMeshComponent>(MyOwner, NAME_None, RF_Transactional | RF_TextExportTransient);
			ProxyMeshComponent->SetupAttachment(this);
			ProxyMeshComponent->bIsEditorOnly = true;
			ProxyMeshComponent->SetStaticMesh(CameraMesh);
			ProxyMeshComponent->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
			ProxyMeshComponent->bHiddenInGame = true;
			ProxyMeshComponent->CastShadow = false;
			ProxyMeshComponent->PostPhysicsComponentTick.bCanEverTick = false;
			ProxyMeshComponent->CreationMethod = CreationMethod;
			ProxyMeshComponent->RegisterComponentWithWorld(GetWorld());
		}

As seen here, Proxy mesh is hidden in game… i assume your meshes is visible in game, so you can remove hidden meshes from your meshlist :wink:

or just get meshcomponent owner and if you can cast to cameracomponent… you need remove that

Thanks AmphDev!

Yeah i’ve seen that it is the camera staticmesh if also looked into the engine code, still dident knwo how to intensionoly overlook all static meshes the engine spawns on components^^
But you tip withe bHiddenInGame looks like a good indicator for ignoring unintended meshes.

thanks again