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 aleem.razzaq09 · Jan 08, 2014 at 12:38 PM · 2dscale

How to change image height without changing in x y.

Hi, I am working on 2D game in Unity 4.3. I have a spring Image, which I want to change its height on finger swipe, I can change via using "transform.localscale" of that Image but whats happening its position also change on size changing. I want to stick its position but just to grow and decrease image size on Swipe. I also attached image whats happening on left spring, its size but it also goes up of white line, this I don't want to do. Kindly suggest me some better approach to accomplish this task. Thanks in advance. Before Scaling

After Scaling

screen shot 2014-01-08 at 5.34.46 pm.png (49.6 kB)
screen shot 2014-01-08 at 5.33.24 pm.png (55.3 kB)
Comment
Add comment · Show 1
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 robertbu · Jan 08, 2014 at 02:27 PM 0
Share

Is this a dup of your other question or is something more going on here:

http://answers.unity3d.com/questions/611765/grow-sprite-image-size-from-edges-ins$$anonymous$$d-of-cente.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by yatagarasu · Jan 09, 2014 at 01:09 PM

No it's position is not changed when you scale it. What changes is position of both ends relative to it's position. And in sprites objects position corresponds to sprite pivot point.

So what you need to do is set sprite pivot point to start of your spring (left or right if your spring sprite is horizontal or to top and bottom if it is vertical). And than scaling will keep it's beginning stationary and will move only other end.

Comment
Add comment · Show 2 · 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 aleem.razzaq09 · Jan 09, 2014 at 01:41 PM 0
Share

Thanks @yatagarasu, I am doing like but It really required lot of calculation to follow finger position, because for this I need to change angle and its size as well this is bit tricky. So I think you are experienced in Unity, so is this possible that Unity has some default feature for this or is there any other quick approach for this to accomplish this task. kindly share with your experience bcoz I am new bee in Unity3D.

avatar image yatagarasu · Jan 09, 2014 at 02:19 PM 0
Share

Unity have a builtin 2D physics engine which can solve your task, but i have never used it.

If you want to calculate scale and rotation by hand. You should calculate a vector between ball and spring fixed joint (attached to the ground). The length of this vector will be scale times greater than the length of the spring. The rotation can be found with a Quaternion.RotateTowards

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

19 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 avatar image

Related Questions

Material doesn't apply on iPad but works fine on android 1 Answer

Can I make 2D games with Unity? 1 Answer

How to move ball as fast as it pulled back for 2D game in Unity 4.3 0 Answers

Pressing 'Play' makes Unity mess with Transform properties 0 Answers

Max scale in unity3d 2 Answers


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