x


Manipulate skinned mesh?

I need to manipulate the vertex of a skinned mesh, but not its sharedMesh (beacuse it remain deformed also when i stop the game). How i can do?

more ▼

asked May 04 '11 at 05:56 PM

Xarro92 gravatar image

Xarro92
17 3 3 3

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Copy the mesh on startup, so that you're operating on the clone instead:

void Start() {
  Mesh oldMesh = GetComponent<SkinnedMeshRenderer>().sharedMesh;
  Mesh newMesh = (Mesh)Object.Instantiate(oldMesh);
  GetComponent<SkinnedMeshRenderer>().sharedMesh = newMesh;
}
more ▼

answered May 04 '11 at 07:40 PM

sneftel gravatar image

sneftel
1.7k 7 9 20

I used with javascript:

var newMesh : Mesh;

function Start() { var oldMesh = GetComponent("SkinnedMeshRenderer").sharedMesh; newMesh = oldMesh; GetComponent("SkinnedMeshRenderer").sharedMesh = newMesh; }

function Update () { var mesh : Mesh = GetComponent(SkinnedMeshRenderer ).sharedMesh; var vertices : Vector3[] = mesh.vertices;

for (var i = 0; i < vertices.Length; i++) vertices[i] += Vector3.up * Time.deltaTime/100;

mesh.vertices = vertices; mesh.RecalculateBounds(); }

But when i stop the game in the editor the skidder mesh dont return to its original... is permanent modified.

May 05 '11 at 12:08 PM Xarro92

With Instantiate it works very well, thank you!

May 05 '11 at 12:14 PM Xarro92
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1366
x276
x138
x25
x8

asked: May 04 '11 at 05:56 PM

Seen: 1908 times

Last Updated: May 04 '11 at 05:56 PM