How do I…
I have 2D sprites object in my UI (2D layer), more or less a card, and when I click on a 3D board, I want to place a rendering of this sprite in the 3D world with 3D layer. These 2D sprites belong to a same object group. Ideally, I want the object created in the 3D world to be instancied with the same variables and values than the 2D object, but also have the same sprite rendering (except that it is in 3D).
I am not sure what is the best approach for this, but I observed the following point:
- You cannot create a custom object made of both 2D sprite and 3D sprite.
- You cannot copy a sprite from an object to another through event, you can only copy animation name and sprite number
I would have wished one prefab = one set of variable value = one animation only, but it seems I may have to twitch my approach, because of those limitation.
So I thought, the best idea, is to create an “invisible” object with the variables and values used by the game. Then in the UI, I link this object to a 2D sprite for the 2D rendering, and in the 3D world, I create a copy of the “invisible” object and link a 3D sprite. In order to ensure they both look the same, both the 2D renderer and 3D renderer needs to have all the possible animations implemented like a dictionnary (I am not happy with this, but I do not see the other way), and the “invisible” object communicate its rendering animation string.
However, if I want this to work, I need to be sure that both the 2D and 3D renderers have exactly the same animation names and sprite.
Is there a way to copy all the animations, animations name and single animation sprite of a 2D sprite object to a 3D sprite object in the editor (basically clone)?
Or is there a better approach to do what I need?
What is the expected result
In other engine, I would simply forward the sprite binary from 2D sprite to the 3D sprite, and there would be no pre-work needed for the 3D sprite, and each 2D sprite prefab will only know the needed sprites.
What is the actual result
I need to make a “dictionnary” of all possible animation in both 2D and 3D sprite, and assignthem through object variable, which is error prone and hard to maintain.