Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 yair1321 · Oct 20, 2018 at 01:57 PM · 2dpositionscaletransform.positionmovetowards

How can I move an object to a (0,0) and scale it to (0,0) at the same time?

How can I move an object to a (0,0) and scale it to (0,0) at the same time? If i try like: transform.position = Vector3(transform.position, Vector3.zero, Time.deltaTime * 3f); transform.localScale = Vector3.Lerp(transform.position, Vector3.zero, 0f); They dont sync I mean they move but they can get to the specific point without scale to (0,0) or they can scale to (0,0) without reaching the specific point. The specific point is (0,0) (Its 2D). Thanks! P.S If I scale the object they x and the y arent the same does that have a fix? Also thanks!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Behisoft · Oct 20, 2018 at 04:26 PM

First of all, you might need some sort of easing function for making the transition look good. I'm not explaining that here. For both scaling and also moving the object, you first need to define the time in which you want the transition to happen. For example I assume you need this to happen during the course of one second. bool shouldGoAway = false; bool isShown = true; float durationSec = 1; float transitionProgressSec = 1; Vector3 startingScale; Vector3 startingPosition; private void Update() { // this.controller.Update(); if (shouldGoAway) { if (isShown) { startingPosition = transform.position; startingScale = transform.localScale; isShown = false; // We set this here in order to prevent further Update calls from updateing start points } transitionProgressSec += Time.deltaTime; float progress = Mathf.Clamp01(transitionProgressSec / durationSec); // This shows the progress which is used in Lerp method transform.position = Vector3.Lerp(startingPosition, Vector3.zero, progress); transform.localScale = Vector3.Lerp(startingScale, Vector3.zero, progress); // We also want to check if the transition is done if (progress == 1) { shouldGoAway = false; } } }

This should solve your problem.

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 yair1321 · Oct 20, 2018 at 07:10 PM 0
Share

Thanks for answering. This doesnt work sorry. maybe the Lerp is the problem. Got any other suggestions?

avatar image yair1321 · Oct 20, 2018 at 07:19 PM 0
Share

I did: transform.localScale = Vector2.Lerp(transform.localScale, Vector2.zero, 0); transform.position = Vector3.$$anonymous$$oveTowards(transform.position, Vector3.zero, Time.deltaTime * 3f); The only problem is the x and the y of the scales dont match and that dont looks good. Any advices how can i avoid it?

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

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

Related Questions

How to drag-and-stretch a 2D sprite in local space? 0 Answers

[2d]inversing scale modify position 0 Answers

move toward but keep going 1 Answer

Position + Vector3 doesn't return correct values 1 Answer

transform.position in fixedUpdate() different from transform.position in Update(); 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