Unity中,我想点击一下后,摄像机飞到目标位置(EmptyGameObject),途中完成自身旋转的角度和目标一样
Unity中,我想点击一下后,摄像机飞到目标位置(EmptyGameObject),途中完成自身旋转的角度和目标一样,现在实现了飞过去,但是不会旋转。求各位大神帮帮忙啊u...
Unity中,我想点击一下后,摄像机飞到目标位置(EmptyGameObject),途中完成自身旋转的角度和目标一样,现在实现了飞过去,但是不会旋转。求各位大神帮帮忙啊
using UnityEngine;
using System.Collections;
[AddComponentMenu("NGUI/Interaction/Center Scroll View on Click")]
public class One1 : MonoBehaviour {
public Transform mc;
public Transform mt;
float speed = 30f;
float distance2 = 30f;
Vector3 destPos;
float pitch = 0;
float yaw = 0;
public bool Click = false;
void Start ()
{
destPos = new Vector3();
Click = false;
}
// Update is called once per frame
void Update ()
{
if (!Click)
{
return;
}
if (Click)
{
mc.transform.position = Vector3.MoveTowards(mc.transform.position,mt.position,speed*Time.deltaTime);
//
if (mc.transform.position == mt.position)
{
Debug.Log("begin");
// mc.transform.Rotate(new Vector3(0, 0, -50), Time.deltaTime * 200);
//mc.transform.rotation = mt.transform.rotation;
Debug.LogError("go on");
Click = false;
Debug.Log("end");
}
}
}
void OnClick()
{
Click = true;
}
} 展开
using UnityEngine;
using System.Collections;
[AddComponentMenu("NGUI/Interaction/Center Scroll View on Click")]
public class One1 : MonoBehaviour {
public Transform mc;
public Transform mt;
float speed = 30f;
float distance2 = 30f;
Vector3 destPos;
float pitch = 0;
float yaw = 0;
public bool Click = false;
void Start ()
{
destPos = new Vector3();
Click = false;
}
// Update is called once per frame
void Update ()
{
if (!Click)
{
return;
}
if (Click)
{
mc.transform.position = Vector3.MoveTowards(mc.transform.position,mt.position,speed*Time.deltaTime);
//
if (mc.transform.position == mt.position)
{
Debug.Log("begin");
// mc.transform.Rotate(new Vector3(0, 0, -50), Time.deltaTime * 200);
//mc.transform.rotation = mt.transform.rotation;
Debug.LogError("go on");
Click = false;
Debug.Log("end");
}
}
}
void OnClick()
{
Click = true;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询