Hello,
I have set up a Sniper-Weapon and added a SceneCaptureComponent2D to the front of the Scope and
the TextureTarget to die Lens showing to the player cam.
All works fine as long as it is only on instance of the weapon,
but if a secont player pickes up the SniperRifle the Lense flakkers between the two SceneCaptureComponents.
Each client should have only 1 scene capture component.
For example… player1 doesn’t need a scenecapture for player2’s sniper (or else you would potentially need many capture components which is a really bad idea).
I would actually recommend that you don’t use any scenecaptures at all if possible and instead use pre-captured cubemaps to fake the scopes… that depends on your game I suppose, I’m not entirely sure what you are trying to do.
No, Pre-Captured Cubemaps are not working for this.
I try to build a “realistic” Sniper feature. the Character Moves up the Rifle.
The Player Sees on the Lense the Zoomed Envirement with Croshair and around the Scope all envirement is in normal FoV.
This is a Picture how it looks on 1 Client.
But if i Open 2 Clients then the Lense Flakkers betwen the what i am looking and the other player is looking to.
I added a sceneCapture2D Component to the Wepon Blueprint and added a TextureRenderTarget and this Texture i used in a Material and used this for the ScopeLense.
So all Scopes have same TextureRenderTarget (Materials).
I added a SceneCaptureComponent2D to the WeaponBlueprint and to this Component i added a TextureRenderTarget.
This Texture I used in the lense Material of the Scope. So all Scopes have the Same TextureRenderTarget.
I know this is the Problem, but i dont know how to solve it.
Is it possible to Create a TextureRenderTarget in Blueprint on “BlueprintConstruktion” and add this to the CaptureComponent2D and to the Lense Material ?
No it’s not possible to create new render targets at runtime (at least not via blueprint) but even if you could do that it’s a bad idea (for performance reasons).
You can try adding a check in the weapon or character bp to see if the owner pawn is a locally controlled player and then disable the capture component if not so.
It depends on your setup I guess.
Does this happen outside of the editor?
It may be as simple as 2 clients in the editor sharing the same texture render target.
In a non-editor situation, that shouldn’t happen.
That said, you can just create a texture render target for each client, provided you disable the scene capture updates when its not in use (as TK-Master mentioned).
Else, yeah, performance issues.
To create a new texture render target, you will have to use the CreateTextureRenderTarget2D function that is included with Rama’s Blueprint Function library.
This happens inside the Editor,
outside i dont tryed it.
i test it and write again
but currently i have a Problem.
IsLocalyControlled seems not to do what i need.
How to Check if the PlayerPawn is Controlled on my computer or from a other players computer?
IsLocalyControlled should work, I can’t help you any further without knowing how you have things setup though perhaps post some screenshots of your blueprint.