# CFrame.lookat() isn't working like it supposed to

I tried to script my first fractal (Sierpiński triangle) by using it’s rules. But something went wrong with my equations and idk what

for example if i want to create point by using lookAt and LookVector of two points and then multiply it by magnitude of these two points divided by two it’s doing something like that (example on picture)

I was already out of ideas when this happend
And i want to achieve this

It looks like you want to find the midpoint between `C` and `B`, which would be `(C + B)/2`

Which would mean the correction would be:

``````point.Position = (c + b)/2
``````

The reason why your current code doesn’t work is because a CFrame’s `LookVector` starts at the origin and not at the CFrame’s position. You can correct that by simply adding the CFrame’s position to the calculation:

``````local cframe = CFrame.lookAt(c, b)
point.Position = cframe.Position
+ cframe.LookVector
* ((c - b).Magnitude / 2)
``````
3 Likes

You don’t need to construct a CFrame value to get the look vector between two vectors. You just need to normalize the difference between the two of them: `(a - b).Unit`. But you can also just lerp between the two points too, if you’re just trying get a midpoint: `a:Lerp(b, 0.5)`, or just divide them by two like @goldenstein64 mentioned.

The reason you’re getting weird positions is probably because you’re moving things about the origin, which might not line up with where your other points are located.

4 Likes