unity3D中如何还原摄像机的旋转角度?
usingUnityEngine;usingSystem.Collections;publicclassbuttonTAB:MonoBehaviour{publicGam...
using UnityEngine;
using System.Collections;
public class buttonTAB : MonoBehaviour {
public GameObject FPS;
public GameObject FPS1;
public Transform FPSpos;
public Transform EmptyPos;
public Transform CameraRot;
void Start () {
FPSpos = this.transform;
}
void Update () {
}
public void TABbutn()
{
CameraRot.localRotation = Quaternion.identity;
FPS.SetActive(true);
FPS1.SetActive(false );
FPSpos.position = EmptyPos.position;
FPSpos.rotation = EmptyPos.rotation;
}
public void TABbutn1()
{
CameraRot.localRotation = Quaternion.identity;
FPS.SetActive(false);
FPS1.SetActive(true);
FPSpos.position = EmptyPos.position;
FPSpos.rotation = EmptyPos.rotation;
}
}
我弄了两个人物控制器(代码里声明为FPS)我想通过点击一个按钮使人物控制器从第一个切换到第二个,并且位置和旋转角度都还原,切换可以,位置也能还原,就是旋转角度不能还原?请大神们指点! 展开
using System.Collections;
public class buttonTAB : MonoBehaviour {
public GameObject FPS;
public GameObject FPS1;
public Transform FPSpos;
public Transform EmptyPos;
public Transform CameraRot;
void Start () {
FPSpos = this.transform;
}
void Update () {
}
public void TABbutn()
{
CameraRot.localRotation = Quaternion.identity;
FPS.SetActive(true);
FPS1.SetActive(false );
FPSpos.position = EmptyPos.position;
FPSpos.rotation = EmptyPos.rotation;
}
public void TABbutn1()
{
CameraRot.localRotation = Quaternion.identity;
FPS.SetActive(false);
FPS1.SetActive(true);
FPSpos.position = EmptyPos.position;
FPSpos.rotation = EmptyPos.rotation;
}
}
我弄了两个人物控制器(代码里声明为FPS)我想通过点击一个按钮使人物控制器从第一个切换到第二个,并且位置和旋转角度都还原,切换可以,位置也能还原,就是旋转角度不能还原?请大神们指点! 展开
1个回答
2016-12-11
展开全部
在摄像机举含桐上绑定一个脚本,脚本里正坦:1.获取小老姿球的Transform a
2.update里写上transform.position=a.position-10*vector3.forward
纯手机打字,望采纳
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询