0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Roblox】プレイヤーの足音の調整

Posted at

はじめに

プレイヤーの足音を消す方法と、床の材質によって足音を切り替える方法です。

前回、プレイヤーが歩いている時に土埃のエフェクトを出しました。
土埃エフェクトも実装する場合は、前回記事をご参照ください。


環境
Roblox Studio: バージョン 0.704.0.7041059

👣 足音を消す

StarterPlayer > StarterPlayerScripts の RbxCharacterSounds を編集します。
ただし、このファイルはプレイを開始すると現れ、プレイを終了するとなくなります。
プレイ中にファイルをコピーし、プレイ終了後 StarterPlayerScripts にペーストして書き換えます。
Running の SoundId = ""

RbxCharacterSounds の抜粋

local SOUND_DATA : { [string]: {[string]: any}} = {
    --(略)
	Running = {
        SoundId = "",
		-- SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3",
		Looped = true,
		Pitch = 1.85,
	},
    --(略)
}

参考動画:How to Disable Footsteps in Roblox Studio

👣 床の材質によって足音を変える

StarterPlayer > StarterCharacterScripts に、LocalScript を作成します。

Material と アセットID の組み合わせを作ります。(MATERIAL_SOUNDS)
プレイヤーの立っている床の材質(FloorMaterial)と対応するアセットIDを、 RunningSoundId にセットします。

FootstepSound(LocalScript)

local hum = script.Parent:WaitForChild("Humanoid")
-- 材質ごとの足音
local MATERIAL_SOUNDS = {
	[Enum.Material.Grass] = "(アセットID)",  --rbxassetid://7003103812
	[Enum.Material.Metal] = "(アセットID)", --rbxassetid://78580994772675
	[Enum.Material.Rock] = "(アセットID)",  --rbxassetid://84528173233317
	[Enum.Material.Wood] = "(アセットID)", --rbxassetid://89597871459985
}

-- 走っているときの足音の変更
local footstepSound = script.Parent:WaitForChild("HumanoidRootPart"):WaitForChild("Running")
local defaultFootstepSoundId = "rbxasset://sounds/action_footsteps_plastic.mp3"
local function updateFootstepSound(id, speed, vol)
	footstepSound.SoundId = id
	footstepSound.PlaybackSpeed = speed
	footstepSound.Volume = vol
end

while true do
	wait()
	
	local soundId = MATERIAL_SOUNDS[hum.FloorMaterial]
	if soundId then
		updateFootstepSound(soundId, 1.0, 0.5)	
	else
		updateFootstepSound(defaultFootstepSoundId, 1.0, 0.5)	
	end
end

公式ドキュメント:Engine API - Humanoid.FloorMaterial

参考動画:How to make FOOTSTEP sounds in Roblox Studio!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?