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 /
This question was closed Dec 02, 2015 at 08:27 AM by Taza494 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Taza494 · Aug 21, 2015 at 11:14 AM · c#physicscar game

Drifting code not 100% accurate?

I'm trying to check if the car is facing the forces direction. but the two angles are always offset by around 3%-5% when driving in a straight line. Any help would be appreciated as this has halted the progress of my project.


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

  • Sort: 
avatar image
0

Answer by VesuvianPrime · Aug 21, 2015 at 12:39 PM

Perhaps instead of trying to reinvent the wheel just use Vector3.Angle

 Vector3 forward = car.transform.forward;
 forward.y = 0.0f; 

 Vector3 velocity = car.rigidbody.velocity;
 velocity.y = 0.0f;

 float angleVelocityOffset = Vector3.Angle(forward, velocity);

 if (angleVelocityOffset > 60)
 {
     //car is drifting
 }

Comment
Add comment · Show 3 · 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 Taza494 · Aug 21, 2015 at 02:47 PM 0
Share

The angleVelocityOffset seems to stick at 90 no matter what I do? Not sure if this is due to my setup or the code. (This is a topdown setup)

avatar image VesuvianPrime · Aug 21, 2015 at 05:29 PM 0
Share

I would be interested to see the hierarchy of your car objects. Do the rigidbody and transform belong to the same GameObject?

avatar image Taza494 · Aug 22, 2015 at 03:13 AM 0
Share

alt text

2015-08-22-12-42-02-unity-personal-64bit-mainscene.jpg (155.9 kB)

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Making car shift gears without set speed limit 1 Answer

Multiple Cars not working 1 Answer

Similar movement to a game (look description) 1 Answer

Rotating an Arrow 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