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

How to face object towards an object with CFrame?

I want to rotate an object towards something but I have little knowledge on whatever math is required to do it in CFrame. There is a simple way which is however said by the wiki to be deprecated where you use CFrame(object1, object2) but now its recommended to use CFrame.fromMatrix. However, I don't know how to utilize CFrame.fromMatrix correctly.

I presume that LookVector will be used or a unit vector.

--example variables (aka probably use this in ur answer to help me)

local object1 = workspace.Object1
local object2 = workspace.Object2

If you can answer, please explain any math behind it if you can! Should be easy to answer.

1 comment

0

I actually made a module that contains this function. Check it out here: https://devforum.roblox.com/t/libraries-a-library-extension-module/409035

1 answer

The wiki does say that it is deprecated, however you can use something similiar

object1.CFrame =CFrame.new(object1.Position,object2.Position)

to make object1 face towards object2's position.

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