示例
形象被抓住尾巴/耳朵时做出反应(闪光、换表情、播放音效)。用 AeloriaJiggleEventShim 订阅物理事件,只在虚拟形象沙盒里可用。
using UnityEngine;
using Cilbox;
using Aeloria.Shims;
[Cilboxable]
public class TailReaction : MonoBehaviour
{
public GameObject sparkle;
void Start()
{
GetComponent<AeloriaJiggleEventShim>();
}
void OnJiggleGrab(int playerId, bool began, int hand, int rigIndex)
{
sparkle.SetActive(began);
}
void OnJiggleTouch(int playerId, bool began, int hand, int rigIndex) { }
}
playerId)、是否开始抓(began)、哪只手(hand)、哪根骨骼/rig(rigIndex);OnJiggleTouch 是”碰到但没抓住”,做”摸头”反应用它;AeloriaAvatarShim.IsOwnedLocally 过滤(见「虚拟形象脚本」)。