- Home /
Question by
saberboy117 · Dec 30, 2012 at 02:38 AM ·
blender
Moving Center/Pivot point with blender models
How can I go about relocating the center point of a blender model directly imported so I can move the pivot point?
Comment
Best Answer
Answer by Straight Rainbow · Dec 30, 2012 at 02:58 AM
I have actually created a script for this a while ago. Put this in your Editor folder and it will be under the Custom tab.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class ChangePivot : ScriptableWizard {
public float offset_x = 0;
public float offset_y = 0;
public float offset_z = 0;
public bool shared_mesh = false;
public GameObject obj;
[MenuItem ("Custom/Move Pivot Point")]
static void CreateWindow()
{
ScriptableWizard.DisplayWizard("Move Pivot Point of Object",typeof(ChangePivot),"Move Pivot");
}
void OnWizardUpdate()
{
}
void OnWizardCreate()
{
change ();
}
void change()
{
Mesh mesh;
if(!shared_mesh)
{
mesh = obj.GetComponent<MeshFilter>().mesh;
}
else
{
mesh = obj.GetComponent<MeshFilter>().sharedMesh;
}
Vector3[] temp = mesh.vertices;
for(int i = 0; i < temp.Length; i++) //Loop through and move the object's mesh
{
temp[i] = new Vector3(temp[i].x + offset_x, temp[i].y + offset_y, temp[i].z + offset_z);
}
mesh.vertices = temp;
obj.GetComponent<MeshFilter>().mesh = mesh; //Just gotta make sure we make get the mesh back to the object.
}
}
Your answer
Follow this Question
Related Questions
copy bone animation from one object to another 0 Answers
Texturing only one face? 1 Answer
how to import animation from blender to unity? 0 Answers
Can i add a blender file from Unity asset using prefab ? 2 Answers
Importing .fbx Character in Blender 2 Answers