How do I make an item that will work like an eraser?

I would like to make a mop that will remove dirt from the walls like an eraser does in Paint. Maybe there is some kind of guide that explains how to do this, or if it’s not difficult for you, explain it to me yourself. Please help me, I just can’t imagine how to do it.

are you working in C++ or blueprints?

do you plan to be looking at the thing to be “erased” as you are erasing it, or are you planing to “select an amorphous region”

if you just want to “erase” the thing that is being looked at in a circumference.

  • I will being making the assumption that you are working with some kind of decal, and not trying to modify an Objects->materials->texture in real time (this is a lot more specialized)

if these decals are SceneComponents on an actor (if they were actors themselves you could run into some of the practical limits of actor counts) then you can:

  • do a sphereTraceByChannel from the Camera (excluding the player character (for 3rd person, and if there are to be other characters in the world)
  • test that SphereTraceByChannel against the Actors that should have your decals (so if these are walls/floors that will not be moving then WorldStatic, if these walls/floors will be moving around then test against WorldDynamic
  • out of the HitResultBreakStruct the Other Components go into a For each try to Cast them to the decal component (remember to do an IsValid before accessing I like the one that has the 2 output execution pins it will have the “?” in the suggestion box), and on success “Do something with the component”
    • destroy the component
    • change the appearance of the decal like if they need to “clean it multiple times” to get rid of it (please have some kind of counter to keep track of)

one thing you can do with this approach is if you want to see if “everything is clean” or a given percent. you can hold all of the Actors that will have the component in an array, and then every so often (in blueprints use a delay into the check) to walk through the array, and see if all of the components still exist. this might be a bit more book keeping (the actor keeps track of how many “things” it started with, or how many decals there were for example) then you just do a little math for percentage and you have the “% cleaned”

1 Like

In case that is not the case:

Since you can paint, you can erase the paint, too.

1 Like