我写了一个脚本来旋转立方体,但是听起来好像在空气中旋转立方体或当它撞上楼梯时(由带有立方体碰撞器的立方体制成)有某种空气阻力。
我尝试了以下代码,但是在此之前,我使用了addTorque,但这也行不通:
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
input = false;
StartCoroutine("moveLeft");
}
void moveLeft()
{
Vector3 moveDirection = Vector3.left;
Vector3 pivot = Player.transform.position;
pivot += moveDirection * 0.5f;
pivot -= Vector3.up * 0.5f;
Vector3 axis = Vector3.forward;
float degrees = 90;
StartCoroutine(FlipOverEdge(degrees, pivot, axis));
}
IEnumerator FlipOverEdge(float degrees, Vector3 pivot, Vector3 axis)
{
int frames = 12;
float degreesPerFrame = degrees / (float)frames;
for (int i = 1; i <= frames; i++)
{
Player.transform.RotateAround(pivot, axis, degreesPerFrame);
yield return new WaitForFixedUpdate();
}
input = true;
}
多维数据集应该像下面的视频中那样旋转: