I’m trying to achieve a teleport effect.
I want to instantiate a Sword at a “fire point” in front of the player when they press a button. And then when they press another button, the player should teleport to where the Sword currently sits.
I have this at the beginning of my script.
public GameObject swordObject;
public Transform firePoint;
So when I press a button, it calls the first method:
GameObject swordObj = Instantiate(swordObject, firePoint.transform.position, Quaternion.identity);
And then when I press another button, it calls the second method:
(This is where the teleport should happen).
I separated the methods so that I could call them at specific times during an animation.
How would I be able to reference the instantiated Sword’s position in the second method so that I can teleport my player there? I just need to be able to reference the position of the instantiated object from a different method. Thanks.