1 (edited by Thibault 2018-10-24 19:20:22)

Topic: Mesh created at runtime, attached to a 3D marker, strange behavior

Hi

I made a prefab (named "frustum") with an empty Gameobject containing a script, which create a mesh. This mesh is displaying properly in a regular empty scene.

I attached this prefab as a child to another prefab which i am using as a 3D marker in my scene with the map.

It doesn't display properly (see the GIF below).

I believed at first that i didn't code properly the mesh creation (particularly the normals) but i made a test : 
If i manually add the frustum prefab in my scene at runtime, and make it a child of my 3D marker prefab manually, it display properly.

See the Gif below:
you will first see the "frustum" prefab not displaying properly.
Then i disable it and enable the "frustum2" prefab (that i manually added at runtime)
you will see that there is no problem with this one.

https://media.giphy.com/media/5w2ejH86o … /giphy.gif

You will find the script of the mesh creation attach to this message, though i don't think it is the problem anymore.

So one solution i have is problably to instantiate the frutum prefab separatly and assign it as a child of my drone prefab via script, but i would prefer to keep it as a part of the drone prefab if it is possible. Do you have any idea of what could occur this strange behavior ?

Post's attachments

Attachment icon FakeCamFrustum.cs 3.95 kb, 78 downloads since 2018-10-24 

Re: Mesh created at runtime, attached to a 3D marker, strange behavior

Hello.

I looked at your gif many times ... and I have no idea why this is happening.
If you send your project to us (support@infinity-code.com) I will be able to test it and tell you the exact cause of the problem.
Unfortunately, in this case, only using gif I can not do it.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Mesh created at runtime, attached to a 3D marker, strange behavior

So the problem was that i forgot to call "Mesh.RecalculateBounds"

https://docs.unity3d.com/ScriptReferenc … ounds.html

The documentation says "Assigning triangles automatically recalculates the bounding volume." which is why i usually don't call this function when i'm creating meshes at runtime. But in this case i'm modifying vertices after having set the triangles.

I feel stupid but it works properly now smile