Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Turning cloth object into a perfect static rectangle
#2
(17-06-2022, 10:36 AM)KaanOzcelik Wrote: I need to turn my cloth object into a regular rectangle shape, much like a plane.

Hi,

What do you mean exactly by a "regular" rectangle shape? A simple static mesh?

You can access the current shape of the cloth mesh from the cloth renderer:

Code:
var mesh = cloth.GetComponent<ObiClothRenderer>().clothMesh;
Then you can do anything you want with it, as an example: instantiate it and assign it to another object's MeshFilter component.

(17-06-2022, 10:36 AM)KaanOzcelik Wrote: I don't want to destroy the cloth and instantiate a new object in its place to do this. How can I do it?

You can't convert an object into some other type magically (this applies to programming in general). Best you can do if both types have the same size in memory, is reinterpret that memory.

More specifically, components in Unity cannot be "converted" into one another. A cloth component is a cloth component, very much like a rigidbody is a rigidbody. You can't turn a rigidbody into cloth, or a cloth into a static mesh, except by destroying one and creating the other. So you can't "turn" an object into a different object: you destroy the old one and instantiate the new one.
Reply


Messages In This Thread
RE: Turning cloth object into a perfect static rectangle - by josemendez - 17-06-2022, 10:58 AM