Я пытаюсь сделать простой скрипт движения VR, используя телепортацию.Я использовал три пустых GameObjects
, чтобы сгенерировать из них квадратичный BezzierCurve
.p0
- это GameObject
внутри проигрывателя;это движется с игроком.Моя проблема в том, что очки (Gameobject
s) не относятся к игроку.Когда p0
находится в положении 0, 0, 0
, скрипт работает нормально;но когда я подключаю его к игроку и перемещаю игрока по сцене, эти очки не относятся к игроку.Я думаю, что напутал с некоторыми базовыми вещами.
using UnityEngine;
public class settingPos : MonoBehaviour
{
public Transform tf;
public GameObject p0, p1, p2;
// 3 empty GameObjects to paste them into QuadraticBezzier Script which uses it for
// generate bezzier curve. p0 is gameObject inside player, it is moving with player
public float UpForce; //simply value for scaling Bezzier curve
Vector3 [] dir= new Vector3[2];
void Update ()
{
dir[0] = p0.transform.position;
Vector3 temp = transform.rotation * Vector3.forward;
temp *= UpForce;
dir[0] += temp;
dir[1] = new Vector3(dir[0].x * 2, 0, dir[0].z * 2); // This is end point of bezzier
// curve. I mentioned that
// distance between end-point
// and height of bezzier curve
// was this same as start-point
// and height.
p1.transform.position = dir[0];
p2.transform.position = dir[1];
}
}
Довольно короткий
Это должно выглядеть так же, но в другой позиции.
Это показывает мою проблему