【发布时间】:2016-11-02 22:50:41
【问题描述】:
在两点之间或仅在左侧不间断或仅在右侧不间断。
在这段代码中,我旋转了圆柱体,但我不能将它移到两侧:
using UnityEngine;
using System.Collections;
public class MakeTwoPoints3D : MonoBehaviour
{
public float speed = 10f;
public float delta = 15.5f; // Amount to move left and right from the start point
public float moveSpeed = 5.0f;
private Vector3 startPos;
void Start()
{
startPos = transform.position;
}
void Update()
{
transform.Rotate(Vector3.up, speed * Time.deltaTime);
transform.position += transform.right * Time.deltaTime * moveSpeed;
}
}
如果我进行transform.right,它会在圆周上上下移动圆柱体。如果我制作transform.up,它将向我移动它,我的意思是向前但向相机移动,但至少它会移动它。如果我再次进行transform.Forward,它将绕圈并将圆柱体向上移除。
我不知道怎么把它移到两边。
【问题讨论】:
-
transform.right有什么价值?