playMaker

Author Topic: First Question! How to randomly place a mesh on another mesh surface  (Read 1077 times)

WreckerPrime

  • Playmaker Newbie
  • *
  • Posts: 4
Hi!

I just started with playmaker and I'm trying to figure out how/if I can do the following.

I want to place a 'planet' (sphere) in a scene and put a mesh on a specific part of the sphere based on a color-coded texture map. So if it is red, it can place a specific resource there, or if the color is something else it places another type of resource.

Eventually, I will create random planets, but I need to have this type of control for certain planets which will be unique and require resources placed randomly along the surface in specific zones depending on the color of the resource map.

Can this be done with Playmaker?

Thanks!
« Last Edit: November 18, 2020, 11:52:14 AM by WreckerPrime »

WreckerPrime

  • Playmaker Newbie
  • *
  • Posts: 4
Re: First Question! How to randomly place a mesh on another mesh surface
« Reply #1 on: November 20, 2020, 01:31:15 AM »
Hoping an image of what I am trying to do will help!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: First Question! How to randomly place a mesh on another mesh surface
« Reply #2 on: November 20, 2020, 05:49:47 AM »
Hi.

Maybe you can find something in unity forums and place a link here.

if its possible in unity, it should be possible with playmaker (but sometimes it might need some new actions or it can be done in combination with scripts)

wetcircuit

  • Full Member
  • ***
  • Posts: 158
    • wetcircuit.com
Re: First Question! How to randomly place a mesh on another mesh surface
« Reply #3 on: November 20, 2020, 08:21:16 AM »
Playmaker can do this… but you'll need to break down each function into states and actions, and a little geometry – something you'll need to do anyway to get the game mechanic you want.

your planet can be a prefab sphere, it's radius can be the size of the planet. Object placement on the surface could be nesting the gameobject at the center of the planet, then translating it the radius until it 'rests' on the surface (or above the surface in orbit).

You might treat your planet's map as a grid and store the positions in an array, or work out a polar coordinate system, or quarternians…. Assuming your resources are procedurally generated, the same system that changes the map colors can be used to test for a hit….

Playmaker is just the nuts-and-bolts, you'll need to approach each mechanic by breaking it down into very small steps.

WreckerPrime

  • Playmaker Newbie
  • *
  • Posts: 4
Re: First Question! How to randomly place a mesh on another mesh surface
« Reply #4 on: November 20, 2020, 10:20:36 AM »
Ok, Thanks for the replies!

I will see what I can figure out but I may well need some help cause it's my first attempt at this!

Thanks!

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: First Question! How to randomly place a mesh on another mesh surface
« Reply #5 on: November 20, 2020, 04:32:25 PM »
Your assets that will be placed at random points on the surface of the globe will have their own vertical axis pointing away from the planet's center.
I haven't used that kind of experiment but an action from the Look At type could allow you to have the object properly aligned. Either you'll orient your object to have its up vector point away from the planet's center, or maybe you'll have a child that's upside down so its own up actually points towards the planet's center.
Then get the planet's radius to place the object on the globe's surface.

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: First Question! How to randomly place a mesh on another mesh surface
« Reply #6 on: November 20, 2020, 04:48:38 PM »
There's actually a component you can add to the object you're placing on the globe, it's called... Look at constraint (unbelievable). Without surprise, the blue arrow points towards the target so essentially the constrained object is upside down. You'll have to circumvent that, like for example with adding a child to this object that's pointing in the opposite direction from its parent. Or in Constraint Settings, unlock the object and put x:180 in Rotation Offset.
You may want to get the radius right first, by getting the globe's radius, using it as the distance [object to place]<->[planet center], place the object so its base touches the globe, then activate the Look at constraint (drag the component into a state and set its property), then activate and show the object.

The other hard part will require knowing how to extract the coordinates from the color map.

WreckerPrime

  • Playmaker Newbie
  • *
  • Posts: 4
Re: First Question! How to randomly place a mesh on another mesh surface
« Reply #7 on: November 22, 2020, 03:51:25 AM »
Yes, rotation of 180 or just creating the assets flipped upside down could work for visual placement, it's getting a hit on the color coordinates from the map that's the hardest part. Still wrapping my brain around it!

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: First Question! How to randomly place a mesh on another mesh surface
« Reply #8 on: November 22, 2020, 05:58:12 AM »
Obviously you need to detect colored areas first on a texture and then find a way to project the found coordinate onto the globe. But if detecting colors is complicated, then you may have to isolate them onto different black and white textures with simply alpha at full transparency used for where there's no color, and then do an alpha detection on the texture.

Perhaps also using vertex colors (or any other data associated to vertices) could help. It would probably weigh much less in resources too.