0
\$\begingroup\$

I am attempting to connect a series of teleporters with entrances inside a single scene. Once the player touches a teleporter he is moved to another place. I am doing this by simply connecting two game objects as shown in the following screenshot. The particle system in the center of the upper side is used as teleporter, the red line indicates the game object where the player will be transported to.

A simple scene showing the connection of a teleporter to an entrance

Sadly, this results in an utter mess when attempting to select a new entrance the teleporter should link to. There is no way to guess which entrance corresponds to which side and dice:

enter image description here

So the tl;dr of my problem would be this: The name of the object that should be selected is meaningless when isolated. It's the path to the object (or in other terms: the name of some parent) that is relevant.

I would see three possibilities to solve this, but sadly I haven't gotten around to find out how to do any of them.

  1. Switch the "Select GameObject" Dialog to use the same hierarchical view as used in the scene viewer. Is there a hidden option somewhere in Unity that I overlooked?
  2. Somehow prefix the names of my entrances programatically. Is there a way to include the path to a certain game object in its name?
  3. My whole approach is backwards and I am doing something in a not Unity friendly way. But what would be the "correct" way to do this?
\$\endgroup\$
5
  • \$\begingroup\$ Maybe you should share your teleportation code here as well \$\endgroup\$
    – Ron
    Commented May 10, 2015 at 16:06
  • \$\begingroup\$ I don't see how the teleportation code would be useful here. This question (as the title states) is not about teleportation. The code itself has quite a few unique tidbits regarding the need to switch gravity, so I wouldn't think it would be helpful to anyone else. \$\endgroup\$ Commented May 11, 2015 at 13:09
  • \$\begingroup\$ Would changing the way the script works to working with handles be an option? That would remove the need to manage countless teleporter -> destination objects and will allow you to manage the destinations on the teleporter itself (you could also add in Gizmos to better display the link between them) \$\endgroup\$
    – Ron
    Commented May 11, 2015 at 14:01
  • \$\begingroup\$ Sorry, I am new to Unity. What do you mean with "handle"? \$\endgroup\$ Commented May 11, 2015 at 14:03
  • \$\begingroup\$ Handles Gizmos and you can use the position handle to achieve what you're trying to do \$\endgroup\$
    – Ron
    Commented May 11, 2015 at 19:07

1 Answer 1

1
\$\begingroup\$

You can attach custom script to any gameobject you want to use as destination call it for example TeleportDestination.

In your entry teleport script you can use public property type TeleportDestination, now unity will pops you only objects with TeleportDestination and not all gameobjects.

Note: TeleportDestination needs to be MonoBehaviour. Note 2: you can create a method in TeleportDestination for teleporting and use it with more entry types later on with same teleporting logic.

Ps: i wrote this answer on mobile. I would go deeper otherwise, sorry. Hope it helps

\$\endgroup\$
2
  • \$\begingroup\$ This would at least filter down the "Select GameObject" Dialog to nothing but entries called "Entrance". But it doesn't really solve the problem that the individual name is not meaningful, only the path to it. \$\endgroup\$ Commented May 11, 2015 at 13:00
  • \$\begingroup\$ you can drag that gameobject directly from hierarchy or you can use Vexes VFW github.com/vexe/VFW, for example use RequiredFromChildren with TeleportDestination and select its parent with meaningful name \$\endgroup\$
    – derki
    Commented May 11, 2015 at 15:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .