Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[SOLVED] How to make a part point to a direction in relation to camera?

So the wind direction is a Vector3 Value on workspace. I was able to make an arrow part appear on a ViewPortFrame and it should point to the wind direction. What I am really struggling with is what the math to this would be.

I tried:

CFrame.new(currentcamera.Position,currentcamera.Position+wind.Value)

CFrame.new(currentcamera.Position+currentcamera.CFrame.lookVector,currentcamera.Position+wind.Value)

CFrame.new(Vector3.new(0,0,0),wind.Value)

CFrame.new(currentcamera.LookVector*wind.Value.Magnitude,wind.Value)

All of these resulted on an arrow that doesnt point in relation to camera lookvector or doesnt rotate at all.

1 answer

Oh I have found the answer after some thinking. Here it is: cam = viewportframe Camera wscam = workspace Camera wind = Vector3 Value representing wind script.Parent.Arrow = arrow that points

script.Parent.Arrow.CFrame = CFrame.new(Vector3.new(0,0,0),wind.Value)
	cam.CFrame = CFrame.new((workspacecam.CFrame.lookVector*-3)+script.Parent.Arrow.Position,script.Parent.Arrow.Position)

This discussion is preserved as it was. New answers, comments, and votes are closed.