c# - 向对象添加表示方向的向量
问题描述
我正在尝试使用传送制作一个简单的 VR 运动脚本。我用三个空GameObjects
来生成 Quadratic BezzierCurve
。p0
是GameObject
内线球员;它随着播放器移动。我的问题是点(Gameobject
s)与玩家无关。当p0
在 position0, 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];
}
}
它应该看起来一样,但在其他位置。
解决方案
推荐阅读
- angular - 如何关闭除 ngb-accordion Angular 2 Release 6 中的第一个面板之外的所有面板
- javascript - 通过第三方组件将参数从父级传递给子级
- node.js - SMTP 服务器收不到邮件
- google-apps-script - Google表格脚本while循环帮助
- angular - Angular - 无法从 api 获取数据
- python - 在 Python 中将字符串转换为链表
- ckeditor - CKEditor 只从粘贴的文本中删除样式属性
- java - JAXB 从列表解组到 HashMap
- tensorflow - 张量流模型中批处理通道在 1 个输入前向传递中的用途
- angular - 保证可观察的订阅在继续下一个代码之前完成