top of page

TOSHICHAN
Unityでスクリプト&簡単な実装サイト
指定した軸をオブジェクトに向ける
public Transform Target;
public float Speed = 0.1f;
void Update ()
{
Vector3 targetPos = Target.transform.position;
// ターゲットのY座標を自分と同じにすることで2次元に制限する。
targetPos.y = transform.position.y;
transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation (targetPos - transform.position),Speed);
}
bottom of page