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 /
  • Help Room /
avatar image
1
Question by goutham12 · Nov 08, 2017 at 05:28 AM · rotationtransformpositiontranslate

Car Controls without physics.

I need to Controls to my car with out rigid body. simply using trasform.traslate and rotate. here is what i did.

accelarationInput = Input.GetAxis ("Vertical");

SteerAngle = Input.GetAxis ("Horizontal");

transform.Translate (0, 0, Speed * Time.deltaTime);

transform.RotateAroundLocal (Vector3.up, SteerAngle Speed 0.03f * Time.deltaTime);

but it is not giving realistic motion it is simple traslating and the rotation also bad.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by goutham12 · Nov 08, 2017 at 02:44 PM

 public float accelarationInput;
 public float SteerAngle;
 public float gravity;
 public float Speed;
 public GameObject Pivot;


 void Update () {
     UpdateAccelaration ();
     UpdateSteerAngle ();
 }

 void UpdateAccelaration()
 {
     if (Application.platform == RuntimePlatform.WindowsEditor) {
         accelarationInput = Input.GetAxis ("Vertical");
     } 
     if (accelarationInput > 0) {
         Speed += Time.deltaTime * 40;
         if (Speed > 100) {
             Speed = 100;
         }
     } else if (accelarationInput == 0) {
         if (Speed > 0) {
             Speed -= Time.deltaTime * 25;
             if (Speed < 0)
                 Speed = 0;
         }if (Speed < 0) {
             Speed += Time.deltaTime * 25;
             if (Speed > 0)
                 Speed = 0;
         }

     } else {
         Speed -= Time.deltaTime * 25;
         if (Speed < -60)
             Speed = -60;
     }
     transform.Translate (0, 0,  Speed* Time.deltaTime);
 }


 void UpdateSteerAngle()
 {
     
     if (Application.platform == RuntimePlatform.WindowsEditor) {
         SteerAngle = Input.GetAxis ("Horizontal");
     } else {
         SteerAngle = simpleJoystick.instance.H / simpleJoystick.instance.Radius;
     }

     transform.RotateAround(Pivot.transform.position,transform.up,SteerAngle * Speed/2 * Time.deltaTime);
 }


it works great. if you don't want to use physics in your car this is the best start up.

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

163 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 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

How to translate an object in an unknown angle ? 1 Answer

transform.Translate() effect is being reverted 0 Answers

How do I change the position of my player model after I rotate it so it's not teleporting? 0 Answers

How to transform a GameObject to an Empty GameObject's position and rotation 1 Answer

Why does my weapon rotation change after hitting play? 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