• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by CrimsonChin · Nov 26, 2013 at 08:04 PM · 2dspritesprites

Unity 4.3 Sprite Align

I hope their is an easy answer to t$$anonymous$$s. Below is the actual sprite sheet I'm using. I slice it automatically and drag all the sprites anto my scene to auto generate the animation. When I play the clip back the c$$anonymous$$mney appears to move upwards. I just want it to look like the c$$anonymous$$mney collapses an is laying down on the roof.

Maybe it's the sprites position wit$$anonymous$$n the keyframe? Or I need to auto align all the sprites to the bottom? I'm very new to unity and like everyone, very new to 4.3! Any help would be awesome.

alt text

jekyllhyde_chimney_01.png (132.0 kB)
Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Spinnernicholas · Nov 26, 2013 at 09:21 PM

The problem is being caused by the smoke, it pushes the bottom of the sprite down below the bottom of the building.

I quickly see two options:

  1. Manually slice the sprites so that the bottom of each sprite is aligned to the bottom of the sprite where the smoke goes down the lowest. ie: if the smoke goes x pixels below the bottom of the c$$anonymous$$mney, then every sprite needs to have x pixels below the c$$anonymous$$mney.

  2. Separate the c$$anonymous$$mney sprites from the effect sprites. You would then create effect sprites on top of the c$$anonymous$$mney sprites. You would only have to deal with aligning the effect sprites then.

I personally like option 2 because I t$$anonymous$$nk it is cleaner, but ultimately, they look the same.

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Spinnernicholas · Nov 26, 2013 at 09:37 PM 0
Share

Set the pivot point of each sprite in the slicer to the base of the chimney and then move the whole sprite down by the pivots y position at runtime.

 void fixSpritePosition()
 {
   transform.position += new vector2(0,(SpriteRenderer)renderer.sprite.textureRectOffset * pixelToWorldConverter);
 }

pixelToWorldConverter is a value that changes the pixel values to world space values. I'm not sure what this would be.

This will cause problems if you have a Rigidbody on the same GameObject as the SpriteRenderer. But, that's easy to fix, just move the Rigidbody to a new gameobject and place both objects under a parent object.

avatar image

Answer by Key_Less · Nov 26, 2013 at 08:34 PM

If you can evenly space out your sprites on the sheet so that they all share equal amounts of area, then you should be able to slice them evenly and the animation will look correct.

Comment

People who like this

0 Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CrimsonChin · Nov 26, 2013 at 08:37 PM 0
Share

I don't have any control over the sprites, is there definitely no way to do it with the image that I have?

avatar image Key_Less · Nov 26, 2013 at 09:16 PM 0
Share

That makes this an interesting issue, I can see exactly why the animation would seem to move up during its animation. I'm sure there is a way but I cannot be sure, I will need to do some research and get back to you. Going off nothing but pure speculation, I would start by parenting the Sprite to an empty GameObject. Then I would try to configure the center point for each sprite and use it as a sort of offset so that each image lines up as expected. Then during each frame of the animation, I would translate the sprite's position based of the difference in distance between the center point and the parent object. Again, I don't know if this is possible, just a brain storm.

Some pseudo code:

 private function PositionSprite()
 {
    var centerPoint = sprite.rect.center;
    // Get a vector between the parent object and center point.
    var distanceBetweenPoints = gameObject.transform.parent.position;
    // translate the sprite using the distance between points.
    sprite.transform.Translate(distanceBetweenPoints);
 }
avatar image CrimsonChin · Nov 27, 2013 at 08:53 AM 0
Share

Thanks for the brain storm (and answer) I don't have much time on this project so I'm going to take Spinnernicholas' quick fix for now. I'll try and let you now if your code solution works next week.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Fast Sprites Extraction from Sprite Sheet 0 Answers

Why does my sprite changes position after animation transition? 1 Answer

How can i make my sprites look crisp like in scene mode ? 3 Answers

Sprite disappears on android 1 Answer

Sprite Editor Unity 4.6: green box and Border parameters, what are they for? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges