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 refi350 · Feb 03, 2019 at 05:52 PM · scalespriterenderer

How to modify scale of sprite

I have a problem with scaling my sprites. I wanted to make Ilusion of rotating around my sprites using scale and proper "back" of my sprite. I made a script, but for some reason gameobjects rotate so fast, that it looks more like switching sprites than slow "rotation" of my sprite.

    public float speed = 0.1f;
     public Sprite[] back;
 
     private bool stop = false;
 
     // Update is called once per frame
     void FixedUpdate()
     {
         Debug.Log(speed);
         if(transform.localScale.x <= -1f && !stop)
         {
             transform.localScale = new Vector2(-speed * Time.deltaTime/100,transform.localScale.y);
         }
         else
         {
             stop = true;
             transform.localScale = new Vector2(-1f, transform.localScale.y);
         }
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 tormentoarmagedoom · Feb 04, 2019 at 09:29 AM 1
Share

Good day.

Are you sure that division is beeing executed?

Try this:

 transform.localScale = new Vector2((-speed/100f) * Time.deltaTime,transform.localScale.y);


1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by AbubakrKhan · Feb 04, 2019 at 09:32 AM

u can scale sprites through the engine buy creating a UI image and then applying that sprite on source image field in image script component of the script. Highlighted below in the picture.

you just have to apply a constant rotation on the image object you just created. by


 void Update(){
   transform.Rotate(Vector3.forward * speedRotate * Time.deltaTime);
 }

or u can use rotateArround function if that is what you are looking for.


 void Update() {
     transform.RotateAround(Vector3.zero, Vector3.up, 20 * Time.deltaTime);
 }


alt text


capture.png (34.4 kB)
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 refi350 · Feb 04, 2019 at 06:05 PM 0
Share

I wanted to avoid using rotations and quaternions, because I don't fully understands them, but after few modifications of my code it worked, but still too fast in my opinion and trying to put diferent numbers to modify rotation didn't seem to change anything. Can you tell me how those quaternions, are calculated?

Edit. also when I put transform.rotation = new Quaternion(transform.rotation.x, -1f,transform.rotation.z,transform.rotation.w); to "fix" position it puts my rotation.y on position -161,571 ins$$anonymous$$d of -180.

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

100 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

Related Questions

Scaling GameObjects by Screen Resolution 0 Answers

How do I size a UI Image to fit the sprite exactly? 2 Answers

Stretch sprite one direction 1 Answer

Scale Objects become flat. 1 Answer

Bake mesh scale. 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