Hi Dredok,
-
There are various ‘space conversion’ methods like ConvertTextureSpaceToPivotSpace defined in UPaperSprite that handle everything for you, but they’re only available in editor builds, since most of the other spaces are ‘baked away’ at runtime so there is only final render geometry in uu space and UVs in texture 0…1 space.
-
Pivots don’t exist at runtime, the sprite render geometry is created so that the pivot is always at 0,0,0 in local component space. However, sockets work at runtime if you need to define multiple points in your sprite for reference. There were some bugs in 4.4 with editing sockets if Pixels per UU was not 1.0, which are fixed in 4.5 (they still worked fine in the level editor or at runtime, but they appeared at the wrong position in the sprite editor, and the transform gizmo felt ‘sluggish’).
-
I’d suggest either using sockets, or using dummy scene component nodes, e.g., if you want to make a sprite bob up and down, then make a scene component as the parent node, and attach the sprite as a child. You can then animate the relative position to the parent to make it move up and down or bob around. If you need ‘setpoints’, e.g., start at X and move to Y, then use a socket for each set point. Normally sockets are used in the opposite sense, where you use them as a point to attach something else as a child, but they’re really just a reference point in component space that you can query using the USceneComponent API, so you can read them and use the -ve of that value as an offset against your parent instead.
-
You could create and destroy the components manually, or you could create them all but hide the ones that shouldn’t be visible at frame 0, and just manage the visibility flags instead. If you’re just changing what sprite asset is visible at a given point in the hierarchy, you could also just change out the sprite using SetSprite, rather than have two components.
This sounds pretty cool, are you working on importing data from an external tool like Spriter or Spine, or do you have your own custom setup in Maya or something?
Cheers,
Michael Noland