I’m trying to create an instance with the same scale as the GameObject that stores it, here is the code:
The problem here is that the instantiated GmObj. seems like it changes its scale to original’s prefab whatever the parent scale is, something like this:
How can I fix this? I don’t understand the localScale very well.
If you want a child to have the same scale as the parent, the child should have a scale of (1,1,1).
When you parent something, it tries to adjust the scale so that it remains visually the same size. So if the parent was already at scale=0.5, and you add a child object of scale 1, it would get a scale of 1.5 to compensate.
The function Transform.SetParent() has an optional boolean to determine whether or not the world-space visual should be preserved after parenting.
Oh I forgot when you add parameters it returns an Object instead of a GameObject, see my edited post for the solution. You can cast to a GameObject or use the generic version of Instantiate where you specify the type in the angle brackets <>.
This is some standard programming stuff though, you should look into more C# oriented tutorials to get more familiar with Types and the syntax of the language. If you googled those errors you could’ve found examples of how to fix it, the error plainly states what’s wrong.
I was trying to solve this quite a lot xD but I’m not so good at finding as I expected. And that’s what I’m doing, I’m trying to learn as much as I can and that’s why I came here ^^