CFrameValue

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

一个容器对象为单个 CFrame 值。

代码示例

This code sample creates a CFrameValue whose Value is set to the camera's current CFrame. This CFrame can be later recalled back into the camera's CFrame.

Store the Camera's CFrame

-- Create a CFrame that stores the camera's current position/orientation
local vSnapshot = Instance.new("CFrameValue")
vSnapshot.Value = workspace.CurrentCamera.CFrame
vSnapshot.Name = "Snapshot"
vSnapshot.Parent = workspace
-- Later, we can load the CFrame back into the camera
workspace.CurrentCamera.CFrame = vSnapshot.Value

属性

Value

读取并联

用于保持一个 CFrame 值。

方法

活动

Changed

每当 CFrameValue.ValueCFrameValue 被更改时,都会发射。它将运行在新值被存储在参数对象中,而不是代表正在更改的属性的字符串。

这个事件,像其他更改的事件一样,可以用来跟踪 CFrameValue 何时发生变更,以及它可能更改的不同值。

例实例,这甚至可能在依赖 CFrameValues 来跟踪游戏对象 CFrame 位置和运动的游戏中有用。

相同类型的更改事件存在于类似对象,例如 NumberValueStringValue,根据需求选择最适合的对象类型。

参数

value: CFrame

更改后的新值。


代码示例

这个例子每次更改时打印 CFrameValue 的新值。

CFRameValue.Changed

local cframeValue = script.Parent.CFrameValue
cframeValue.Changed:Connect(print)
cframeValue.Value = CFrame.new(1, 2, 3)