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 /
  • Help Room /
avatar image
0
Question by pRoFlT · Aug 24, 2015 at 01:43 AM · animation

Area Effector 2D and the Animator not working together.

Windows 7 64bit environment (compiling to android) (testing in windows), 2D platformer'ish style game, Unity 5.1.2f1

Okay my issue right now is i have a 2D game with water and an "area effector 2d" used to make the player float. I want to make the water lower. so i added an animator and setup what i want to change from full water to low water. when i play the game the water lowers (from an animation adjusting the transform etc) but the area effector is no longer working during animation play? if i disable the animation the effect will come back, while debugging. i want the player to still float as the water lowers but he just drops all the way to the bottom.

Layout is Gameobject with Sprite Render, animator, Box Collider 2D, Area effector 2D and a controller script which doesn't do anything right now.

Again without animation the water works fine and the player kind of goes into the water and floats back up to the top.

Any ideas? Thanks.

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 pRoFlT · Aug 25, 2015 at 05:50 AM 0
Share

Okay round two. I removed the animator. I added a script to adjust the localscale of the object. I get the same results. when adjusting the scale the "area effector 2D" has no effect on my player. Here is the function i used to modify scale. Not pretty but it works.

 //$$anonymous$$axDistanceDelta is set to 0.02 and i have max scale at 8 and $$anonymous$$ at 2.
 
 float currentDrainY = transform.localScale.y;
         if(draining && (drain$$anonymous$$inY < currentDrainY))
         {
             //drain
             transform.localScale = Vector3.$$anonymous$$oveTowards(transform.localScale,new Vector3(transform.localScale.x,drain$$anonymous$$inY,transform.localScale.z),$$anonymous$$axDistanceDelta);
         }
         else if(!draining && (drain$$anonymous$$axY > currentDrainY))
         {
             //fill
             transform.localScale = Vector3.$$anonymous$$oveTowards(transform.localScale,new Vector3(transform.localScale.x,drain$$anonymous$$axY,transform.localScale.z),$$anonymous$$axDistanceDelta);
         }

I created a empty object with the controller script attached so i could have a anchor point where i needed it. then attached the gameobject with the sprite render, collider and area effector to it. So i scale the empty object with the script and it makes the attached gameobject shrink or grow. but as soon as it starts to shrink/grow my player falls to the bottom and no longer floats.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by pRoFlT · Aug 31, 2015 at 08:04 PM

http://forum.unity3d.com/threads/area-effector-2d-does-not-seem-to-work-while-adjusting-scale-custom-area-effector-2d-solved.349991/#post-2271520

I've posted this in the forum. And this link is my answer to my own question :)

I just wrote my own Area Effector 2D script. only works with one object. could use more work to be cleaner and be a direct replacement drop in for area effector 2D.

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

25 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

Related Questions

Audio event in an animation decrease its volume and stopped 0 Answers

Survival shooter - Video 2 - Movement Animation Not Working 1 Answer

Odd twitching when using deltaTime 1 Answer

Same animation from multiple spritesheets 1 Answer

How to play animations for objects in gameObject [ ] ? 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