• 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 Juan Santos · Apr 04, 2015 at 08:47 PM · force

Add force to slow down object

Hi, I'm trying to find a way to slow add a force to slow down (for a brief instance) my object upon collision. Think of a racing game, where if you hit a rock you decelerate a little bit for a moment.

This is my what I currently have related to the movement.

     void FixedUpdate () {
         GetComponent<Rigidbody>().AddForce (Vector3.forward * constantVelocity, ForceMode.Impulse);
     }
     void OnTriggerEnter(Collider other)
     {
         if(other.tag == "SpeedBoost")
         { 
             GetComponent<Rigidbody>().AddForce (Vector3.forward * 100.0f, ForceMode.Impulse);
             print("Hit Speed!");
         }
         if (other.tag == "UpBoost")
         {
             GetComponent<Rigidbody>().AddForce(Vector3.up * 100.0f, ForceMode.VelocityChange);
             print("Hit Up!");
         }
             if (other.tag == "Obstacle")
             {
                  //add negative force to decelerate/
                  GetComponent<Rigidbody>().AddForce (Vector3.forward * -100.0f, ForceMode.Impulse); //not working.
             }

     }
 }

Thanks.

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 SheldonS · Sep 28, 2019 at 11:02 AM

I know this is really old but I ran into this as well. This is how I handled it;

     public void SlowDown()
     {
         Vector2 pushBack = targetRigidBody2D.velocity * -1;
         targetRigidBody2D.AddForce(pushBack * .01f, ForceMode2D.Impulse);
     }
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 axelforsberggg · May 03, 2020 at 06:23 PM

line 18 try doing Vector3.-fordward

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.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Help with player movement and adding force to a ball. 1 Answer

How can i set AddRelativeForce relative to how fast/slow im moving my mouse? 2 Answers

Force input on Button? 1 Answer

Adaptive Force smoothing? (Updated) 0 Answers

crush object based on pressure/weight from sides 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