I want to spawn an object at a cloned gameobjects 4 gameobjects positions. My code right now will spawn 4 watermelon_split object at the watermelon clone, but not at the watermelon_split1 position or watermelon_split2 and etc.
![alt text][1]
[1]: /storage/temp/52213-new-pic.png
using UnityEngine;
using System.Collections;
public class attackTrigger : MonoBehaviour {
public GameObject watermelon;
public GameObject watermelon_split;
public Transform watermelon_split1;
public Transform watermelon_split2;
public Transform watermelon_split3;
public Transform watermelon_split4;
void OnTriggerEnter2D(Collider2D col)
{
if(col.isTrigger != true && col.CompareTag("watermelon"))
{
Instantiate(watermelon_split, col.transform.position, watermelon_split1.rotation);
Instantiate(watermelon_split, col.transform.position, watermelon_split2.rotation);
Instantiate(watermelon_split, col.transform.position, watermelon_split3.rotation);
Instantiate(watermelon_split, col.transform.position, watermelon_split4.rotation);
Destroy(col.gameObject);
}
}
}
↧