CFrame Point to Roblox

Posted on

CFrame or Coordinate Frame is the term to call the data type used to rotate and position 3D objects. As the object property or the standalone unit, this one contains global X, Y, and Z coordinates as well as rotation data for each axis. In addition, it contains helpful functions for working with objects in the 3D space.

There are three basic things about CFrame. Aside from positioning the CFrame, rotating the CFrame, and offsetting the CFrame, there is also facing toward the point. The ability to point the front surface of the CFrame at the certain point in the world is one of the most powerful uses of CFrame. You can consider the example that places the thing called redBlock part at 0, 3, 0 and then points its front surface at the blueCube part.


Another thing related to CFrame is dynamic CFrame orientation. By themselves, both CFrame.new() and CFrame.Angle() constructors are powerful even though they are also very strict. All of them are able to simply position or rotate the object at the certain orientation within the world. It might be useful in some cases, but what if you cannot rely on the fixed world position and rotate angle such as placing the floating treasure directly in front of the player who may be standing anywhere in the world, facing any direction or making the magical genie appear directly above the right shoulder of the player? In those cases mentioned before, the CFrame functions such as the relative position, the relative rotation, facing the specific surface toward the point, and funding the point between points are far more powerful than the strict constructors.

These following paragraphs will uncover about both facing the specific surface toward a point and finding a point between points. According to the official website of Roblox Developer, you are able to make the object look at another object by supplying the Vector3 point as the second parameter of CFrame. Actually, this one can be limiting, however, since the operation is associated with the front face of the object.

Fortunately, you are able to use relative rotation in order to make any face of the object point toward the Vector3 point. Here is the example that you can consider that performs two consecutive CFrame operations. The first one is to point the front surface at the target and the second one is to rotate the CFrame to make the top surface point toward the target.

By using the method known as linear interpolation, which is known as lerp, you are able to position the CFrame between two points. For example, the code positions the redBlock part directly between the greenCube and cyanCube parts, using the value of 0.7 to place it 70% of the distance away from the green cube. All the pointers have to get you started on orienting objects in the game world through CFrame constructors and functions. For further information about CFrame point to Roblox, please visit the official website of Roblox Developer.

Leave a Reply

Your email address will not be published. Required fields are marked *