unity 中 SkinnedMeshRenderer mesh world position change to local position
时间: 2024-05-12 10:21:18 浏览: 10
To change the world position of a SkinnedMeshRenderer mesh to local position, you can use the Transform.InverseTransformPoint method. Here's an example:
```
// Get the world position of the mesh
Vector3 worldPosition = skinnedMeshRenderer.transform.TransformPoint(skinnedMeshRenderer.sharedMesh.vertices[0]);
// Convert the world position to local position
Vector3 localPosition = skinnedMeshRenderer.transform.InverseTransformPoint(worldPosition);
```
In this example, we're getting the world position of the first vertex in the shared mesh of the SkinnedMeshRenderer. We then use the Transform.InverseTransformPoint method to convert the world position to local position.
You can use this method to convert any world position to local position relative to the SkinnedMeshRenderer's transform.