make one thing flat to another

im working on making a portal style mechanic that works on anything, so i need it to work on any surface, my problem is that if i shoot a portal on a surface thats at a weird angle it just looks off and awkward, how do i get the portal model i’ve made to be flat against the surface its being shot at?

TLDR : how do i get the portal model ive made to be flat against the surface its being shot at?

There is a reason why Valve allows portals only at locations that follow some rules: i.e. flat and big enough (‘white’ is not a technical reason, that is only a gameplay mechanic)…it is very difficult to make them work on arbitrary surfaces. With flat surfaces it is quite straight forward: all you need is the surface normal (and the center of the ‘tile’, so the portal doesn’t appear at a corner and sticks out of the wall)…from the top of my head I can’t think of a mechanic, that would work with curved surfaces…you could try painting the portal on the surface using projectors, and a collider to move the player to the outgoing portal, but that would probably not look or behave like the real deal…