You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
60 lines
1.3 KiB
3 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class ArrowControl : MonoBehaviour {
|
||
|
|
||
|
bool flag = false;//判断如何移动
|
||
|
private void Start()
|
||
|
{
|
||
|
transform.localScale *= 0.666666666666666f;
|
||
|
if (transform.parent.name.Contains("xia")|| transform.parent.name.Contains("Down"))
|
||
|
{
|
||
|
flag = true;
|
||
|
transform.localScale *= -1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
private void FixedUpdate()
|
||
|
{
|
||
|
// transform.LookAt(Camera.main.transform);//时刻看向摄像机
|
||
|
ObjMove();
|
||
|
}
|
||
|
bool transDir = false;
|
||
|
void ObjMove()
|
||
|
{
|
||
|
if (flag)
|
||
|
{
|
||
|
if (transform.localPosition.z > -7)
|
||
|
{
|
||
|
transDir = true;
|
||
|
}
|
||
|
if (transform.localPosition.z < -9)
|
||
|
{
|
||
|
transDir = false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (transform.localPosition.z > -7)
|
||
|
{
|
||
|
transDir = true;
|
||
|
}
|
||
|
if (transform.localPosition.z <-9)
|
||
|
{
|
||
|
transDir = false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
if (transDir)
|
||
|
{
|
||
|
transform.localPosition -= new Vector3(0, 0, 0.2f);
|
||
|
}
|
||
|
else {
|
||
|
transform.localPosition += new Vector3(0, 0, 0.2f);
|
||
|
}
|
||
|
}
|
||
|
}
|