• 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 kecaj · Jan 24, 2011 at 10:57 PM · addforceontriggerexit

removing AddForce

Hi good and wise people. Please, help the beginer. I can't figure out how to stop object after AddForce. My script is

var Cube : GameObject; var Sphere : GameObject;

function Start(){ Cube = GameObject.Find("Cube"); Sphere = GameObject.Find("Sphere"); }

function OnTriggerStay (other : Collider) { if(other.transform.name == "Sphere"){ Sphere.rigidbody.AddForce (1, 0, 0); } } function OnTriggerExit (other : Collider) { if(other.transform.name == "Sphere"){ Sphere.rigidbody.AddForce (0, 0, 0); } }

where Cube is a trigger. Sphere exits the Cube and still moves. I there any way to remove the AddForce? Thanks :)

Comment
Add comment · Show 1
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 Jessy · Jan 24, 2011 at 11:47 PM 0
Share

Code button next time, please.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Jessy · Jan 24, 2011 at 11:49 PM

http://unity3d.com/support/documentation/ScriptReference/Rigidbody.Sleep.html

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 kecaj · Jan 25, 2011 at 12:25 AM 0
Share

Thanks Jessy :), it stops Sphere but I want it to react still to gravity. There is a shot of s$$anonymous$$m that moves the Sphere in my game. After a short distance (the length of cube the trigger) it should exit the range of s$$anonymous$$m force. Can I just switch off the force without switching off the gravity?

avatar image
1

Answer by DaveA · Jan 24, 2011 at 11:16 PM

"F = ma ", Newton

What if you AddForce in the opposite direction?

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 kecaj · Jan 24, 2011 at 11:25 PM 1
Share

Yoda $$anonymous$$aster, even if I set -3 Sphere still mover. It must be the dark side of the power!! Seriously - it doesn't help :(

avatar image DaveA · Jan 25, 2011 at 12:31 AM 0
Share

You put -1, 0, 0 in the AddForce on the exit, right?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Adding rotation to Physics.AddForce(); ... Getting weird error? 0 Answers

Add Force to the right of the rigidbody, not right of the screen 1 Answer

Rigidbody2D and AddForceAtPosition 1 Answer

Avoid incoming objects by aproach side 1 Answer

Add force 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