![]() Maybe an extension method would be useful here, on the Mesh. I probably got some things backwards, but I hope it gets you the general idea. I guess I don't have Unity in front of me, but I think that's the general idea. Save the updated vertices back to your mesh.įrom then on, just get the Scaler component attached to your objects, and call the Scale function passing in the scale. Add it to the anchor position and that is your new vertex position. You'll take subtract the saved anchor position from each vertex position, and multiply that value by your scale. In the scale function, you will look through all the vertices in the mesh. An Anchor is a special component that overrides the position and orientation on the Transform component on the same GameObject. Importing these models into Unity, I believe, preserves those center-points. Defining Your Own Geometry If you are savvy with model building software (e.g., Maya or Blender), they often support tools allowing you to specify the center-point of the geometry. Then, create a Scale function, that accepts an amount. There are two commonly used approaches: define your own geometry and anchors. So, if your object is a cube, and the anchor is at the bottom left front corner (um (-1, -1 -1) I believe).Īlso get a reference to the mesh on object A, and save that too. Save it's position locally relative to object A's position, and save that in a field variable. In the Startup function of the script, find the "Anchor" child gameobject. ![]() Or you can just add a script vector variable, that holds the anchor's local position.Īdd a script to object A, your original. What you might do is, attach an empty gameobject to your original object (Object A), and call it Anchor. I've been using Unity for a while now, and I'm not aware off the top of my head if Unity has a "Scale from position" function. In our case the issue is that Unity is making tiny changes to the anchor. If so.the only way I can think of to do this in Unity is to actually define the anchor yourself, and actually move each vertex of the box/cube/whatever away from the anchor. Jobs in unity game development are plentiful, and being able to learn C. The other corners expand away from the bottom left corner. write code to change the value to which the pointer points' 'xargs -0' ' 0-9+' /bin/bash for launching ec2 Plot the histogram of sex attribute using Matplotlib Use bins 2 and rwidth 0. When you scale it, the bottom left corner stays at the anchor. 'write code to change the value of a pointer. I have a cube which I have turned into a rectangle its a child of a plane which is the 'ground' so that they share rotation (this is a pinball table). Instead, let's say you want the "anchor" to be the bottom left corner. Right now, when you scale it, all corners expand away from the center (anchor) as you scale it. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |