I know it is slow to update a mesh collider, that is not a problem.
I was using this code in a 2.5 project before I moved it to iphone 1.5. It still works in 2.5, just checked. Is there a reason the following code would not update a meshcollider at runtime?
(Mesh.collider as MeshCollider).sharedMesh = Mesh.mesh;
Works on 2.5 but not 1.5… any ideas? I kinda really need this to work no matter how slow it is
I also found that removing the mesh collider. waiting and then adding it back, still has the original mesh not an updated mesh.
Destroy(GameObject.collider as MeshCollider);
yield WaitForSeconds(5);
GameObject.AddComponent(MeshCollider);
I found this quite undesireable :?
Shouldn’t it add a mesh collider which corresponds to the current mesh at the time it is added?
I tried the method in this thread:
http://forum.unity3d.com/viewtopic.php?t=32554
The code works to find the hit on a mesh without a collider, but it doesn’t work for what I need.
I am procedurally modifying the mesh at runtime and require the meshcollider to be periodically updated.
From what I can tell collider.shareMesh is accepting the updated positions from the original mesh, but they are not actually being transferred over to the collider, they are merely in sharedMesh. Is there a way to apply it?
Is it a bug that collider.sharedMesh does not actually alter the collider’s geometry? Considering it worked in 2.5 and doesn’t in iphone 1.5
I use a mesh terrain with a mesh collider and have not discovered any problems with it “out of the box”.
When you say that you ‘procedurally modifying the mesh at runtime’, can you tell me more about what you are doing?
I was changing scale and other attributes via scripting, and the mesh collider worked fine. On the other hand, my mesh terrain was usually pushing 7k tri for the mesh alone, and it could take a measurable number of seconds to update on the iPhone, so I had to be very careful how I did it to prevent any hitch in the user experience.
I have a sphere on screen and move verts around via script. If you think of the sphere as a globe and add a mountain to it, then touching the mountain’s peak will not be caught by a raycast.
The sphere collider is remaining a sphere and not updating to the new shape of the mesh even though I am asking it to.
Unity themselves provide a very good example here:
Under Sculpt Vertices
In their example, if the mesh is altered, that is:
if (filter != unappliedMesh)
Then apply the mesh to the mesh collider:
function ApplyMeshCollider () {
if (unappliedMesh unappliedMesh.GetComponent(MeshCollider)) {
unappliedMesh.GetComponent(MeshCollider).mesh = unappliedMesh.mesh;
}
unappliedMesh = null;
}
I have tweaked the code around over and over again and the collider remains the same shape. However on my desktop (2.5 still haven’t tried 2.6)… it works fine.
I have also found that the problem is found in these threads and remains unresolved:
http://forum.unity3d.com/viewtopic.php?p=66253&sid=f4ac960e38fab0aee5eb32956395cfb0
http://forum.unity3d.com/viewtopic.php?p=215908
So I have discovered that my code works fine in Unity 2.6, so the problem is only for the Unity iphone.
Could we please have meshCollider updating put in for unity iphone 1.5.1, I know it’s slow but I don’t see any other way of tackling this problem.
If anyone has got meshCollider’s to update on the iphone please let me know how it was achieved.
If I can get time on the box, I’ll compare what I’m doing with the info you’ve posted, and see if any of that helps.
When it comes to 1.5.1 - this release is VERY imminent. I believe there is a thread that indicates they are in the RC phase of 1.5.1. Have you filed this as abut report to get it into the system?
I made another thread about it. I also noted that the report a problem does not work in unity iphone 1.5, so i reported the bug in unity 2.6
It would be extremely detrimental if this was not in iphone 1.5.1, I hope it makes it in
Humm… My report a problem very definitely works in iPhone 1.5. I use it a lot (mostly to report issues in the docs…OCD on my part usually).
Just to rule out the issue… have you done a reinstall on 1.5? Are you sure it’s clean? And have you tried to replicate this in a new empty project?
Just stabs in the dark before I go to bed.
I’ll take a peek on the morrow…
Reinstall didn’t help. Maybe it’s a SL issue?
Can someone try this in a iphone 1.5 and tell me if the meshCollider updates after the mesh is sculpted.
It is just an iphone version of procedural examples → sculpt vertices
Using the same package on:
Unity desktop - allows you to continually pull the vertices out as much as you want as the meshCollider updates.
Unity iphone - the meshCollider does not update, this results in minimal mesh manipulation until it cannot be moved anymore.
221497–8035–$sculptvertices_134.unitypackage (138 KB)
Dam still no downloads… I guess I’m just anxious to see if it’s my code at fault or if this is just not possible at the moment with iphone 1.5
If this is read by anyone from UT, I know 1.5.1 is real close, but it would be great if I could get any confirmation of whether or not this functionality will be available in the next update?
I have a pretty big project that I would love to be able to complete in 1.5.1 as this is vital to it. Otherwise it will need to be shelved until we see it come in.
I have posted a bug report and asked about this issue in multiple threads and have no idea if it’s a problem with my code or if its missing functionality.
Wow I feel like a clown bumping this but could someone try it our for me and see if it works for them
Sorry. Just did not get any time today. But I did download it. Too much time on the stump trying to hawk the new game… I’ll try again tomorrow.