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 Nafis1053 · Dec 09, 2018 at 01:07 PM · 2d game2d-physics

How to use centerOfMass of rigidbody properly??

Hi guys!...I am new to unity and am currently working on a 2d game...it's a shooting game where my character can move both ways(left and right),jump,and shoot......the player object has a box collider attached with it...the problem is when i move the character around,sometimes(actually often) due to some sort of inertia effect the character seems to lose its balance and fall on the ground.....like if it has a rectangular collider attached with it..it simply lies down on the ground.....I need to make the player more stable....so I thought if i changed it's centre of mass and brought it closer to the ground or feet of the character..that might solve the problem...I wrote a part in the script to change its centre of mass like this....

 rb2d=GetComponent<Rigidbody2D> ();
     rb2d.centerOfMass=transform.Find("Floor_position").position;

here "Floor_position" is an empty child game object of the player game object and it determines the new centre of mass of the player... the problem is whenever i run the game....some invisible force seems to carry the player off the ground and place it in a different position......and the rectangular box collider attached with the player simply lies down from the very beginning.....need help....thanks in advance.....if i am not clear enough...i can post pictures of the situation in more detail....

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 Marioooo · Dec 09, 2018 at 03:07 PM

if you are making a character that must keep standed, on the rigidbody you attached, you must chang the value of the option called "angular drag" to Zero. with that option, the object will never rotate unles you do it on code, if wou want a low rotation, just use a very low value, like 0.01 Good Luck!

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 Nafis1053 · Dec 09, 2018 at 03:30 PM

@Marioooo Thanks for ur reply....i have done what you have told...but i think my problem was a bit different all along...decreasing the angular drag makes it hard to rotate...but i need my character to stay standing /alligned at all times...when it falls from an edge in the game, or i start moving it while it was standing in an inclined place...it starts to rotate again.

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 Marioooo · Dec 09, 2018 at 03:39 PM 0
Share

in that case, you maybe should create your own physics system... but with this approach you will need to use a capsule collider to climb up an inclinated place..

https://unity3d.com/es/learn/tutorials/topics/2d-game-creation/intro-and-session-goals?playlist=17093

this is a official tutorial, check it out to create yor own physics system.. Good Luck and $$anonymous$$eep Creating!

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

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

Related Questions

Brick Breaker - Ball not bouncing back from the brick. 2 Answers

Rigidbody and Collision choices for 2D Adventure 0 Answers

The player randomly freezes in place while other objects move ingame 1 Answer

Best way to rotate around a point with a RigidBody 2 Answers

How do you make a car drift in unity 2D 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