How to create a self-contained SceneCaptureComponent2D and Plane class?

TheBoxyBear
Wed, 07 Apr 2021 23:03:48 +0000
C++

I want to make a “Camera” blueprint class that captures what it sees using a SceneCaptureComponent2D (calling it render camera from now on for simplicity sake). All the example of this component I can find create a texture asset and reference it in the render camera’s properties. The problem with that approach is that all instances will share the same texture so will all screens. I would like to have each instance of my class store it’s own texture, so each one can show it’s own image separately. This is especially important since my camera instances are spawned at runtime an there will be multiple of them at once.

I have been experimenting with dynamic material instances, but wasn’t able to get it to work. Here is what I have so

LensBase is a material I created that contains a texture sample parameter called Render. The problem is that because both the texture target and LensRender variable are None, I can’t get a reference to the texture target to use as a parameter value. I tried using CreateObjectFromClass to get an object reference to work with, but storing it in texture target, even passing through the LensReader variable causes the entire editor to crash when compiling.

1 post - 1 participant