- Home /
Incorrect Mesh Position of Mesh changed at runtime
Hello, in my project I have a ship model and when it gets damaged enough I want it to swap the full health ship mesh to a damaged ship mesh.
However, when I change the ship mesh via script, the new mesh is at an offset position (approx (-5,-10,-10.5) away). I am wondering how I can get the new mesh to appear in the exact same position as the original mesh.
For testing purposes my code is something like this (where I have set the meshBroken in the inspector):
//private Mesh startMesh;
private MeshFilter myMeshFilter;
public Mesh meshBroken;
void Start () {
myMeshFilter = GetComponent<MeshFilter> ();
//startMesh = myMeshFilter.mesh;
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown (KeyCode.Space))
{
myMeshFilter.mesh = meshBroken;
}
}
Any help would be greatly appreciated, thanks!
Comment
Best Answer
Answer by Julian-S · Mar 31, 2015 at 04:27 AM
Fixed it. It was a problem with the mesh itself.
Your answer
![](https://koobas.hobune.stream/wayback/20220613191735im_/https://answers.unity.com/themes/thub/images/avi.jpg)