Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411489 Posts in 69371 Topics- by 58428 Members - Latest Member: shelton786

April 24, 2024, 02:37:50 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Adding objects to the Hierarchy
Pages: [1]
Print
Author Topic: Adding objects to the Hierarchy  (Read 765 times)
badrobit
Level 0
**



View Profile
« on: October 02, 2016, 11:38:42 AM »

I have recently started work on a project that will create planets using isospheres and my work has started using this: http://catlikecoding.com/unity/tutorials/octahedron-sphere/. They are creating properly but I do not see the objects showing up in the hierarchy and I would also like for each of the faces in the spheres to also show up as sub-items of each of the planets.

Does anyone have any idea on how to do this?
Logged
projecteterna
Level 0
*


View Profile
« Reply #1 on: October 02, 2016, 09:28:33 PM »

Can you give more details about not showing in the hierarchy? If the scene is running in the editor, and the object exists, I believe it should be in the hierarchy view. I don't think you'll ever see the faces though. Those are only vertex and index data in the MeshFilter component on the object. They aren't objects themselves.
Logged
badrobit
Level 0
**



View Profile
« Reply #2 on: October 03, 2016, 08:51:44 AM »

Unfortunately, I cannot at the moment but in watching some of Quill18's tutorials https://www.youtube.com/playlist?list=PLbghT7MmckI4_VM5q3va043FgAwRim6yX I think I figured out that I am only creating the mesh and not assigning it to a game object.

Is this something that I would have to do in order to have it show up in the Hierarchy?
Logged
projecteterna
Level 0
*


View Profile
« Reply #3 on: October 03, 2016, 03:05:01 PM »

The mesh will never show in the scene hierarchy. Only the GameObjects do. But if you select the GameObject, then in the inspector you can see the MeshFilter component, and one of that component's properties is the mesh. It doesn't get more granular than that in the editor.
Logged
badrobit
Level 0
**



View Profile
« Reply #4 on: October 03, 2016, 03:23:49 PM »

so how would I go about doing it if I want the sphere (planet) to be the game object and the faces that make up the planet (triangles) to be sub-objects that can be interacted with like a tile in Civ5?
Logged
projecteterna
Level 0
*


View Profile
« Reply #5 on: October 03, 2016, 08:49:46 PM »

They won't be sub objects. You can change the appearance of a triangle by changing its vertex colors, or the UVs.

Also keep in mind that you can use raycasting to find out which triangle is being interacted with.
Logged
badrobit
Level 0
**



View Profile
« Reply #6 on: October 03, 2016, 08:53:13 PM »

Would it be possible to have them created as sub-objects? In terms of ease of access later on when a player wants to interact with a selected tile.

Thanks for the tip about the vertex colours I will give that a shot Smiley
Logged
bateleur
Level 10
*****



View Profile
« Reply #7 on: October 04, 2016, 02:19:38 AM »

It's possible to have the triangles as sub-objects, but then the icosphere won't be a single Mesh. The reason being, a MeshFilter is a Component and like any Component it therefore belongs to exactly one object (having been created and assigned simultaneously via AddComponent).

The question of how to design the system you want is quite a subtle one and you have lots of options, so I'd recommend planning ahead quite a bit to work out what you'll need later. For example, one approach I might consider if doing this would be for the icosphere to be a single Mesh and to use a single GameObject for it, but then to add a separate GameObject for each face as well. This makes it easy to attach complex behaviours to each face separately and attach other graphical elements as children, etc.
Logged

badrobit
Level 0
**



View Profile
« Reply #8 on: October 04, 2016, 06:18:47 AM »

If I were to follow your suggestion (which is how I think I would like to do it) would updating each face also update the icosphere that they belong to?

Ideally like you said I want the faces of the icosphere to be as much their own game object as possible as the user will be able to perform a wide variety of actions on or with them and having them be their own game object I think would make this as simple as possible down the road.
Logged
bateleur
Level 10
*****



View Profile
« Reply #9 on: October 05, 2016, 12:00:15 AM »

Updating the icosphere wouldn't automatically do anything to the faces. On the other hand, if you adopt this approach you probably wouldn't want to modify the icosphere itself. The purpose of that mesh is mainly to position all the faces correctly. Having done that you can then use each triangle as the basis for a face, which is then a separate object.

If you parent each face GameObject (or rather its Transform) to the icosphere object then any motion of the icosphere will automatically keep the faces in place. Your actual gameplay code (Colliders, raycasts, graphics, etc.) can then work entirely with faces and never interact directly with the icosphere.
Logged

projecteterna
Level 0
*


View Profile
« Reply #10 on: October 05, 2016, 06:05:18 AM »

You can also make the parent an empty GameObject with no mesh. Then, each face is a child GameObject with a mesh, which is just one triangle. You can still do raycasting or whatever else.
Logged
badrobit
Level 0
**



View Profile
« Reply #11 on: October 05, 2016, 08:40:37 AM »

Thank you, everyone, for all your help! Thanks to you I now have a clear vision of what I want to do and an even clearer understanding that I am not ready for this yet No No NO

In case anyone is interested here is my new plan:

1. Create a simpler version of this using a flat 2D plane, I think doing things in 3D is messing with my head.
2. Work out all the mechanics I want the system to have on that (This should transfer to the 3D version).
3. Update the 2D version to use 3D once everything is flushed out.

As everyone always says about game dev, it's all about baby steps. I think it's time for me to step back and take a few of my own!
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic