エンジンクラス
RunService
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
方法
BindToRenderStep(name: string,priority: number,function: function):() |
BindToSimulation(function: function,frequency: Enum.StepFrequency,priority: number):RBXScriptConnection |
GetPredictionStatus(context: Instance):Enum.PredictionStatus |
Pause():() |
Reset():() |
Run():() |
SetPredictionMode(context: Instance,mode: Enum.PredictionMode):() |
Stop():() |
UnbindFromRenderStep(name: string):() |
イベント
Heartbeat(deltaTime: number):RBXScriptSignal |
Misprediction(time: number,instances: {any},stats: Dictionary):RBXScriptSignal |
PostSimulation(deltaTimeSim: number):RBXScriptSignal |
PreAnimation(deltaTimeSim: number):RBXScriptSignal |
PreRender(deltaTimeRender: number):RBXScriptSignal |
PreSimulation(deltaTimeSim: number):RBXScriptSignal |
RenderStepped(deltaTime: number):RBXScriptSignal |
Rollback(time: number):RBXScriptSignal |
Stepped(time: number,deltaTime: number):RBXScriptSignal |
APIリファレンス
プロパティ
方法
BindToRenderStep
戻り値
()
コードサンプル
円を描くフレームの移動
local RunService = game:GetService("RunService")
-- フレームの移動速度
local SPEED = 2
local frame = script.Parent
frame.AnchorPoint = Vector2.new(0.5, 0.5)
-- (0.5, 0.5)を中心とし、半径(0.5)の円の単純なパラメトリック方程式
local function circle(t)
return 0.5 + math.cos(t) * 0.5, 0.5 + math.sin(t) * 0.5
end
-- 現在の時間を追跡
local currentTime = 0
local function onRenderStep(deltaTime)
-- 現在の時間を更新
currentTime = currentTime + deltaTime * SPEED
-- ...フレームの位置を更新
local x, y = circle(currentTime)
frame.Position = UDim2.new(x, 0, y, 0)
end
-- これは視覚効果だけなので、「Last」優先度を使用
RunService:BindToRenderStep("FrameCircle", Enum.RenderPriority.Last.Value, onRenderStep)
--RunService.RenderStepped:Connect(onRenderStep) -- これも機能しますが、お勧めしませんRunService カスタム関数
local RunService = game:GetService("RunService")
local function checkDelta(deltaTime)
print("最後のレンダー ステップからの経過時間:", deltaTime)
end
RunService:BindToRenderStep("デルタチェック", Enum.RenderPriority.First.Value, checkDelta)関数のバインドとアンバインド
local RunService = game:GetService("RunService")
-- ステップ 1: 関数と名前を宣言する
local NAME = "こんにちはを印刷"
local function printHello()
print("こんにちは")
end
-- ステップ 2: 関数をバインドする
RunService:BindToRenderStep(NAME, Enum.RenderPriority.First.Value, printHello)
-- ステップ 3: 関数のバインドを解除する
RunService:UnbindFromRenderStep(NAME)BindToSimulation
RunService:BindToSimulation(
パラメータ
| 既定値: "Hz30" |
| 既定値: 2000 |
コードサンプル
パーツの色プロパティの同期
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local somePart:BasePart = Workspace:WaitForChild("Part")
RunService:BindToSimulation(function(deltaTime: number)
local syncdColor = Color3.fromHSV(math.fmod(time(), 1.0), 1.0, 1.0)
somePart:SetAttribute("SyncdColor", syncdColor)
end)
RunService.RenderStepped:Connect(function(deltaTime: number)
local syncdColor = somePart:GetAttribute("SyncdColor")
somePart.Color = syncdColor
end)GetPredictionStatus
パラメータ
Pause
RunService:Pause():()
戻り値
()
Reset
Run
RunService:Run():()
戻り値
()
SetPredictionMode
パラメータ
戻り値
()
Stop
RunService:Stop():()
戻り値
()
イベント
Misprediction
パラメータ
PostSimulation
Stepped