void Update ()
{
target = GameObject.Find("new_offer");
// 滚轮设置
相机与人物的距离.
if(Input.GetAxis("Mouse ScrollWheel") != 0)
{
theDistance = theDistance + Input.GetAxis("Mouse ScrollWheel") *
Time.deltaTime * ScrollKeySpeed;
}
// 鼠标中间滚动得到的值是不确定的,不会正好就是0,或
-10,当大于0时就设距离为0,小于MaxDistance就设置为MaxDistance
if(theDistance>0)
{
theDistance = 0;
}
if(theDistance < MaxDistance)
{
theDistance = MaxDistance;
}
transform.position =
target.transform.position;
SetDistance();
}
void Start
()
{
if (rigidbody)
{
rigidbody.freezeRotation =
true;
transform.position = target.transform.position;
}
}
//设置相机与人物之间的距离
void SetDistance()
{
transform.Translate(Vector3.forward * theDistance);
}
请问,运行时发现摄像头只是上下移动,并不实现拉近后退的效果,这是为什么?
慕哥9229398
相关分类