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 Morvar · Feb 19, 2014 at 09:16 PM · animationcolliderscaleefficiency

How should I scale an object with collider?

Hi,

I currently a have randomly generating world consisting of simple blocks with colliders. When these blocks come inside the player's vision range, they are scaled with Lerp from 0,0,0 to 1,1,1 in real time currently with this code:

thisBlock.transform.localScale = Vector3.Lerp (thisBlock.transform.localScale, maxScale, speed * Time.deltaTime); speed = speed + 0.1f;

As the profiler picture below shows, the method is not very efficient and it's giving me these errors apparently because the blocks have colliders? And I read that scaling with colliders is not a good idea.

alt text

I was wondering would it be any lighter/better idea in general to make animations of my cubes and all other objects, scaling from 0,0,0 to 1,1,1 and then play these animations when the blocks come in the range? All goal scales would be predefined, such as from 0,0,0 to 1,1,1 and back to 0,0,0. Could I make these kind of animations with animator + Mecanim? The blocks have no bones.

Or would there be some other even better way?

scalingprofiled.png (33.9 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 Morvar · Feb 19, 2014 at 10:04 PM 0
Share

I found out that I should start by separating the collider to a child object, which should stop the errors.

Edit: Collider moved to child and a test with mechanim animation on the parent still causes warnings through those colliders on child. Sigh.. Can I somehow record an animation to scale only in local scale?

Edit2: I suppose I need even more children. Perhaps: 1. GrassBlock (just empty) 1.1. $$anonymous$$esh (with the mesh, texture and animator) 1.2. Collider (with boxcollider and script handling collisions)

But that's again so much refactoring that I'll have to try it tomorrow :)

1 Reply

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

Answer by Morvar · Feb 20, 2014 at 02:47 PM

After 17 hours as there's been no better alternative suggestions I'll mark my mecanim animation as a solution. It might not be the most efficient way to scale but at least with the 1, 1.1, 1.2 structure I also got rid of the errors related to colliders being scaled.

Comment
Add comment · 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

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

18 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

Related Questions

Mesh Collider from 3d max animation? 1 Answer

how to scale object to fit inside a room 1 Answer

Problem with collision detection in an animated object 1 Answer

4.5.2 animation BUG: 2D collider colliding with 2d trigger!!! 0 Answers

Missing animation that isn't actually missing 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