Going through wall

I need help in building a script for my game, I want to allow the character to be able to pass through a wall by targeting a wall using raycasting as the starting point, from that starting point make a ray or something that targets the area after the wall. Then the player walks toward the starting point and then the player gets teleported across, and able to access to and fro.

But how do I code the part where I create 2 points by targetting a wall, one on the side where the player is facing and the other side of the wall where the player is supposed to teleport across?

Here is an example of what I mean if you don’t fully understand what I am trying to do.

1| wall | 2

So when I aim at the wall and it creates the start point at 1, I want to script 2 to appear at the other side of the wall.

Once you use Physics.Raycast to identify the entry point, you can use the Collider.Raycast function (not the Physics.Raycast function) on the wall with a second ray going in the other direction. The origin point should be far enough along the original ray that it won’t be inside the wall, and the direction is negated.

create a camera and make a new layer called gun then put that camera u just created to the layer gun and put ur weapons to the layer gun and make sure that camera is on depth only and change the depth to 1 and there u go