请帮忙把unity的update函数的每行代码都注释一下
publicfloatmovementSpeed=6.0f;//小球运动的速率privateVector3horizontalMovement;//小球水平运动//这里理...
public float movementSpeed = 6.0f;//小球运动的速率
private Vector3 horizontalMovement;//小球水平运动
//这里理解为小球前后运动
private Vector3 verticalMovement;
void Update()
{
horizontalMovement = Input.GetAxis("Horizontal") * Vector3.right * movementSpeed;
verticalMovement = Input.GetAxis("Vertical") * Vector3.forward * movementSpeed;
Vector3 movement = horizontalMovement + verticalMovement;
rigidbody.AddForce(movement, ForceMode.Force);
} 展开
private Vector3 horizontalMovement;//小球水平运动
//这里理解为小球前后运动
private Vector3 verticalMovement;
void Update()
{
horizontalMovement = Input.GetAxis("Horizontal") * Vector3.right * movementSpeed;
verticalMovement = Input.GetAxis("Vertical") * Vector3.forward * movementSpeed;
Vector3 movement = horizontalMovement + verticalMovement;
rigidbody.AddForce(movement, ForceMode.Force);
} 展开
1个回答
2014-06-23
展开全部
horizontalMovement = Input.GetAxis("Horizontal") * Vector3.right * movementSpeed;
verticalMovement = Input.GetAxis("Vertical") * Vector3.forward * movementSpeed;
分别获取横竖轴上的移动量×右或者前×速度;(就是你的输入对小球的影响)
Vector3 movement = horizontalMovement + verticalMovement;
把2个分量相加,算出总的
rigidbody.AddForce(movement, ForceMode.Force);
然后小球受到一个大小方向为movement的力
verticalMovement = Input.GetAxis("Vertical") * Vector3.forward * movementSpeed;
分别获取横竖轴上的移动量×右或者前×速度;(就是你的输入对小球的影响)
Vector3 movement = horizontalMovement + verticalMovement;
把2个分量相加,算出总的
rigidbody.AddForce(movement, ForceMode.Force);
然后小球受到一个大小方向为movement的力
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询