Hi there,
I’m trying to instantiate an object relative to a prefab’s position. So within the script attached to the prefab, I setup the function below. Problem is that the instantiated prefab is not being instantiated at the right position.
I’ve used a similar script for another prefab and it’s working fine. Anyone have any idea why this is the case?
void CreateEnemySpeech()
{
//instantiate speech
GameObject instEnemySpeech = Instantiate (EnemySpeech, new Vector3(transform.localPosition.x, transform.position.y+200, transform.localPosition.z), transform.rotation) as GameObject;
instEnemySpeech.transform.SetParent (BattleCanvas, false);
EnemySpeechText = EnemySpeech.GetComponent<EnemySpeechContainer> ();
EnemySpeechText.EnemySpeech.text = "text";
Destroy (instEnemySpeech, 4f);
}