전방으로 이동하여 매초마다 프리 프레임을 생성하는 gameobject가 있습니다. 유일한 문제는 산란이 고르지 않은 것처럼 보이고 때로는 물체가 멀리 떨어져 있고 때로는 겹쳐지는 경우도 있습니다. 나는 spawntime과 거리를 변경함으로써 이것을 해결할 수 있지만, ios에서 테스트했을 때 다시 깨졌습니다.프리폼을 움직이고 생성하는 GameObject
다른 객체에서 게임 객체를 밀어내는 스크립트를 만들려고했으나 객체를 밀어내어 다른 객체와 다른 객체에 쳤습니다.
내가 할 수 있기를 원하는 것은 spawner가 앞으로 나아가고 prefab이 겹치지 않도록 prefab을 내려 놓는 것입니다. 나는 이걸로 일할 필요가있어. 여기
using UnityEngine;
using System.Collections;
public class SpawnScript : MonoBehaviour {
public GameObject[] obj;
//public float spawnMin = 1;
//public float spawnMax = 1;
//public float spawnDistance = 0.1f;
//private float barDisplay = 3;
public float timeLeft = 0.1f;
static bool finishTimer = false; //i made this global so you can access from other scripts
static bool timerStarted = false;
//private GameObject GroundSpawner;
// Use this for initialization
void Start() {
timerStarted = true;
}
void Update(){
Timer();
transform.Translate(Vector3.forward * 0.1f);
}
void Timer(){
if (timerStarted == true) {
timeLeft -= Time.deltaTime;
if (timeLeft <= 0.0f) {
Spawn();
timerStarted = false;
}
}
}
void Spawn(){
//GroundSpawner = GameObject.Find ("Ground Spawner");
//if (GroundSpawner.transform.position) {
//Invoke ("Spawn", Random.Range (spawnMin, spawnMax));
Invoke ("Spawn", 1.75f);
Instantiate (obj [Random.Range (0, obj.Length)], transform.position, Quaternion.identity);
// }
}
}
이 땅이 다른 게임 오브젝트 스크립트에서 추진하고 : 인스턴스화 팹 사이
using UnityEngine;
using System.Collections;
public class GroundHittingSelf : MonoBehaviour {
// Use this for initialization
void Start() {
}
// Update is called once per frame
void Update() {
}
void OnCollisionEnter(Collision other) {
Debug.Log("Hitting Ground without tag");
if (other.gameObject.tag == "Ground") {
//transform.position += new Vector3(0, 0, 0.1f);
Debug.Log("Hitting Ground with tag");
}
}
}
음, 정확히 무엇을 하려는지 이해할 수 없으므로 3.0f가됩니다. 귀하의 질문에 이미지 (스크린 샷)를 게시 할 수 있습니까? –