• 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 Zappelphilipp · May 02, 2016 at 10:34 AM · gameobjectscaletransforms

transform.localScale resets automatically

Hello,

I have a gameObject (non-static) and i want to scale it down or up in a method.

 mainObject = GameObject.FindGameObjectWithTag ("robotKyle");
 mainObject.transform.localScale = new Vector3 (2, 2, 2);

at this point, i have a new ratio, not just 2, but this helped me to find the problem. As often as i call this method, the object gets scaled without any problems (in this case to 2), but if i stop firing this method, it flips back to the default scale-value.

further information: i am working with ARToolkit and by detecting a marker i call this method to make it bigger or smaller so this method is called repeatedly if the marker is detected. so the problem is, as soon as the marker disapears (and the method is not called anymore) the scale-value resets back.

EDIT AND SOLUTION: the mistake was, double given the tag "robotKyle" so two objects were named the same.

Comment
Add comment · Show 5
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 tanoshimi · May 03, 2016 at 06:55 AM 2
Share

Do you have an animator attached to the gameobject also? Please post the inspector setup.

avatar image Zappelphilipp tanoshimi · May 03, 2016 at 09:50 AM 0
Share

an animation is attached but empty and not active. i removed the attaced animation but no difference... first image is the marker, second the gameObject attached to the marker. (marker is the parent)

inspector part 1 inspector part 2

avatar image Zappelphilipp Zappelphilipp · May 03, 2016 at 12:01 PM 0
Share

ah, problem found. Thany you tanoshimi! As you can see on image 1 and image 2, i named the parent AND the child object "robot$$anonymous$$yle". stupid mistake...

avatar image Link0n3 · May 03, 2016 at 08:49 AM 0
Share

following tanoshimi I guess animator can be the cause because if you are modifying a property set on an animation it will kept the values from the animation keyframe. That is why as soon as you stop overriding the value on the update the animator bring it back to the value set in the current key frame.

avatar image Zappelphilipp Link0n3 · May 03, 2016 at 09:51 AM 0
Share

i already found out, that animations can cause some problems, but i do not use any animations. :/

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Torigas · May 02, 2016 at 01:54 PM

This sounds a lot like you have other scripts which set the localScale of your object. Perhaps some character controller with a ducking functionality? You should create a minimal example with just your ARToolkit and nothing else. Perhaps just an empty GameObject you change. Then this behaviour shouldn't happen anymore.

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 Zappelphilipp · May 03, 2016 at 06:20 AM 0
Share

Hmm. there is nothing like this. $$anonymous$$y project is already that $$anonymous$$imal, i just have the ARTookit parts and this gameobject.

avatar image Torigas Zappelphilipp · May 03, 2016 at 08:12 AM 0
Share

Okay so how about you add an object (say, a cube) and put your two lines of code there in a script (on button pressed in the update method if you will)- does the scaling disappear? If it doesn't, and it shouldn't, then you can slowly add the components you have on your target game object. Then you'll see when that stops working and you will have identified the problematic component.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get an object to fill 3/4th of the screen. 0 Answers

Game Object Scaling based on Proximity 1 Answer

Make gameobject size always be the same 3 Answers

Game Object scale jumps when animation plays 0 Answers

How to reset GameObject to original scale 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