良好的周日足球下午大家, 我的问题是我在Unity中有一个球员控制器,我正在创建,球员应该以圆周运动向左或向右移动。好吧,我创造了这个,但是我很难找到如何让玩家围绕固定的周围移动,最终会改变。 这是我到目前为止,和代码的作品。 C#,统一,使用球体。如何调整球员围绕周围的运动
//editable property
float timeCounter = 0;
public float speed;
void Start()
{
//Called at the start of the game
speed = 1;
}
void Update()
{
timeCounter += Input.GetAxis("Horizontal") * Time.deltaTime * speed; // multiply all this with some speed variable (* speed);
float x = Mathf.Cos(timeCounter) ;
float y = Mathf.Sin(timeCounter) + 6;
float z = 0;
transform.position = new Vector3(x, y, z);
}
void FixedUpdate()
{
//Called before preforming physics calculations
}
}
所以玩家已经是在y(6)周围移动一个非常小的圆圈,并且我试图让这个圆圈成为一个变量,随着等级的进展可以改变这个变量,可以操纵圆周来增加玩家的移动范围。 –