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 Bloke28 · Mar 31, 2018 at 02:24 AM · carvehiclestandard assets

Standard Asset Car won't shift past 3rd gear yet coding is set to 5 gears.

I'm using the standard asset car and it seems to have a bug which stops it shifting to 4th or 5th gear.. How can this be fixed? (Unity version Version 2017.4.0f1 (b5bd171ee9ba) Personal Wed, 14 Mar 2018 11:16:17 GMT Branch: 2017.3/release)

Thanks

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityStandardAssets.Vehicles.Car;
 
 public class GearManager : MonoBehaviour {
     public static int GearsValue;
     //public static int GlobalGears;
     public GameObject GearsDisplay;
     // Use this for initialization
 
     
     // Update is called once per frame
     void Update () {
         //if(CarController.m)
         GearsValue = CarController.m_GearNum + 1;
         GearsDisplay.GetComponent<Text>().text = "Gears: " + GearsValue;
     }
 }
 // Is the script to display gears to see.

Comment
Add comment · Show 1
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 Bloke28 · Mar 31, 2018 at 02:30 AM 0
Share

[SerializeField] public static float m_Topspeed = 200; and public static int m_GearNum;

were my only changes to the carcontroller script where I believe the problem may lie?

A$$anonymous$$A both were made static

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bloke28 · Mar 31, 2018 at 04:10 AM

         public Rigidbody objectToClock;
         public float maxVelocity = 100f;
         public float CurrentSpeednow;
         private void Update()
         {
             CurrentSpeednow = objectToClock.velocity.magnitude / maxVelocity;

             if (m_GearNum == 0 && CurrentSpeednow * 400 > (MaxSpeed / NoOfGears)) // max 200/5 = 40
             {
                 m_GearNum = 1; // 2nd gear
             }
             if (m_GearNum == 1 && (CurrentSpeednow * (400)) > (MaxSpeed*2 / NoOfGears)) // max 200/5 = 40
             {
                 m_GearNum = 2; // 3rd gear
             }
             if (m_GearNum == 2 && CurrentSpeednow * 400 > (MaxSpeed*3 / NoOfGears)) // max 200/5 = 40
             {
                 m_GearNum = 3; //4th gear
             }
             if (m_GearNum == 3 && CurrentSpeednow * 400 > (MaxSpeed*4 / NoOfGears)) // max 200/5 = 40
             {
                 m_GearNum = 4; //5th gear
             }
             if (m_GearNum == 4 && CurrentSpeednow * 400 > (MaxSpeed * 4.5 / NoOfGears)) // max 200/5 = 40
             {
                 m_GearNum = 5; //6th gear
             }
 
             if (m_GearNum >= 1 && CurrentSpeednow * 400 < (MaxSpeed / NoOfGears)) // max 200/5 = 40
             {
                 m_GearNum = 0; // 1nd gear downwards
             }
             if (m_GearNum >= 2 && CurrentSpeednow * 400 < (MaxSpeed*2 / NoOfGears)) // max 200/5 = 40
             {
                 m_GearNum = 1; // 2nd gear downwards
             }
             if (m_GearNum >= 3 && CurrentSpeednow * 400 < (MaxSpeed * 3 / NoOfGears)) // max 200/5 = 40
             {
                 m_GearNum = 2; // 3nd gear downwards
             }
             if (m_GearNum >= 4 && CurrentSpeednow * 400 < (MaxSpeed * 4 / NoOfGears)) // max 200/5 = 40
             {
                 m_GearNum = 3; // 4nd gear downwards
             }
             if (m_GearNum >= 5 && CurrentSpeednow * 400 < (MaxSpeed * 4.5 / NoOfGears)) // max 200/5 = 40
             {
                 m_GearNum = 4; // 5th gear downwards
             }
         }
         private void GearChanging()
         {
             /*
             float f = Mathf.Abs(CurrentSpeed/MaxSpeed);
             float upgearlimit = (1/(float) NoOfGears)*(m_GearNum + 1);
             float downgearlimit = (1/(float) NoOfGears)*m_GearNum;
 
             if (m_GearNum > 0 && f < downgearlimit)
             {
                 m_GearNum--;
             }
 
             if (f > upgearlimit && (m_GearNum < (NoOfGears - 1)))
             {
                 m_GearNum++;
             }
             */
             
             
         }
 

Rewrote the code and it works now :P

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 Bloke28 · Mar 31, 2018 at 04:31 AM 0
Share

Tweaked gear change times from there too...

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

75 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

Related Questions

fast forward physic vehicles 0 Answers

Vehicle programming source 5 Answers

Unity 5 Standard Asset Car Waypoint AI problem with accuracy 0 Answers

Any idea how to make an anti-lock braking system a.k.a. ABS? 1 Answer

Vehicle automatically accelerates with any input on Logitech G29 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