# playMaker

### Author Topic: help with getting a random point on the diameter of a round object  (Read 1624 times)

#### cel

• Junior Playmaker
• Posts: 96
##### help with getting a random point on the diameter of a round object
« on: March 14, 2013, 12:07:54 AM »
I'm trying to get a random point on the edge of a round object (cylinder), how can this be done with playmaker?

#### Vallar

• Junior Playmaker
• Posts: 90
##### Re: help with getting a random point on the diameter of a round object
« Reply #1 on: March 14, 2013, 04:35:49 AM »
Hello,

Honestly, I haven't found any actions regarding areas or circumference of an object.
However, I think if you place the cylinder object then surround its perimeter with empty game objects add the game objects to a pool and then select randomly and apply your logic to that object it might convey the same effect.

For example:
1- Create cylinder object.
2- Create empty Game Objects located around the Cylinder cirumference.
3- Create an int variable and feed an Int Random action the minimum 1 and the maximum as the total number of the empty Game Objects and check include maximum.
4- Whenever a number is chosen you pick the game object related to it.
5- Apply your logic to that point.

Hope that helps.

#### Red

• Hero Member
• Posts: 563
##### Re: help with getting a random point on the diameter of a round object
« Reply #2 on: March 15, 2013, 11:33:55 AM »
Hello,

Honestly, I haven't found any actions regarding areas or circumference of an object.
However, I think if you place the cylinder object then surround its perimeter with empty game objects add the game objects to a pool and then select randomly and apply your logic to that object it might convey the same effect.

For example:
1- Create cylinder object.
2- Create empty Game Objects located around the Cylinder cirumference.
3- Create an int variable and feed an Int Random action the minimum 1 and the maximum as the total number of the empty Game Objects and check include maximum.
4- Whenever a number is chosen you pick the game object related to it.
5- Apply your logic to that point.

Hope that helps.

I like the approach but setting that up might be a little more time-consuming than is feasible (since as far as i can tell, OP wants to select a completely random spot... so, having the entire object crusted with empty gameObjects might be a real nightmare.)

Something that might help, it isn't completely random as this is driven by the verticies on the object but a system set up with the "Get vertex count" and a "random int" set to limit itself to the number of verticies that the "Get vertex count" sends off (this would have to be with a mesh, the collider wouldn't give you the results you need) and from there, you can feed the random int value you've generated to the "Get vertex position" action in the "Vertex index" slot to then feed that position into a vector3 variable that you can then work with... and with the vertex position action, you can tell it to use either world or local space.

it isn't true random either because it is dependant on the verticies in the mesh object... but if you have a modeling package you can make a capsule with, you can easily modify it to make the mesh much more dense (just be careful, the denser the mesh, the more processing power it's going to take to use it, even if it isn't visible to the camera, it's still going to be visible to the system.)

If you want a truly random, that's going to be tricky and i don't think PlayMaker is set up with the right kinds of actions i think would be needed. The process that my imagination is coming up with would need you to find a random vertice, finding the polygon that it controls, aligning the object to match the normal of the polygon, offsetting it's position locally in the x/y axis but ensuring that that offset is constrained by the positional data that that polygon is constrained by.

but the other method i mentioned might help you out there (and it doesn't need the mesh-renderer or collider component to work, it just needs the mesh data... so, even with a very high-density mesh to work with, you can shave down the processer power needed by removing those two components from the object you want to use this with.)