1
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?

More than 5 years have passed since last update.

Robloxで「ジャンプ力アップ」のアイテムをつくる

Last updated at Posted at 2019-11-21

概要

image.png

image.png

プログラミング

image.png

  • Workspaceに新しくPartを追加
  • 名前をJumpBallとかにしておく
  • Scriptを追加
Script.lua
-- このScriptの親、つまりJumpBallオブジェクトを変数にいれておく
local boostPart = script.Parent
-- ジャンプ力の設定用の定数
local BOOSTED_JUMP_POWER = 125
 
local function onPartTouch(otherPart)
	-- ぶつかってきたPartの親を変数にいれておく
	-- 人間の場合、体のどこかのPartがぶつかったら、その親である人間本体のオブジェクトを変数にいれる
	local partParent = otherPart.Parent
	-- ぶつかってきたものが人間かどうかを判定
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		-- 当たり判定を無効にする
		-- ボールにぶつかったら、ボールがころころ転がらないようにするため
		boostPart.CanCollide = false
		-- あとで必要なので、「現在のジャンプ力」を変数にいれておく
		local currentJumpPower = humanoid.JumpPower
		-- 「現在のジャンプ力」が、「強化後のジャンプ力」よりも弱ければ、ジャンプ力を強くする
		-- 10秒たったら、元のジャンプ力に戻す
		if currentJumpPower < BOOSTED_JUMP_POWER then
			humanoid.JumpPower = BOOSTED_JUMP_POWER
			wait(10)
			humanoid.JumpPower = currentJumpPower
		end
	end
end

-- 何かがぶつかったらonPartTouch関数が発動
boostPart.Touched:Connect(onPartTouch)

応用

image.png

  • ゲームを起動
  • workspace内に自分のオブジェクトが登場(わたし場合はyorunegy)
  • その中にHumanoidオブジェクトがある
  • Humanoidオブジェクトをクリックしてから、画面下にある「Propertys-Humanoid....」というタブをクリック
  • この中に複数のProperty(要素)があります。JumpPowerもその1つ
  • 上記プログラミングの「JumpPower」の部分を別のProperty名に書き換えれば、違う効果をもったアイテムのできあがりです。
  • 使えるPropertyは以下を参考のこと
  • 最大HP、歩くスピード、現在のHPなどを変更できます
    image.png
1
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
1
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?