playMaker

Author Topic: Finding a child and adding a mesh filter with a specified mesh. [Solved]  (Read 1842 times)

simon

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
I have a tri-hexal tile system that switches out 6 triangular slices of a hexagon tile. The effect is a wang-tile triangle grid acting like a hex grid. It adapts itself to its neighbours for a more natural procedurally generated hex grid, this is the function I'm currently working on.

Right now my hex grid generates and I have two land types: Earth and Ocean.
The hex grid is populated, water and earth randomly generate, but now I need to program the neighboring slice behavior.

I have a lot of game objects in my scene.
I populate the scene with a diagonal staircase of game objects that are rotated to form a hex grid from top down, and that stores position data.

Next I have a list of hex tile game objects which are tied to the x and z world positions of the above game objects, thus retaining real world transformations. Meanwhile I can leverage hex cube coordinataion. Within each tile; eg land, ocean etc, there are 6 game objects representing the 6 slices of tile.

Given that there can be up to 2500 tiles, each with their own 6 slices stored as children, I want a solution that won't bump that number up by much.

I want to keep those children, without the need to replace or add to the number of game objects, so I'm trying to find the child and apply a mesh filter with a specified mesh inside. After a lot of fiddling around with every likely action, I've found no sollution.

if you don't know how I can achieve this, please let me know what you'd do to get similar results.

Warm regards,

Simon.
« Last Edit: March 31, 2018, 01:52:37 AM by simon »

Doh

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: Finding a child and adding a mesh filter with a specified mesh.
« Reply #1 on: February 16, 2018, 11:28:42 AM »
Hey, just had a little look into this.

In response to this part of your query "so I'm trying to find the child and apply a mesh filter with a specified mesh inside" I've done something that seems to answer that and taken a screen shot, it finds the child object (a cube) and turns it into a capsule. It's attached, hope it helps!


simon

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: Finding a child and adding a mesh filter with a specified mesh.
« Reply #2 on: March 07, 2018, 12:10:35 AM »
Hey, just had a little look into this.

In response to this part of your query "so I'm trying to find the child and apply a mesh filter with a specified mesh inside" I've done something that seems to answer that and taken a screen shot, it finds the child object (a cube) and turns it into a capsule. It's attached, hope it helps!

Hey Doh!

Sorry about the late reply, but thank you so much for your time and help.

Unfortunately after following your example closely and double checking, I'm not getting any new components or meshes attached to existing components.

Would you like a screenshot of my setup?

Warm regards,

Simon.

Doh

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: Finding a child and adding a mesh filter with a specified mesh.
« Reply #3 on: March 08, 2018, 05:44:31 AM »
Hey Simon, a screenshot may show something that may have been missed or incompatible, go for it.

simon

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: Finding a child and adding a mesh filter with a specified mesh.
« Reply #4 on: March 09, 2018, 06:04:41 AM »
Here's as much information as I could think to screenshot.

In case some of this doesn't make much sense I'll give some context.

This is a tri-hex grid generator. It first deals in hex grid coordinates, then it adds 6 slices that match the edges of adjoining hexagons.

Here's an example of what I'm trying to achieve in my game:

http://polycount.com/discussion/163125/polygonal-planet-project-a-unity-demo-for-your-browser

If you're familiar with the 'wang-tile' technique, it's essentially the same principle.

I need my algorithm to create meshes in real time, so it can figure out without creating a bunch of unnecessary game objects, which sectors to match. As you can see, I've started with the south western (SW) tile.

Kind regards,

Simon.

Doh

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: Finding a child and adding a mesh filter with a specified mesh.
« Reply #5 on: March 09, 2018, 08:16:16 AM »
The difference between our examples are the third action within the mesh swap state, so in mine "set object value" was used to set the value of a local variable made simply to hold that information for the 4th action "set property". If you do it exactly as I did does it work for you?

I think your "set object value" should be preparing the "mesh" variable instead of "ChildMesh".
« Last Edit: March 09, 2018, 08:19:30 AM by Doh »

simon

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: Finding a child and adding a mesh filter with a specified mesh.
« Reply #6 on: March 16, 2018, 10:34:22 PM »
Thanks Doh, I'll try that and let you know how it goes!

Kind regards,

Simon.

simon

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: Finding a child and adding a mesh filter with a specified mesh.
« Reply #7 on: March 31, 2018, 01:52:23 AM »
Yep that fixed it! The main issue was that I was trying to re-use existing variables to save space. Having a unique variable for the child seemed to fix the problem.

Thanks Doh.

Kind regards,

Simon.

Doh

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Awesome! It sounds like an interesting project, best of luck!  :D