Last active
October 15, 2023 13:50
-
-
Save hobione2k/39e882ef36e35f621a8829060577a115 to your computer and use it in GitHub Desktop.
ClusterScript Beta アイテムをプレイヤーにくっつける(Item直接)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// インタラクトしたユーザーの頭にアイテムをくっつける | |
$.onInteract((player) => { | |
$.state.targetPlayer = player; | |
}); | |
const attachToPlayer = (player, bone, offset) => { | |
const bonePosition = player.getHumanoidBonePosition(bone); | |
const boneRotation = player.getHumanoidBoneRotation(bone); | |
const position = bonePosition.add(offset.clone().applyQuaternion(boneRotation)); | |
$.setPosition(position); | |
$.setRotation(boneRotation); | |
}; | |
$.onUpdate((deltaTime) => { | |
const player = $.state.targetPlayer; | |
if(player!=null && player.exists()) { | |
attachToPlayer(player, HumanoidBone.Head, new Vector3(0, 0.5, 0)); // 対象プレイヤー、頭ボーン、オフセットを指定 | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment