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 ungalyant2 · Feb 19, 2013 at 11:24 AM · collidersontriggerentertriggers

On Trigger enters being called a frame late

I'm working with some functionality that requires a function to be called as soon as the player character enters a collider. We were originally using OnControllerColliderHit functions, but that only seemed to work with physical colliders, which is causing issues as collision is repositioning him. So I switched to using OnTriggerEnter functionality, however, the OnTriggerEnter function only seems to be called the frame after the player has entered the collider, as is demonstratable by the attached picture, the print functions are called within the OnTriggerFunction, is there any way around this, or anything I should be taking into account that I am not?

alt text

triggerenterissue.jpg (278.0 kB)
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

Answer by Bunny83 · Apr 11, 2013 at 03:18 PM

I guess the player is still a CharacterController? Have you an additional kinematic Rigidbody attached? Usually the CharacterController doesn't produce OnTriggerXXX messages.

In this case the problem is that collisions (and triggers) are handled by the physics system. The physics system runs before Update is called, so when you move your player in Update, the collision is detected the next frame when the physics system updates.

You could try to put your movement code in FixedUpdate, but i'm not sure if that really helps, especially because it could make your movement a bit "choppier".

Comment
Add comment · Show 3 · 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 ungalyant2 · Apr 11, 2013 at 03:22 PM 0
Share

Thanks, I did know about the order of calls, but I just hadn't thought about it in that way. I think I tried attaching a rigidbody to check if it works, but I'll try again to make sure.

avatar image ungalyant2 · Apr 13, 2013 at 09:34 AM 0
Share

I tried attaching a rigidbody to both colliders, making them both kinematic, and the player's update is already being called in FixedUpdate. The collision is still being detected a frame late, sometimes 2 frames, when the first frame is only a small collision.

avatar image Bunny83 · Apr 13, 2013 at 06:16 PM 0
Share

What is "small"? :) maybe it's below the "$$anonymous$$in Penetration For Penalty" value? Is it that important to get the notification a frame earlier?

You could try using Rigidbody.SweepTest to test for an intersection manually.

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

10 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

Related Questions

How do I prevent multiple triggers using OnTriggerEnter? 1 Answer

OnTriggerEnter Multiple Collisions Activating. I tried many variations, Please help (Java) 3 Answers

Can't call GetKey inside OnTriggerEnter? 2 Answers

Hello, How would one make a particlesystem activate triggers? (hopefully I worded that right) 0 Answers

Trigger in child object calls OnTriggerEnter in parent object 3 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