HI,
I am trying to get creative with the block-breaker game, and am using a number of block variants, some of which spawn blocks of a different type when they are destroyed. The spawning part of the game instantiating new block types in specific locations with the same rotation as the spawning block works fine.
I have a mechanism where the score for destroying each block is calculated from a variable blockValue and a blockValueMultiplier that is a serialized Field in the Inspector.
The initial block variants I am using to spawn new block variants each have a blockValue calculated by a specific instance of another GameObject. I want to pass either the identifier for the reference GameObject instance or the current blockValue to the spawned blocks.
The problem I have is that the new blocks do not have an obvious association with the reference GameObject used by the spawning initial block or the spawning block itself. For blocks that are on screen when the scene is opened, I can set the association using [SerializeField] in the inspector, but I cannot do that for blocks that are spawned at run-time.
I need a way to tell the spawned block which instance of the reference GameObject holds the specific blockValue that it should use. If that is not possible, I want to pass the blockValue from the spawning block to the new block.
The Unity script reference for Instantiate says that you can pass the Original Object to be cloned, a Vector3 position, a rotation and a parent Transform, but it gives no examples of the use of the parent Transform. I have tried using the reference GameObject set for teh spawning block by the Inspector using [SerializeField] as the Transform parent, but Visual Studio gives me an error saying that I cannot convert from the GameObject Type to UnityEngine.Transform.
Any pointers appreciated, thanks in advance.