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
1
Question by Shadyfella13 · Dec 24, 2009 at 08:28 AM · vehiclesteering

How can I set up a tank steering mechanism?

Here is the basic formula I want to use, (thank you mooserman352 @ gamedev.net)I am just not sure how to write it in JavaScript.

Let R be the radius of the circle, the distance from the turning point to the center of the tank. Let D be the distance from the center of the tank to each tread. Suppose you wait for some time T, so that the tank makes a nice complete circle around the turning point. The outer track has drawn out a circle of radius (R+D) and length 2*pi*(R+D), and the inner track a circle of radius 2*pi*(R-D). Since 2*pi*(R+D) = V1*T and 2*pi*(R-D) = V2*T, (R+D)/V1 = (R-D)/V2. Solving for R*(1/V1 - 1/V2) = D*(1/V1+1/V2). Seems reasonable, if v1 = v2, R=infinity; if v1 = -v2, R=0.

My previous attempts were either a total disaster, or more like normal car movement. Can anyone help me out with this? Thanks.

Scripting noob

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

Answer by duck · Dec 24, 2009 at 10:06 AM

To be honest, those formulas are making my eyes boggle slightly. I'm sure they're probably correct, but often in Unity you don't really need to do these kind of complex calculations yourself because you have a physics engine at your fingertips which can do it all for you.

There are a number of ways you can do tank-like movement:

  • Simply use AddTorque to rotate your tank, combined with AddForce to push it backwards or forwards
  • Use AddForceAtPosition to add a force at each side of the tank, relative to how fast each track is moving
  • Use a row of wheel colliders along the base of each track, and apply motorTorque to them, to simulate the power of each track)

I recently used this 3rd method to simulate the tracks of an excavator, however I didn't tackle the 'driving in a circle' problem. In mine, you could simply drive forward, backward, or rotate on the spot. Of course, you could use free-rolling wheelcolliders combined with either of the first two methods, so that your tank rolls properly (and perhaps just apply brakeTorque when necessary), but you apply force to the body to get it moving.

Comment
Add comment · Show 2 · 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 Shadyfella13 · Dec 24, 2009 at 10:42 AM 0
Share

Thanks Duck! I am having a go at it now.

avatar image Shadyfella13 · Dec 24, 2009 at 12:48 PM 0
Share

The wheel colliders method worked great.. it just took some time to set it up properly. Thanks again Duck. ;)

avatar image
1

Answer by Ricardo · Feb 10, 2010 at 10:53 AM

Wee bit late of an answer, but...

It would seem that you could also use the UnitySteer classes to implement the forces. I would suggest creating a vehicle that has two different steering calculations, one for each track, and mix the forces depending on how much work each track is doing.

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

No one has followed this question yet.

Related Questions

car accelerates too slow ? 0 Answers

Steering an AI vehicle to a waypoint using float of -1 to 1? 1 Answer

Creating a magnetic vehicle (like F-Zero) 1 Answer

vehicle stops when colliding with ramp 1 Answer

How to simulate a vehicle moving only by moving terrain with itween/waypoints? 0 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