Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 42p · Nov 29, 2016 at 08:16 AM · rigidbodyvelocityforcerigidbody.addforcedynamics

Rigidbody velocity has got different direction than VelocityChange force vector

I want my GameObject to move to direction +y direction with a constant speed.

I chose to apply VelocityChange type fordce to a rigidbody. The force applied: (0,10,0) The Rigidbody properties: mass of 1, Use Gravity: false, Is Kinematic: false.

 public class moveForward : MonoBehaviour 
 {    
     public Vector3 force;
     
     void Start () 
         {
             print("v0: " + GetComponent<Rigidbody>().velocity);
         
             GetComponent<Rigidbody>().AddForce(force,ForceMode.VelocityChange);
         
             print("f: " + force);
     }
     
     int fuCounter = 0
 
     void FixedUpdate()
     {
         if(0==(fuCounter%50))
         {            
             print("v: " + GetComponent<Rigidbody>().velocity);
         }
         ++fuCounter;
     }
 }
   

My expectation was that I measure a velocity which equals the velocity vector I added, namely (0,10,0). Instead I got (0.0, 9.0, -1.1).

v0: (0.0, 0.0, 0.0)

f: (0.0, 10.0, 0.0)

v: (0.0, 0.0, 0.0)

v: (0.0, 9.0, -1.1)

v: (0.0, 9.0, -1.1)

...

The force and velocity vector do not point into the same direction:

alt text

What is the reason of this difference?

20161128.png (44.5 kB)
Comment
Add comment · Show 5
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 Glurth · Nov 30, 2016 at 07:04 AM 0
Share

something else is going on. I just tested your code in an otherwise empty scene and it worked fine. v: 0,10,0

avatar image Link0n3 · Dec 01, 2016 at 03:42 PM 0
Share

@42p Have you checked you did not change the center of mass of the object? As far as I remember it should be (0,0,0) as it is a relative coordinate to the transform position

avatar image Bunny83 Link0n3 · Dec 01, 2016 at 04:28 PM 1
Share

Changing the center of mass doesn't change anything in this case. AddForce always applies the force at the center of mass. AddForce itself does never change the angularVelocity, only AddForceAtPosition would cause this.

If the velocity doesn't match the given force direction there must be another force applied. $$anonymous$$ost likely a collision with another object. $$anonymous$$aybe the object is spawned / positioned so it overlaps another collider.

avatar image Link0n3 Bunny83 · Dec 01, 2016 at 05:25 PM 0
Share

You are right, I have done a mistake. I never realized that AddForce never change the angularVelocity. Very interesting anyway.

avatar image 42p · Dec 05, 2016 at 06:40 AM 0
Share

Thank you for your help. It turns out I had the collider of the plane on the picture enabled. The cylinder and the plane collided on a small area.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by 42p · Dec 05, 2016 at 07:33 AM

I managed to get rid of the problem. I disabled the collider of the plane, which I forgot to do before. Now it works fine.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can you apply force or set the velocity of a rigidbidy on local axis? 1 Answer

Rigidbody Character 1 Answer

How to get collision force, not relative velocity? 1 Answer

relativeVelocity how to? (noob question) 2 Answers

AddForce doesn't work when used with velocity 3 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