Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 BloodBTF · Jun 28, 2015 at 06:44 PM · scriptingproblem

How do I set the center of mass for my vehicle?

Im making a racing game and 7/8of my cars are working perfectly: what I mean is, they are driving well, their center of mass is good, but it comes down to one vehicle. See, im using the catamount car from unitys car tutorial asset with my own script. The driving is working well, but the problem is, whenever I turn hard to right/left, it just bicycles.(goes on 2 wheels.) I dont know,if its the COM, or a problem with wheel colliders. Heres a snippet of my COM code so you can see.

 #pragma strict
 var centerOfMass : Vector3
 function Start (){
 GetComponent.<Rigidbody>.centerOfmass = centerOfMass;
 SetValues();
 }
 

Comment
Add comment · Show 3
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 Cherno · Jun 28, 2015 at 07:39 PM 0
Share

I assume you set the centerOf$$anonymous$$ass values to something like (0, -0.5f, 0), right? Anyway, imagine sitting in a real car, driving fast and suddenly turning hard left or right, wouldn't the car go on two wheels or even flip? It's (kind of) realistic behavior, I would think. Also, I don't know about the car set up of the tutorial, but a real car also hass a suspension that helps in those cases.

avatar image Inok · Jun 28, 2015 at 08:03 PM 0
Share

Lowering center of mass is not best solution for making car stable if you want realistic car physics, but for arcade its ok. If you try turn at high speed you need reduce max angle of wheel rotation, so your max angle base on curent speed of car.

avatar image BloodBTF · Jun 28, 2015 at 09:47 PM 0
Share

$$anonymous$$y center mass is -0.5,-1.2,0. This works fine for me, but if i set the suspens ion to 0. But even this causes the car to act really weird. Also i forgot to mention that it lifts up even at lower speeds. I just need an, if you could, a solution, like increasing the mass of the wheel colliders, or maybe increasing the rigidbody mass, or interpolation? Thx anyway

1 Reply

· Add your reply
  • Sort: 
avatar image
7

Answer by UziMonkey · Jun 28, 2015 at 10:17 PM

The easiest way to do this is add a child empty object called Com or something. Then in your script set the empty's local position to the rigid body's center off mass. This makes it easily adjustable and not hardcoded, and the script that sets the center off mass will be reusable. Just remember to use localPosition, as the center of mass property will only work with local coodinates.

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 tutanchacon · May 02, 2021 at 03:14 PM 0
Share

I couldn't reposition my vehicle because it was twisting like a worm. It was from using position instead of localPosition. Thanks!

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

7 People are following this question.

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

Related Questions

Character and enemy don't damage each other 1 Answer

My camera is not working, nor are my bullets? 0 Answers

Assets/Scripts/Racing System/RacerPositionObject.cs(27,1): error CS0029: Cannot implicitly convert type `float' to `bool' 1 Answer

How to create a PNG / AI only with a script ??????? 1 Answer

Every script says "can not load script" and that there is no monobehavior in the file 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