- Home /
Set anchor point for procedural mesh?
How can I set the anchor point of a procedural mesh to its centre?
I need to rotate it around its centre and I'm having trouble doing it any other way.
I haven't worked that much with procedural meshes in Unity before, so is there any easy way to do this?
Answer by Owen-Reynolds · Oct 23, 2013 at 11:49 PM
Just like a mesh made in an editor, the anchor point (pivot point) is automatically where-ever (0,0,0) is. If you built it with Y always 0 or more, the pivot is on the bottom. Build it with Y running from -5 to 5, same for X and Z, the pivot will be centered.
Since it's your mesh, you could recenter it by finding the low/high X values, average them, and subtract from X of each vert (to put the center at 0.) Or just guesstimate and toss in a loop to add (??, ??, ??) to each of your verts. This is the equivalent of, in the modelling program, grabbing all the verts (not the model,) and dragging it a bit.
Or just use the parent trick, same as any other mesh.
Hi, thanks for the response. Earlier I had tried subtracting the lowest values(All are above 0) and the average of the difference between the lowest and highest values. I managed to get the anchor point at around the bottom-left corner.
What is the parent trick by the way?
Suppose the lowest y is 10 and the highest is 25. That's a total length of 15, so you might want the points shifted to -7.5 and 7.5. This means you should subtract 17.5 from all numbers. How to find the equation for 17.5? It's the average of 10 and 25 (you wrote about the difference between them -- turns out that isn't helpful.)
Parent trick: If look up in here in UA about how to recenter an object, lots of examples of doing that using an empty parent.