こっち見て〜

LookAt
VRMにこれを付ける。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VRM10LookAt : MonoBehaviour
{
public Transform target; // インスペクターでセットするターゲットオブジェクト
public Animator animator; // Animatorコンポーネントへの参照
private bool isEnabled = true; // Flag to enable or disable look-at behavior
void OnAnimatorIK(int layerIndex)
{
if (isEnabled && target != null) // ターゲットが設定されているかチェック
{
animator.SetLookAtPosition(target.position); // ターゲットの位置を設定
animator.SetLookAtWeight(1.0f, 0.8f, 1.0f, 0.0f, 0f);// ターゲットへの向きの重みを設定
}
}
public void SetEnabled(bool enabled)
{
isEnabled = enabled;
}
}
VRMに設定しているAnimatorのIKPassをオンにする

VRM10という名前にしているがHumanoidモデルだったらなんでも動いた気がする

PolySpatialのカメラ
TargetにつけるカメラをVolumeCameraにしても、実機だと原点の方向を見てしまい、こっちを見てくれない。
結論から言うと、XROriginがない場合はそれを追加して、その下のMainCameraをTargetにしたらいい

この記事スレッドが詳しい。Unboundedモードである必要もある。
https://discussions.unity.com/t/lookat-in-polyspatial/315013/6

私は今回のシーンをPolySpatialのManipulationを元に改変していたのでXROrigineがなかった。
ImageTrackingとかのサンプルシーンにはXROrigineがあるのでそれをコピーしてきて、不要なものを切り取った。
右クリックからも作れるからこれでもいいのかも

その他
「PolySpatial LookAt」でググったら、「VisionOS は通常はプライバシー保護の観点からカメラの位置をDeveloper には通知しません」と言う記事が出てきてできないのかと思い焦ったが、これはboundedモードの時だけかな?
qiita.com
あとSceneCameraはUnityEditor上だけでしか使わないのかな〜?これをTargetにしても確かLookAtしなかったはず
そういえばXROriginを追加したら、UnityEditorのGame画面でクリック操作ができなくなった。XROriginかScenecameraを非アクティブにしたら操作できる。
ScenecameraとXROrigineの下のカメラ二つあるのがいけないのかも。
おまけ 環境光を受けるVRM用シェーダー
こちらのシェーダーを使った!
qiita.com
openUPMというの初めて使った気がする。
zenn.dev
シーンにあるVRMへの適用が一発でできる方法があるのかよくわからなかったので手動でシェーダーを変えてテクスチャを付けた。

これで確かに現実の環境光の影響は受けるようになったが、シーンにあるポイントライトなどの影響は受けない・・・
ちょっと全体的に暗いので明るくしたいがどうしたらいいかわからない。

諦めてUnlitのほうがいいだろうか・・・
Unlit/TextureはいけるけどUnlit/Transparentはダメだった。

前やった時はURP/Unlitか
bibinbaleo.hatenablog.com
おまけ VRM10でのまばたき
ググった時VRM10でのまばたきスクリプトが見当たらなかったので貼っておく
using UnityEngine;
using UniVRM10; // Add this line
public class VRM10AutoBlink : MonoBehaviour
{
[SerializeField] private Vrm10Instance vrm;
private Vrm10RuntimeExpression vrm10RuntimeExpression;
private float blinkTime = 0f;
private float blinkInterval = 3f; // Interval in seconds
private float blinkIntervalMin = 2f; // Minimum interval in seconds
private float blinkIntervalMax = 5f; // Maximum interval in seconds
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
vrm10RuntimeExpression = vrm.Runtime.Expression;
blinkInterval = Random.Range(blinkIntervalMin, blinkIntervalMax); // Set initial random interval
}
// Update is called once per frame
void Update()
{
blinkTime += Time.deltaTime;
if (blinkTime >= blinkInterval)
{
Blink();
blinkTime = 0f;
blinkInterval = Random.Range(blinkIntervalMin, blinkIntervalMax); // Set next random interval
}
}
private void Blink()
{
vrm10RuntimeExpression.SetWeight(ExpressionKey.Blink, 1f);
Invoke("ResetBlink", 0.1f); // Reset blink after 0.1 seconds
}
private void ResetBlink()
{
vrm10RuntimeExpression.SetWeight(ExpressionKey.Blink, 0f);
}
}
UnityのInputFieldも概ね動いた。
視線を合わせてクリックするとOSのキーボードがちゃんと出てくる