回复 那些空白的梦 :using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
public GameObject A;
public GameObject B;
Vector3 lastPosition_A = Vector3.zero;
float speed = 0.1f;
// Use this for initialization
void Start ()
{
lastPosition_A = A.transform.position;
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown(KeyCode.A))
{
A.transform.position += Vector3.left*speed;
}
if(lastPosition_A.x > A.transform.position.x)
{
B.transform.position += Vector3.left*speed;
A.SetActive(false);
}
}
}
这是我刚刚写的,你拿去试试。