Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by CrimsonChin · Nov 26, 2013 at 08:04 PM · 2dspritesprites

Unity 4.3 Sprite Align

I hope their is an easy answer to this. 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 chimney appears to move upwards. I just want it to look like the chimney collapses an is laying down on the roof.

Maybe it's the sprites position within 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
Add comment
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
0
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 chimney, then every sprite needs to have x pixels below the chimney.

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

I personally like option 2 because I think it is cleaner, but ultimately, they look the same.

Comment
Add comment · 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
0

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
Add comment · 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.

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

Why is my sprite not the original resolution? 2 Answers

Having trouble changing sprites in 2 dimensional animation 1 Answer

default sprite missing after removing and reimporting tmp 0 Answers

Fast Sprites Extraction from Sprite Sheet 0 Answers

2D Sprite Layering? 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