I’m making an attack functionality which teleports you to an object that I shot out from my player.
if (facingRight)
{
GameObject tmp = (GameObject)Instantiate(Orb, rangedPos.position, Quaternion.identity);
tmp.GetComponent<Orb>().Initialize(Vector2.right);
}
else
{
GameObject tmp = (GameObject)Instantiate(Orb, rangedPos.position, Quaternion.identity);
tmp.GetComponent<Orb>().Initialize(Vector2.left);
}
This is the instantiating method which works perfectly fine. I tried to do this in the Update:
void Update()
{
if (Input.GetMouseButtonDown(0))
{
player.position = Orb.transform.position
}
}
But it just teleports me to 0.0, 0.0, 0.0 in my scene cause that’s where my original orbprefab is which is not what I want. How do I reference the Orb that I Instantiated in my Instantiating function and get its current position as its moving?