- Home /
Copy collider Component type and parameter to a new Object at runtime
Hi, i've searched a lot and never found a working solution to my problem so i through i would ask and hope for an answer, in C# preferably.
THE SETUP:
I have a prefab Gameobject, let's name it TEMPLATE,with nothing on it except a script or two. I have a list of prefab, let's name them ITEM, with MeshFilter and different Collider types and size.
When i press a button, I instantiate TEMPLATE at a precise position, and i want to add the MeshFilter and Collider Component from the selected ITEM to it.
.
THE PROBLEM:
I cannot figure out how to copy or recreate the collider component of the selected ITEM with all it's parameters, to the TEMPLATE instance.
so far i managed to get the collider type but i cannot find how to store the collider settings in a variables so that i can resetup the new one or even better, how to do
(pseudocode) Component tempComponent = ITEM.GetComponent(someCollider); TEMPLATE.AddComponent(tempComponent);
Your answer
Follow this Question
Related Questions
Instantiated object won't collide with particles 1 Answer
Generating a pixel-perfect collider for an object at runtime 1 Answer
AddComponent() at runtime - variable not being initialized from Inspector 1 Answer
Object hover over collider during runtime? 2 Answers
why i can not destroy the collider 0 Answers