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 Essential · Nov 30, 2011 at 04:10 PM · charactercontrollerontriggerenter

How do I make my platform not be jerky?

I have a platform that only moves down when the player is standing on it, otherwise it moves back up again.

To do this, I'm using onTriggerEnter to determine when the player is touching a box collider on the surface of the platform. However, when the platform moves down, the motion is jerky. I assume the player is slightly moving off the box collider every frame or so. How can I fix this?

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 syclamoth · Dec 01, 2011 at 09:49 PM 0
Share

Well, it looks like your other question got shut down by Eric. No big surprise there. You shouldn't have mentioned that you'd double-posted, otherwise he wouldn't have noticed! Anyway, I think I can answer this one.

avatar image Essential · Dec 01, 2011 at 10:46 PM 0
Share

Haha, I wanted to be honest about it…

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by syclamoth · Dec 01, 2011 at 09:50 PM

This isn't a problem with OnTriggerEnter, so much as it is a problem with your platform script! If you set it up so that the platform always moves before your player does in script execution, you might get a better result. I don't think you should be using OnTriggerEnter for this, by the way- maybe put a box trigger on top of the platform, and use OnTriggerStay backed up by raycasting from you character's feet.

Basically, it's a script execution order problem. But that's easy to fix, as of Unity 3.4!

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
avatar image
0

Answer by aldonaletto · Dec 02, 2011 at 12:28 AM

If the player is a CharacterController, a possible cause is the player movement script: FPSWalker.js and the CharacterController.Move example (both are almost the same) zero the vertical speed (y component of MoveDirection) when the character is grounded. If the platform moves down, the gravity must accelerate the character during a couple of frames until it touches the platform - which will ground the character, zeroing its vertical velocity again, etc. This is specially true when the character moves in Update, because the platform collider will be moved in the physics cycle: the different rates create a jerky movement.
A possible solution is to place the movement code in FixedUpdate (you can try to just rename Update to FixedUpdate); if you are using the standard First Person Controller, just set the option Use Fixed Update in the Character Motor component, in the Inspector.
If this doesn't solve the problem, edit your question to include the player movement script (not necessary if it's CharacterMotor.js).

Comment
Add comment · Show 1 · 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 Essential · Dec 02, 2011 at 09:45 PM 0
Share

So I changed it to LateUpdate in the character movement and it made a BIG difference, but there is still a slight amount of jerking there. I'm basically using a very slightly modified PlatformerController script from the 2.5D platformer tutorial. I could post it but it's quite big with a lot of functions and I'd be unsure which portions to post.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

OnTriggerEnter not working with CharacterController 0 Answers

Check for Collision 1 Answer

Enemy with character controller has inconsistent hit detection 1 Answer

using OnTriggerEnter, char falls thru respawn point 1 Answer

Moving Trigger/Platform and Moving Player calls OnTriggerEnter every frame 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