I made a wall that the player can place on the ground. The wall should be a post when it is alone and when other walls are placed next to it, the walls will automatically connect. how can I do this?
There are a number of ways that you can do this.
I made a similar system for a game jam where when you place two fence posts one grid tile apart from each other, the wiring for the fence would automatically connect them. Basically you have a placeable post actor that, when spawned (when you place it on the grid point) it fires a trace along the X and Y axes, and if the trace returns a hit with a component match (comparing against your wall post) it should spawn a wall there.
You can then set up the wall piece to expand outward based on its x or y scale if you set up its origin point and forward rotation correctly, so based on where you return a hit, i.e. on the positive/negative x/y axis, you would rotate your wall mesh to face the right direction, and then scale it along its forward axis to fill the gap, depending on what grid size you’d like to use.
Here is a video showing it in action, please let me know if you have questions, I may be able to extract the build code for this for you to review if necessary.