Last active
September 28, 2023 19:18
-
-
Save hobione2k/79f791b5ff0671935a47c0bd8e9e9737 to your computer and use it in GitHub Desktop.
ClusterScipt Beta DOGEZA検出サンプル
This file contains 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
// プレイヤー検出用コライダーにOverlap Detector Shapeコンポーネントを付けること | |
// アイテムの中心(原点)が床の高さであること | |
const dedupPlayer = (players) => | |
players.filter((p, i) => players.findIndex((p2) => p2.id == p.id) === i); // 重複排除 | |
$.onUpdate((deltaTime) => { | |
// プレイヤーを取得 | |
const overlaps = $.getOverlaps(); | |
const players = dedupPlayer( | |
overlaps.map((o) => o.object.playerHandle).filter((p) => p != null) | |
); | |
const itemPos = $.getPosition(); | |
let dogezaLevel = 0; // DOGEZA人数 | |
players.forEach((p) => { | |
const headPos = p.getHumanoidBonePosition(HumanoidBone.Head); | |
const headHeight = headPos.y - itemPos.y; // アイテム原点からの距離(位置調整用) | |
if (headHeight < 0.3) dogezaLevel += 1; // 頭の位置が0.3m未満なら土下座判定+1 | |
}); | |
$.setStateCompat("this", "dogezaLevel", dogezaLevel); // dogezaLevelトリガー(Integer) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment