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 pepperedereppep · Nov 21, 2010 at 04:47 AM · tagtriggers

triggers and going through objects

So I have an object moving down towards the ground object. I have a code that says when the object hits the ground, it triggers the ground tag and stops(OnTriggerEnter). Problem is the falling object sees the ground trigger a little late and by the time it stops it is half way into the ground. Is there a way to prevent this from happening or making it more accurate? Any help is greatly appreciated

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Adam Rademacher · Nov 21, 2010 at 05:35 AM

You can do a sphere/capsule cast to check for the trigger to stop its movement early, or you can try non-trigger colliders with OnCollisionEnter.

Comment
Add comment · Show 2 · 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 pepperedereppep · Nov 22, 2010 at 02:34 AM 0
Share

thanks for the reply. OnCollisionEnter has the same effect; the object is half way through the ground before it's triggered. As for sphere/capsule, I've never heard of it.. can you explain what you're talking about"? thanks

avatar image Adam Rademacher · Nov 22, 2010 at 03:15 AM 0
Share

You can think of spheredcasting as the physics system throwing a sphere in the direction (like a ray) and checking to see if it collides with anything. http://unity3d.com/support/documentation/ScriptReference/Physics.SphereCast.html has the scripting reference...you'd basically want to do this and keep the distance very small and the layermask only set to collide with the terrain. Then stop your object from moving when it gets within the distance specified.

avatar image
0

Answer by The_r0nin · Nov 21, 2010 at 02:53 PM

You could also check the depth of the penetration (using Contacts and ContactPoints), get the normal of the collision and either move the object back above the ground or apply a force (which would give you a slight bounce effect).

Comment
Add comment · Show 2 · 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 Mike 3 · Nov 21, 2010 at 03:02 PM 0
Share

You wouldn't get contacts from a trigger collision, you only receive the collider itself

avatar image The_r0nin · Nov 21, 2010 at 05:56 PM 0
Share

So only OnCollisionEnter() provides contacts? I thought OnTriggerEnter() used the same colliderInfo? If not, you could change over from a trigger to a collider (like $$anonymous$$said)...

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

No one has followed this question yet.

Related Questions

I am working with first person controller, I cant control the clamp of main camera to specific rotation 0 Answers

colliding with child trigger? 0 Answers

How do you find the tag of the object that is a trigger? 1 Answer

Check if there is a child of object, and if so, get tag? 2 Answers

Disable Box Collider on Tagged Object 2 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