how to make multiple nearby objects to player transparent?

Hello, I’m trying to add in a feature where the player can press a button and all the walls go transparent, so other objects can be seen through them, within a certain distance. I’ve managed to get this working for a couple of objects, although this would not be practical to do for lots and lots of different objects.

so here, when F is pressed, AND a sphere attached to the player (so basically the players location, i had been trying to use overlaps) is within 1000 units of the target, then a dynamic instance of the material is created, and the opacity is set to a low value, and the material applied.

The problem is that i can’t practically copy the “distance away” logic for every single wall, as you can see even in this example it only takes the distance for one wall, to make both walls transparent. I figure there must be some way to use some better variables or arrays or something so that this logic can be looped for every wall separately, then each wall individually has the material applied, when within a distance? Any suggestions?

[heres a .txt file of the example shown, which I think you can just copy into your level editor (?) if you want to edit this, don’t know if this is helpful…][2]

Many thanks

If I understand you correctly, you’ve already got the transparency part working and are now wondering how to get all walls in a certain radius around the player.

To get all objects in a certain radius around any position in the world, you can use the SphereOverlapsActors node.

55709-sphereoverlapactors.png

You can then iterate over all Out Actors to turn them transparent.

The important part is the Object Types array you feed into the node. By default, all static meshes use the WorldStatic Collision ObjectType. You can edit this parameter in the viewport’s Details panel. You’ll need to change the CollisionPresets to Custom first to make it editable.

55734-collisionobjecttype.png

Seeing how you probably only want some of your static meshes to become transparent but want all of them to use the same collision, your best bet is probably to create a new Collision setting:

  1. Open the ProjectSettings

  1. Open the Collision tab, click New Object Channel and give it a name

  1. Back in the viewport, you can then pick your new object channel in the Collision category. If you have several objects selected at the same time, you can bulk-edit the property for all of them

Good luck!

Oh, and of course you also need to change the setting in the ObjectTypes passed into the SphereOverlapsActors node:

55736-changeobjecttypeinarray.png

Thanks, I really appreciate the help, the only issue i have now is getting the array of actor references converted into (an array of?) primitive components so i can apply or change the material on them? When I take a line from the SphereOverlapActors “out actors” pin I can’t seem to do much with it?

Can’t you call GetStaticMeshComponent on them like you did in your example?

I haven’t actually tried your setup, only fiddled with the SphereOverlapsActors node’s returned actors’ location and visibility status to test whether the sphere itself worked as expected.

Well I need to call them from the array, otherwise I can either do them all or only selected individuals. So ideally I could just connect up static mesh component to the array, but I can’t as “Static Mesh actor reference is not compatible with array of actor references” I’ve tried just using a get function, but that has a similar problem; the wrong type of actors.

Managed to do it by using sphere overlap components, rather than actors. works great now!