Scenecapture 2d in multiplayer:sniper scope

Hi guys, i have a problem with my game project. i am doing a sniper scope using a camera capture 2d(render target,material) attached in socket in my weapon. it works with one player in game, but when 2 players use the sniper scope, both see same image. i have posted some screen to be specific to explain my problem. anyone, can be help me? thank all and sorry for my elementary english… :slight_smile:

That’s because there’s only 1 material, so obviously they will see the same picture. I think, you need to create X materials per X maximum players in your game, and assign proper material to scope based on player number.

Pseudo code:
let’s say you 20 players in a match maximum.

  1. Make 20 render target materials.
  2. Have a data table with all the materials
  3. In GameMode class, override SetPlayerDefaults, this method provides a Pawn for this specific player. And is called after player enters the game.
  4. In said method, Cast to your character class, and get the weapon actor, then its scope render target 2d
  5. Tell the render target to project to specific material, by reading a row from the data table you have created.
  6. At this point, there will be different rendered materials
  7. Now you need to assign a proper material to the scope, and it should work.

Hope this helps.

thank you so much, i am trying it tomorrow. then i want to trying to reduce the steps and avoid to create 20 different render targets and materials…thanks again.

I tried it the way you describe but got lost in how you said to set it up. I setup the Struct and Data Tables for both the Texture and the Material, then tried to follow your steps but they are vague at best. Can someone please just define the steps, after all there is not any tutorial out there on how to reference a texture or material to an Asset, then reference that back to a lot of players, and link it to a specific random object…

Okay, the easiest way to do this turns out to be that you put the camera and the 2dscenecomponent in the character, then make a texture that you use for the 2dscenecomponent and turn that into a material that you add to the mesh that you use for the eye piece on the scope. Then it renders right.

the same problem

this logic in weapon on begin play, the instigator is my Pawn, i have only 1 render target material for all players


Hello! I seem to have found a solution, heres my blueprint. You make a render target and then set it as the texture target for your scene component 2D. Then create a dynamic material for realtime customisation and set it on your scope, finally set the texture target in your dynamic material using it as a parameter. To do this remember to convert your render target in your material to a parameter.

Hope ive helped :slight_smile:

1 Like

YAZGOOP’s answer is spot on, I did what he did and it worked like a charm. Genius, Thanks!

That’s perfect, man!