Positioning part in front of another part RELATIVE to Camera

As the title dictates, I need to position a part relative to two factors, an origin and where it is relative to.

bild.

If some people are aware of the mesh bug, where you can emulate the very same effect by inversing a mesh’s normals, this gave birth to the trend of these UGC crations:

Of course, now it is pretty simple to do for a part, you can just inverse a part’s rotation matrix, and add a smaller part inside and it would look something like this:

So what’s the issue? Well this is the issue!
bild
The blue outline isn’t hidden when the inner part is intersecting the outer and why this is an issue is that it makes it difficult to stack these parts together.

I am no good with math! Although, I’d guess the logic would be look something like whitePart.CFrame = CFrame.new(bluePart.Position * Camera.CFrame.LookVector * Camera.CFrame.Position) ← Obviously not going to work

For people interested of its use-case, I am currently making a custom lightning module with TypeScript and it looks something like this

You seem to make the problem harder than it is. The direction to move the part from the base part’s position is just the camera’s LookVector. Have the inverted object spawn, like you do now, at the base part’s origin. Then, bound to RenderStepped, move the part a few units in the the direction of:

(basePart.Position - camera.CFrame.Position).unit

1 Like

This is the effect I got.

local invertedPart = workspace.inv
local origin = invertedPart.Position

local rs = game:GetService("RunService")
local cam = workspace.CurrentCamera

rs:BindToRenderStep("tate", 201, function()
	local direction = (invertedPart.Position - cam.CFrame.Position).unit
	invertedPart.CFrame = CFrame.fromMatrix(origin + direction, Vector3.new(1,0,0), Vector3.new(0,1,0), Vector3.new(0,0,-1))
end)
2 Likes

Well, invertedPart is the inverted part.

Here’s the place file to make it easier. invertedPartClipping.rbxl (21.5 KB)

I’ve tried implementing the solution and it appears that it is quite expensive and I am unsure of how to apply the correct rotation now. https://gyazo.com/6c47654cd35386a7ef0e8d1486f4ec91

Yeah, there’s not much I can go off of based on a video unfortunately. But in concept, your lightning movements plus a render stepped second-pass movement would be expensive on it. You’d definitely need to integrate it into the first-pass (what causes the lightning to spawn and move in the first place) to avoid double-dipping on the rendering.

Unfortunately I can’t help further without code or a reproduction.