Resizing a box by moving vertices

So, I imported a model (just a box) and added a script to it to change the height of the box through those up and down buttons by moving its vertices. It works! Now, I cloned the box to make another box but did not add any script. But, it’s strange that the cloned box is changing its height through those buttons even though the script is only added to the original box. I think they are sharing vertex buffer somehow. I want a separate control per box. How can I do that? Here is the demo (the left box is cloned):

Hi @cgopia94,

Since both entities use the same model asset, the mesh instance used to render each cube uses the same mesh.

You will need to copy that cube to a new mesh to allow for separate control over its vertices. Check the terrain generation example on how it creates a new Mesh and sets positions/indices, similarly you can do the same with your cube.

1 Like

Thank you, @Leonidas
I was able to create a mesh/ mesh instances to get separate controls - the up arrow is for the original box and the down arrow is for the other box.
One thing I couldn’t figure out is that the new box got 90 degree rotated on X so that you see the down arrow changes the depth instead of height. I could rotate the box using eulerAngles, but is there any way to get correct orientation? Thank you again.

That’s quite interesting, I’d assume if you copy positions/indices and add the new mesh instance to an entity with the same translation/rotation, the result would be the same.

@mvaligursky any idea?

It should 100% match. There must be some rotation on the entity or similar, that makes it rotate.