1:调用Debug.drawLine或者Debug.drawRay运行的时候没有显示出来画的线段,原因:game scene选项没有启用Gizmos
?2: 在调用射线监测的时候,目标layerMask应该是
Physics.Raycast(playerPos,dir,10f,1 << LayerMask.NameToLayer("Environment"));
而不是?Physics.Raycast(playerPos,dir,10f, LayerMask.NameToLayer("Environment"));
3:朝向一个目标看:
Vector3 newDir = Vector3.zero;
if(dir == DIRECTION.Right || dir == DIRECTION.Left) {
if(isGrounded) {
newDir = Vector3.RotateTowards(transform.forward, Vector3.forward * -(int)dir, rotationSpeed * Time.deltaTime, 0.0f);
} else {
newDir = Vector3.RotateTowards(transform.forward, Vector3.forward * -(int)dir, jumpRotationSpeed * Time.deltaTime, 0.0f);
}
transform.rotation = Quaternion.LookRotation(newDir);
currentDirection = dir;
}
|