我尝试统一创建一个绳索摆动(像虚拟点一样的摆锤)机械师。但是在挥杆的第一帧,我的角色突然跳来跳去,然后又像钟摆一样继续向前和向下移动。
void InitSwing(){
lineLenght = (transform.position - virtualLinePoint).sqrMagnitude;}
public void SwingLocomotion()
{
Vector3 testPos = transform.position + jMotor.moveDirection *Time.deltaTime;
float newLenght = (testPos - virtualLinePoint).sqrMagnitude;
if (newLenght != lineLenght)
{
testPos = virtualLinePoint + (testPos - virtualLinePoint).normalized * lineLenght;
}
transform.position = testPos;
答案 0 :(得分:0)
是否可能是由于第一帧中的Time.deltaTime为0?因此,行jMotor.moveDirection *Time.deltaTime
将返回0,而testPos将等于transform.position + 0