我正在尝试使用远距传送制作一个简单的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];
}
}
外观应该相同,但位置不同。