• 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 AW0610AUT · Feb 22, 2014 at 11:13 AM · triggerscalingvectortransform.rotation

Scaling Object but not attached Trigger

Hello, i want to scale my object after the if statement is true. I have it working but the problem is that the trigger that is attached to the object scales too. I dont want that. what can i do?

Here is a piece of my code. I didnt want to post the whole one because there is alot of unrelevent coding in it too. Hope you can help.

 if (health <= 80){
         RndRot = (Random.Range(45,300));
         transform.rotation = Quaternion.AngleAxis(RndRot, Vector3.up);
         transform.localScale = Vector3(0.8,0.8,0.8);
         }
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
1
Best Answer

Answer by whydoidoit · Feb 22, 2014 at 11:16 AM

So I'd parent the trigger as a child of an the object, and the rendering as a different child - then you can scale one but not the other. Your other choice is to modify the scale of the collider - but that's kind of complicated and very hard if it's a mesh collider.

Comment
Add comment · Show 11 · 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 AW0610AUT · Feb 22, 2014 at 11:19 AM 0
Share

Thanks. I will try it the first way. $$anonymous$$y Trigger is a Sphere. Is there a command for increasing the radius of a trigger collider?

avatar image AW0610AUT · Feb 22, 2014 at 11:28 AM 0
Share

And one more thing. If I make a empty Gameobject with the trigger attached and make it a child of the object i want to scale, can i still just use the function OntriggerEnter .etc in a script on the object i want to scale? Or will i get problems getting the trigger values from the child to the parent? I hope you know what i mean.

avatar image whydoidoit · Feb 22, 2014 at 12:24 PM 0
Share

Yeah you will need to put the script on the trigger object - but you can get it to send that up to its parent with Send$$anonymous$$essage - I can't quite remember if triggers send to their parent if the parent has a rigidbody (collisions are sent that way).

So yep - if you "cast" the collider to a SphereCollider you can just set the radius to the inverse of the scale you've applied to the object.

avatar image AW0610AUT · Feb 22, 2014 at 01:24 PM 0
Share

I think i have it right now but it doesnt do anything the collider still gets scaled down. This is part of the script:

 var ColRad =(collider as SphereCollider).radius;
 .
 .
 .
 if (health <= 80){
         RndRot = (Random.Range(45,300));
         
         transform.rotation = Quaternion.AngleAxis(RndRot, Vector3.up);
         transform.localScale = Vector3(0.8,0.8,0.8);
         ColRad = ColRad / 0.8;
         }
avatar image whydoidoit · Feb 22, 2014 at 01:30 PM 0
Share

You need to update the radius - you variable just has a copy of it.

 (collider as SphereCollider).radius = ColRad;
Show more comments

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

20 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

Related Questions

Resize objects with touch 1 Answer

Help with pickup animation (Scale object up, down and dissapear) 1 Answer

Good old trig and NaN 1 Answer

Can't click gameobject when over another trigger? 1 Answer

How to make cubes between 2 point and stick them together? 0 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