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
1
Question by AW0610AUT · Dec 14, 2013 at 06:35 PM · lowpoly

Low FPS while playing animations.

 var anim : String;
 var AnimationSource = gameObject;
 
 function OnTriggerStay()
 
  { 
 
 if(Input.GetKey("e"))
 animation.Play("AirlockOpen", PlayMode.StopAll);
 }


Hello,there. I have about 4 Doors in my scene they open like airlock doors (one part to the left one to the right) they are moved by an animation.

So far so good, the code works but when i activate about 3 door at once the game´s Fps drop to an unplayable state. While playing about three animations i get like 10-15 Frames. Is this normal? the Doors are very low poly. What am i doing wrong? Is it because of the animations? Any help appreciated.

PS: Im from Austria so my english isnt the best.

Comment
Add comment · Show 2
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 ashjack · Dec 14, 2013 at 07:02 PM 0
Share

Try building your project and run it, sometimes lag is just in the editor.

avatar image CHPedersen · Dec 15, 2013 at 12:42 AM 0
Share

Have you read the documentation on OnTriggerStay? Especially the part about getting called every physics update when a collider is touching the trigger. Perhaps that's the reason? $$anonymous$$aybe you should try OnTriggerEnter ins$$anonymous$$d.

2 Replies

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

Answer by Sindorej · Dec 14, 2013 at 07:33 PM

It is because when you call GetKey it gets called while the key is pressed. You should replace it with GetKeyDown. Small notice : instead of "e" use KeyCode

Comment
Add comment · Show 7 · 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 · Dec 14, 2013 at 09:08 PM 0
Share

Ok i changed it to Get$$anonymous$$eyDown. Still works but the FPS are not any better. I also tried Building the game but its still not better. btw what do you mean by $$anonymous$$eyCode?

avatar image Sindorej · Dec 14, 2013 at 09:18 PM 0
Share

You can still move the door by applying a force to it, if it is an object with a collider and physics material. Check out that. This needs to have a rigidbody component.

r

igidbody.AddRelativeForce(0f,0f,thrust,Force$$anonymous$$ode.Acceleration

also check

http://docs.unity3d.com/Documentation/$$anonymous$$anual/Physics.html

By $$anonymous$$eyCode i mean

i

f(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space)

avatar image AW0610AUT · Dec 14, 2013 at 09:32 PM 0
Share

Ok thanks. Im going to try that tomorrow. So i guess animations are the wrong way to go when opening doors or stuff like that.

avatar image Sindorej · Dec 15, 2013 at 12:31 AM 0
Share

Check this one out

http://unity3d.com/learn/tutorials/modules/beginner/physics/joints

He blasts the door using a joint as a hinge

avatar image AW0610AUT · Dec 15, 2013 at 12:40 PM 0
Share

Ok i found out what causes the FPS drop. I tried a few different things. 1.) changing the OnTriggerStay to OnTriggerEnter didn't do much for my FPS. Also with OnTriggerEnter i couldn't implement my press e to open and i had to make it open automatic.

2.)At first i had only one door in my scene and i set the collider to mesh. So when i duplicated my doors everyone had a mesh collider. I changed that and now i have much better FPS.

3.)I still need to try out the "physics" way of doing this ins$$anonymous$$d of animations.

Thanks for the help everyone.

Show more comments
avatar image
0

Answer by TheHoboCoder · Dec 14, 2013 at 07:19 PM

You could try to use GetKeyDown instead of GetKey. Don't know if it changes anything but at least it only runs it once.

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

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

Procedural "Faceted" Terrain 1 Answer

Low draw calls and awesome batching, BUT laggy frame rate. Why?! 2 Answers

I have performance lag after my game has been compiled. 1 Answer

Level Creation, Prefabs and Colliders 2 Answers

How to bump the graphics down? 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