Unity摄像机跟随Target快速位移和旋转
2015-10-28 10:42
489 查看
[html] view
plaincopyprint?
public Transform target;
public float distance ;
public float targetHeight;
public float PitchAngle;
private float x = 0.0f;
private float y = 0.0f;
void Start () {
var angles = transform.eulerAngles;
x = angles.x;
y = angles.y;
}
void LateUpdate ()
{
if(!target)
return;
y = target.eulerAngles.y;
// ROTATE CAMERA:
Quaternion rotation = Quaternion.Euler(x-PitchAngle, y, 0);
transform.rotation = rotation;
// POSITION CAMERA:
Vector3 position = target.position - (rotation * Vector3.forward * distance + new Vector3(0,-targetHeight,0));
transform.position = position;
}
/article/7791761.html
plaincopyprint?
public Transform target;
public float distance ;
public float targetHeight;
public float PitchAngle;
private float x = 0.0f;
private float y = 0.0f;
void Start () {
var angles = transform.eulerAngles;
x = angles.x;
y = angles.y;
}
void LateUpdate ()
{
if(!target)
return;
y = target.eulerAngles.y;
// ROTATE CAMERA:
Quaternion rotation = Quaternion.Euler(x-PitchAngle, y, 0);
transform.rotation = rotation;
// POSITION CAMERA:
Vector3 position = target.position - (rotation * Vector3.forward * distance + new Vector3(0,-targetHeight,0));
transform.position = position;
}
/article/7791761.html
相关文章推荐
- Unity3D开发一些初级问题
- Unity:镜面反射
- unity3d 虚拟现实在各行业的应用
- Unity3D 内存 释放
- Unity3d 动态读取外部文件
- unity3d 屏幕截图
- unity3d 动态改变模型大小、方向(展示必用)
- Unity3d 场景打包与加载
- unity3d 动态改变模型大小
- unity3d 资源文件从MAX或者MAYA中导出的注意事项
- Unity3d 调用外部视频
- Unity3D 自动光照 shader
- Unity 中的向量的 相关使用1
- 全面理解Unity加载和内存管理机制之二:进一步深入和细节
- Unity5中优化VR 应用的12个技巧
- (二十)unity4.6得知Ugui中国文献-------另外-InputModules
- Unity调用C++中DLL文件
- Unity3d中所有特殊的文件夹
- Unity3d中所有特殊的文件夹
- Unity3D 提高视频movie视频播放的质量