# Humanoid（ロブロックス クラス）

> キャラクターの「体の動き」と「体力」を管理するクラスです。歩く速さ・ジャンプ・体力・やられたときのイベントなどを扱います。

- URL：https://roblox.minecraft-okinawa.com/reference/classes/Humanoid/
- 公式：https://create.roblox.com/docs/reference/engine/classes/Humanoid
- 受け継いでいるクラス：Instance

## 使用例：ふれたプレイヤーを倒すブロック（キルブロック）

（Script／置く場所：パーツの中）

```lua
local part = script.Parent :: BasePart

part.Touched:Connect(function(hit)
	local character = hit.Parent
	if not character then
		return
	end
	local humanoid = character:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end)
```

## 使用例：参加したプレイヤーの歩く速さを変える

（Script／置く場所：ServerScriptService）

```lua
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid") :: Humanoid
		humanoid.WalkSpeed = 32
	end)
end)
```

## プロパティ

- `Humanoid.AutoJumpEnabled: boolean`：Sets whether the character will automatically jump when they hit an obstacle as a player on a mobile device.
- `Humanoid.AutomaticScalingEnabled: boolean`：When Enabled, AutomaticScalingEnabled causes the size of the character to change in response to the values in the humanoid's child scale values changing.
- `Humanoid.AutoRotate: boolean`：AutoRotate sets whether or not the Humanoid will automatically rotate to face in the direction they are moving in.
- `Humanoid.BreakJointsOnDeath: boolean`：Determines whether the humanoid's joints break when in the HumanoidStateType.Dead state.
- `Humanoid.CameraOffset: Vector3`：An offset applied to the Camera's subject position when its CameraSubject is set to this Humanoid.
- `Humanoid.DisplayDistanceType: HumanoidDisplayDistanceType`：Controls the distance behavior of the humanoid's name and health display.
- `Humanoid.DisplayName: string`：Sets the text of a Humanoid, displayed above their head.
- `Humanoid.EvaluateStateMachine: boolean`：Used to disable the internal physics and state machine of the Humanoid.
- `Humanoid.FloorMaterial: Material`：Describes the Material that the Humanoid is currently standing on. If the Humanoid isn't standing on anything, the value of this property will be _Air_.
- `Humanoid.Health: float`：今の体力。0になると、キャラクターがやられます。
- `Humanoid.HealthDisplayDistance: float`：Used in conjunction with the Class.Humanoid.DisplayDistanceType|DisplayDistanceType property to control the distance from which a humanoid's health bar can be seen.
- `Humanoid.HealthDisplayType: HumanoidHealthDisplayType`：Controls when the humanoid's health bar is allowed to be displayed.
- `Humanoid.HipHeight: float`：Determines the distance off the ground the Humanoid.RootPart should be.
- `Humanoid.Jump: boolean`：If true, the Humanoid jumps with an upwards force.
- `Humanoid.JumpHeight: float`：ジャンプの高さ（UseJumpPowerがfalseのとき）。
- `Humanoid.JumpPower: float`：ジャンプの強さ（UseJumpPowerがtrueのとき）。
- `Humanoid.MaxHealth: float`：体力の最大値。初期値は100です。
- `Humanoid.MaxSlopeAngle: float`：The maximum slope angle that a humanoid can walk on without slipping.
- `Humanoid.MoveDirection: Vector3`：Describes the direction that the Humanoid is walking in.
- `Humanoid.NameDisplayDistance: float`：Used in conjunction with the Humanoid.DisplayDistanceType property to control the distance from which a humanoid's name can be seen.
- `Humanoid.NameOcclusion: NameOcclusion`：Controls whether a humanoid's name and health bar can be seen behind walls or other objects.
- `Humanoid.PlatformStand: boolean`：Determines whether the Humanoid is currently in the HumanoidStateType.PlatformStanding state.
- `Humanoid.RequiresNeck: boolean`：Allows developers to disable the behavior where a player Character|character dies if the Neck Motor6D is removed or disconnected even momentarily.
- `Humanoid.RigType: HumanoidRigType`：Describes whether this Humanoid is utilizing the legacy R6 character rig, or the new R15 character rig.
- `Humanoid.RootPart: BasePart`：A reference to the humanoid's HumanoidRootPart object.
- `Humanoid.SeatPart: BasePart`：A reference to the seat that a Humanoid is currently sitting in, if any.
- `Humanoid.Sit: boolean`：Describes whether the Humanoid is currently sitting.
- `Humanoid.TargetPoint: Vector3`：Describes the 3D position where the Player controlling the Humanoid last clicked in the world while using a Tool.
- `Humanoid.UseJumpPower: boolean`：Determines whether the Class.Humanoid.JumpHeight|JumpHeight (false) or Humanoid.JumpPower (true) property is used.
- `Humanoid.WalkSpeed: float`：歩く速さ。初期値は16です。
- `Humanoid.WalkToPart: BasePart`：A reference to a part whose position is trying to be reached by a humanoid.
- `Humanoid.WalkToPoint: Vector3`：The position that a humanoid is trying to reach, after a call to Class.Humanoid:MoveTo() is made.

## メソッド

- `Humanoid:AddAccessory(accessory: Instance): ()`：Attaches the specified Accessory to the humanoid's parent.
- `Humanoid:ApplyDescriptionAsync(humanoidDescription: HumanoidDescription, assetTypeVerification: AssetTypeVerification): ()`：Makes the character's look match that of the passed in HumanoidDescription. If HumanoidDescription.UseAvatarSettings is true, the Avatar Settings for the experience will also be applied to the character.
- `Humanoid:ApplyDescriptionResetAsync(humanoidDescription: HumanoidDescription, assetTypeVerification: AssetTypeVerification): ()`：Makes the character's look match that of the passed in HumanoidDescription, even after external changes.
- `Humanoid:BuildRigFromAttachments(): ()`：Assembles a tree of Motor6D joints by attaching together Attachment objects in a humanoid's character.
- `Humanoid:ChangeState(state: HumanoidStateType): ()`：Sets the Humanoid to enter the given HumanoidStateType.
- `Humanoid:EquipTool(tool: Instance): ()`：Makes the Humanoid equip the given Tool.
- `Humanoid:GetAccessories(): Array`：Returns an array of Accessory objects that the humanoid's parent is currently wearing.
- `Humanoid:GetAppliedDescription(): HumanoidDescription`：Returns a copy of the humanoid's cached HumanoidDescription which describes its current look.
- `Humanoid:GetBodyPartR15(part: Instance): BodyPartR15`：Pass a body part to this method (the body part should be a sibling of Humanoid, and a child of a Model) to get the BodyPartR15 of the Part.
- `Humanoid:GetLimb(part: Instance): Limb`：Returns the Limb enum that is associated with the given Part.
- `Humanoid:GetMoveVelocity(): Vector3`：Returns the current intended movement velocity of the Humanoid.
- `Humanoid:GetRelativeVelocityAtFloor(): Vector3`：Returns the humanoid's actual physical velocity relative to the surface it is standing on as a Vector3 in world-space orientation.
- `Humanoid:GetState(): HumanoidStateType`：Returns the humanoid's current HumanoidStateType.
- `Humanoid:GetStateEnabled(state: HumanoidStateType): boolean`：Returns whether a HumanoidStateType is enabled for the Humanoid.
- `Humanoid:Move(moveDirection: Vector3, relativeToCamera: boolean): ()`：Causes the Humanoid to walk in the given direction.
- `Humanoid:MoveTo(location: Vector3, part: Instance): ()`：指定した場所へ歩いて移動させます。
- `Humanoid:PlayEmoteAsync(emoteName: string): boolean`：Plays emotes and returns if was successfully ran.
- `Humanoid:RemoveAccessories(): ()`：Removes all Accessory objects worn by the humanoid's parent.
- `Humanoid:ReplaceBodyPartR15(bodyPart: BodyPartR15, part: BasePart): boolean`：Dynamically replaces a Humanoid body part with a different part.
- `Humanoid:SetStateEnabled(state: HumanoidStateType, enabled: boolean): ()`：Sets whether a given HumanoidStateType is enabled for the Humanoid.
- `Humanoid:TakeDamage(amount: float): ()`：体力を減らします（バリアなどで守られているときは減りません）。
- `Humanoid:UnequipTools(): ()`：Unequips any Tool currently equipped by the Humanoid.

## イベント

- `Humanoid.ApplyDescriptionFinished(description: HumanoidDescription)`：Fires when a HumanoidDescription has finished being applied to the Humanoid.
- `Humanoid.Climbing(speed: float)`：Fires when the speed at which a Humanoid is climbing changes.
- `Humanoid.Died()`：キャラクターがやられたときに発生するイベントです。
- `Humanoid.FallingDown(active: boolean)`：Fires when the Humanoid enters or leaves the FallingDown HumanoidStateType.
- `Humanoid.FreeFalling(active: boolean)`：Fires when the Humanoid enters or leaves the Freefall HumanoidStateType.
- `Humanoid.GettingUp(active: boolean)`：Fires when the Humanoid enters or leaves the GettingUp HumanoidStateType.
- `Humanoid.HealthChanged(health: float)`：体力が変わったときに発生するイベントです。
- `Humanoid.Jumping(active: boolean)`：Fires when the Humanoid enters and leaves the Jumping HumanoidStateType.
- `Humanoid.MoveToFinished(reached: boolean)`：Fires when the Humanoid finishes walking to a goal declared by Class.Humanoid:MoveTo().
- `Humanoid.PlatformStanding(active: boolean)`：Fires when the Humanoid enters or leaves the PlatformStanding HumanoidStateType.
- `Humanoid.Ragdoll(active: boolean)`：Fires when the Humanoid enters or leaves the Ragdoll HumanoidStateType.
- `Humanoid.Running(speed: float)`：Fires when the speed at which a Humanoid is running changes.
- `Humanoid.Seated(active: boolean, currentSeatPart: BasePart)`：Fired when a Humanoid either sits in a Seat or VehicleSeat or gets up.
- `Humanoid.StateChanged(old: HumanoidStateType, new: HumanoidStateType)`：Fires when the state of the Humanoid is changed.
- `Humanoid.StateEnabledChanged(state: HumanoidStateType, isEnabled: boolean)`：Fires when Class.Humanoid:SetStateEnabled() is called on the Humanoid.
- `Humanoid.Strafing(active: boolean)`：Fires when the Humanoid enters or leaves the StrafingNoPhysics HumanoidStateType.
- `Humanoid.Swimming(speed: float)`：Fires when the speed at which a Humanoid is swimming in Terrain water changes.
- `Humanoid.Touched(touchingPart: BasePart, humanoidPart: BasePart)`：Fires when one of the humanoid's limbs come in contact with another BasePart.

英語の説明とメンバー一覧：Roblox Creator Documentation（CC BY 4.0）。日本語の解説はこのサイト独自のものです。

執筆：鈴木孝昌（現役プロジェクトマネージャー／プログラミング講師）／運営：沖縄マイクラ部 プログラミングスクール「クロスウェーブ」（https://minecraft-okinawa.com/）