Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411433 Posts in 69363 Topics- by 58418 Members - Latest Member: Pix_RolleR

April 20, 2024, 07:20:57 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Artist using Unity w/ Playmaker, help with implementing code
Pages: [1]
Print
Author Topic: Artist using Unity w/ Playmaker, help with implementing code  (Read 828 times)
Harpeaux
Level 0
**


A Pixel Infant


View Profile WWW
« on: May 18, 2016, 10:14:49 PM »

So I'm slowly teaching myself Unity with zero coding experience, and I'm trying to implement Krabl Mesh Processors on a randomly generated mesh.

According to the documentation, SubdivideQuadsMesh can do exactly what I want. However, I don't know how to implement it. I'd like to either set it in a Playmaker event of my choosing, or just attach it to the prefab as a component.

Any help is greatly appreciated!
Logged
oahda
Level 10
*****



View Profile
« Reply #1 on: May 19, 2016, 12:45:45 AM »

It's a function. You need to call it. I don't know how Playmaker works, and if it's possible to select the function from a list to have it executed at the right time (I know other parts of Unity do allow this sort of stuff, for example UI button events). If not, you need to call it from a script. Can you choose to run a function from a script or something in Playmaker?

Hopefully someone who actually knows how to use Playmaker will show up and help you properly, but those are some hints in the meantime, at least.
Logged

Harpeaux
Level 0
**


A Pixel Infant


View Profile WWW
« Reply #2 on: May 19, 2016, 12:55:30 AM »

Playmaker can definitely run a script (when i want to call on it), but I think the biggest problem I'm having is what goes in the "unityMesh" area.

Currently, the script would need to be

Code:
static void KrablMeshUtility.SubdivideQuadsMesh	(unityMesh, 1, true)

But I don't know how to point it at the mesh specifically, especially since the mesh is dynamically generated.
Logged
bdsowers
Level 3
***



View Profile WWW
« Reply #3 on: May 19, 2016, 07:44:30 AM »

Even if the mesh is dynamically generated, you should have a Mesh object somewhere. Unity uses Mesh to represent 3D geometry: http://docs.unity3d.com/ScriptReference/Mesh.html

At some point during your dynamic mesh generation, one of those should've been created. But without knowing more about your setup, it's hard to say where or how to get at it. If you're trying to modify an object with a MeshRenderer and MeshFilter, which I'd say is likely (?), the MeshFilter points at a Unity Mesh. So if in your script you have *that* object, you can say:
Code:
Mesh unityMesh = objectWithMeshFilter.GetComponent<MeshFilter>().mesh;

You have some other issues (which are very, very common among new programmers):
Your understanding of how to actually use a function is a bit off. You wouldn't say
Code:
static void KrablMeshUtility.SubdivideQuadsMesh (unityMesh, 1, true)

When actually using a function, you don't include the "static void" portion. It would look like this:
Code:
KrablMeshUtility.SubdivideQuadsMesh (unityMesh, 1, true);


Knowing how Unity handles 3D meshes is in some ways trickier than the coding portion.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic