36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class Infoboard : MonoBehaviour
|
||
|
{
|
||
|
public Transform target; // The OVRCameraRig transform
|
||
|
|
||
|
public float distanceInFront = 1.5f;
|
||
|
public float heightAbove = 0.5f;
|
||
|
|
||
|
private bool placed = false;
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
if (placed) return;
|
||
|
if (target == null) return;
|
||
|
|
||
|
// Calculate the new position (1.5 units in front and 0.5 units above the ground)
|
||
|
Vector3 newPosition = target.position + target.forward * 2.5f + target.up * 0.5f;
|
||
|
|
||
|
// Set the position of this object
|
||
|
transform.position = newPosition;
|
||
|
|
||
|
// Face the target
|
||
|
transform.LookAt(target);
|
||
|
|
||
|
// Since a quad is used, you may need to adjust the rotation if it doesn't face correctly
|
||
|
transform.Rotate(Vector3.up, 180f); // Rotate by 180 degrees around the Y-axis
|
||
|
|
||
|
placed = true; // Set placed to true to ensure this only happens once
|
||
|
|
||
|
}
|
||
|
}
|