Commit 20fbfe1d authored by wanqing's avatar wanqing

场景预制体

parent 322067c6
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CheeseView : MonoBehaviour
{
public Transform m_rotateTrans;
public Transform m_rotateTarget;
private float m_speed = 200.0f;
private float m_time = 0.0f;
private float m_radius = 0.0f;//半径
private float m_angled;
private float m_posX1 = -0.4f;
private float m_posX2 = -0.3f;
private float m_posX3 = -0.2f;
private bool m_bControl1 = true;
private bool m_bControl2 = true;
private bool m_bFinish = false;
// Start is called before the first frame update
void Start()
{
Vector3 varVec3 = m_rotateTrans.localPosition;
varVec3.x = m_posX1;
m_rotateTrans.localPosition = varVec3;
m_radius = 0.4f;
//Invoke("DelayPos2", 1.0f);
}
void DelayPos2()
{
Vector3 varVec3 = m_rotateTrans.localPosition;
varVec3.x = m_posX2;
m_rotateTrans.localPosition = varVec3;
m_radius = 0.3f;
Invoke("DelayPos3", 1.0f);
}
void DelayPos3()
{
Vector3 varVec3 = m_rotateTrans.localPosition;
varVec3.x = m_posX3;
m_rotateTrans.localPosition = varVec3;
m_radius = 0.2f;
Invoke("DelayFinish", 1.0f);
}
void DelayFinish()
{
//m_bFinish = true;
}
// Update is called once per frame
void Update()
{
m_angled += (m_speed * Time.deltaTime) % 360;//累加已经转过的角度
float posX = m_radius * Mathf.Sin(m_angled * Mathf.Deg2Rad);//计算x位置
float posZ = m_radius * Mathf.Cos(m_angled * Mathf.Deg2Rad);//计算y位置
m_rotateTrans.localPosition = new Vector3(posX, 0, posZ) + m_rotateTarget.localPosition;//更新位置
if(m_rotateTrans.localPosition.x <= -0.4f && m_bControl1)
{
m_bControl1 = false;
Debug.LogError("aa");
}
//m_time += Time.deltaTime;
//if (m_time > 1.0f && m_time <= 2.0f)
//{
// if(m_bControl1)
// {
// m_bControl1 = false;
// }
//}
//else if (m_time > 2.0f && m_time <= 3.0f)
//{
//}
//if(!m_bFinish)
//{
// m_rotateTrans.RotateAround(m_rotateTarget.position, transform.up, m_speed);
//}
}
}
fileFormatVersion: 2
guid: 2d99a7fe465cdfa4b85f5c040265762b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: d6d07649d17d6fa41b33735705fd6bb8
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment