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 pocikanec · Nov 22, 2010 at 04:36 PM · triggerobjectgravityfalling

TriggerEnter, useGravity, Cubes are not falling down

Hello, i have problem.

I got two cubes. Cube > with a collider and rigidbody, useGravity is unchecked. Cube > with a collider and script attached on it. Script:

var ObjectToFall : UnityEngine.GameObject;

function OnTriggerEnter ( other : Collider ) { ObjectToFall.rigidbody.useGravity = true; }

So when i collide it with my playercontroller (2d platform tutorial), first cube will fall down, checking on the useGravity. It not works, why? (If i push the first cube, it slowy moves in direction where i have pushed it)

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

3 Replies

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

Answer by skovacs1 · Nov 22, 2010 at 05:33 PM

Your description gets very confusing towards the end when you suddenly start talking about a character controller and pushing. What do you mean by this?

There are several reasons why OnTriggerEnter may not work:

  1. Your GameObject with the trigger script does not have a Rollider.
  2. Your GameObject with the trigger script's Collider does not have the isTrigger checked.
  3. Your GameObject with the trigger script's trigger script instance's ObjectToFall instance is not set.
  4. Your GameObject with the Rigidbody does not have a Rollider.
  5. Your GameObject with the Rigidbody's Rigidbody is asleep.

to name a few.

Since 1-4 are pretty rudimentary, your most likely culprit above is 5. Unless your rigidbody is moving, changing, etc. it will be asleep and will not set off OnTriggerEnter. See this doc for more. The simple solution is to force it to wake up within some proximity to your trigger, but this does not scale well as for n rigidbodies this becomes much more costly and complicated to handle. For those cases, you may want to use a different mechanism than depending upon OnTriggerEnter.

To force awake, you could add something in your trigger script like:

var range : float = 3.0f;

function Update() { if(ObjectToFall && (ObjectToFall.transform.position - transform.position).magnitude <= range) ObjectToFall.WakeUp(); }

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
1
Best Answer

Answer by Bampf · Nov 22, 2010 at 06:54 PM

It sounds like you want the player to enter an area represented by cube A, causing cube B to fall. Is that right?

You are putting code in OnTriggerEnter. Make sure Is Trigger on cube A is true (checkbox is checked.)

Make sure ObjectToFall on cube A was assigned the cube that you want to fall (cube B).

If neither of these help, it might help to narrow down the problem. While the game is running, select cube B in the Inspector. You should be able to see the Use Gravity checkbox switch on when the player hits cube A. You can also try toggling Use Gravity on manually. This will help you narrow down whether the problem is with the cube A trigger, or the gravity on cube B.

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 pocikanec · Nov 23, 2010 at 01:53 PM

Thanks for fast replys, iam really an idiot! isTrigger was unchecked... Now my next question, how to make isTrigger checked and make the cube like it is unchecked. So, the isTrigger = true & my character dont go trough it

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

No one has followed this question yet.

Related Questions

Trigger Falling Object 1 Answer

Walking on walls JS 2 Answers

how to set rotation / position of an object on trigger? 2 Answers

Distinguish between two colliding objects 1 Answer

character gravity problem 1 Answer


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