- Home /
How can I set a sprite to be at a different coordinate than its gameobject?
I need to change the center transform coordinates (NOT the pivot) of an object in the editor relative to its attached SpriteRenderer. Visually, what I want to accomplish is:
I can't just attach the sprite to another gameobject, change its position, then link them in the heirarchy because the tool I'm working with specifically calls the center of the object the SpriteRenderer was directly attached to, i.e. the child not the parent.
Answer by FartDev · Jun 06, 2019 at 05:46 PM
Well, I never did find a direct answer but I did end up figuring out a work-around.
Increase the height of the sprite in your image editor so that the center of the object falls at some point along the transparent alpha section of the image, like so:
Note: For every pixel you need to offset the image in the editor, double that in the height increase in the image editor (e.g. if you need to offset the image 10 pixels up, increase image height by 20 pixels and move the sprite to the top of the image.)
This isn't a great workaround since you'll need to record offset values and adjust sprite positioning accordingly, for each sprite, so if anyone has a better answer hand it over.