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 united4life · Mar 11, 2013 at 09:21 AM · forceprojectile

Making force 0 at some point.

I am adding force(for projectile motion) once i release my mouse button.

 if(Input.GetMouseButtonUp(0))
 rigidbody.AddRelativeForce(10, 10, 10);

Once it reaches the trigger point i want this force to be 0 .i.e the ball should fall down with the gravity. So how to make this force 0?

PS : The trigger point is somewhere far.

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
0

Answer by sparkzbarca · Mar 11, 2013 at 09:51 AM

is the trigger an actual object?

basically you need to add a bool AND together the if statement with the bool and change the bool based on the trigger.

 public bool TriggerHit = false;
 
 if(input.getmousebuttonup(0) && TriggerHit == false)
 {
 //addforce
 }
 //you can add something to do here if the trigger is hit
  or you can just do nothing and simply stop adding force
 
 
 
 
 
 //script atttached to gameobject with trigger collider
 
 void OnTriggerEnter(collider ColliderOfObject)
 {
 if (ColliderofObject.gameobject.tag == "name of your ball")
 {
 
 ColliderofObject.gameobject.getComponent<Script That adds force>().TriggerHit = true;
 
 }
 
 }
 
 
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 united4life · Mar 11, 2013 at 11:05 AM 0
Share

This is not working. I think because if(input.getmousebuttonup(0)) is called only once. Even if the bool becomes true there will not be any change.

avatar image sparkzbarca · Mar 11, 2013 at 11:13 AM 0
Share

do you just want to remove that force?

colliderofobject.gameobject.rigidbody.addrelativeforce(-10,-10,-10);

or

colliderofobject.gameobject.rigidbody.gravity = true;

I'm not sure what your trying to accomplish.

however if you know how to remove it in the script itself like right after you do it.

Take that code, paste it into the if statement inside the ontriggerenter

that is on trigger enter check to see if what hit the trigger was this ball object and if it is. Begin messing with the ball now thats its at the trigger point.

avatar image united4life · Mar 12, 2013 at 05:33 AM 0
Share

Thanks for the answer. I have made force 0 by making rigidbody.velocity = 0. And now it is working exactly how i wanted.

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

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

Related Questions

Shoot projectile according to rotation 2 Answers

Shooting a cannonball. 6 Answers

How to control the speed of the projectile motion? 1 Answer

Firing projectile in curve 1 Answer

Setting limits to my trajectory 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