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 siddharth3322 · Apr 21, 2014 at 07:38 AM · rigidbodyvelocityforceunity4.3

Apply Constant Force

I want to apply constant force to game object which has rigid body attached. But I found that after applying continuous force to game object, game object's speed increased per frame. That I have checked through printing velocity of game object.

I have used following code.

 private Vector2 force;
     public float speed, downLimit;
 
     void Start ()
     {
         force = new Vector2 (speed, 0f);
     }
 
     void FixedUpdate ()
     {
         rigidbody2D.AddForce (force);
         print ("bird velocity : " + rigidbody2D.velocity);
         CheckForDownLimit ();
     }
 
     private void CheckForDownLimit ()
     {
         Vector3 birdPosition = transform.position;
         if (birdPosition.y < downLimit * -1f) {
             force.y = speed * Constants.VERTICLE_SPEED;
         } else if (birdPosition.y > downLimit) {
             force.y = -speed * Constants.VERTICLE_SPEED;
         } else {
             force.y = 0;
         }
     }

I want to move my game object with same speed at any level of game not with continuous increasing speed.

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

Answer by mattyman174 · Apr 21, 2014 at 07:46 AM

Just check if the Velocity of your Rigidbody is going to exceed a maximum value and then just set it to that maximum if it does.

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

Answer by HarshadK · Apr 22, 2014 at 12:52 PM

Instead of using the force you can use MovePosition to move your rigidbody. Using MovePosition will ensure that the physics is also calculated as you want it to be since you are using force.

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 siddharth3322 · Apr 22, 2014 at 05:44 PM 0
Share

Thanks for your answer. I got some new point from it. But I want to use physics behaviour so I mark first answer as correct one but up vote your suggestion also.

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

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

Related Questions

relative velocity of rigidbody according to rotation... 1 Answer

How to change velocity of object which move by Rigidbody. 1 Answer

Gravity doesn't work 2 Answers

How do I move this rigidbody? 1 Answer

Gravitational Object Creation for 3D Game 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