Hi, I've made a basic teleport script for my game, and I'd like to use the teleporting "portals" as a magic spell in my game (create one, then create another somewhere further to be able to go back and forth instantly).
Here is my code for the teleporters:
This works just fine by dragging the first portal prefab to other's destination in the inspector, and vice versa. However, for my magic spell, I need to instantiate the two portals. For the instantiated clones however, the destination variables of the Teleporter script are not assigned, and they won't work, of course. Just to be clear, here's a video of the problem: http://www.youtube.com/watch?v=nfcUxn9DipM&feature=youtu.be
In any case, to 'link' the portals the way you want to, you need to use GetComponent or instantiate casting on the newly created instances.
This way, the two teleporters will automatically link to each other when they have both been created!
answered Jan 07 '12 at 03:53 AM