Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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
1
Question by Adeel1 · Jun 12, 2016 at 07:05 AM · c#physics

How to detect my car is drifting or not ?

I am making a drift game. I want to add score points and compliments on during the car drift. How can i detect now my car is drifting and now my car is going straight i-e not drifting ?

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 JedBeryll · Jun 12, 2016 at 07:13 AM 2
Share

Never done this but if you use wheelcolliders you could check if the back wheels are facing the same direction as the car rigidbody velocity? Or check if their difference is bigger than a few degrees.

avatar image Adeel1 JedBeryll · Jun 12, 2016 at 07:17 AM 1
Share

@JedBeryll This seems helpful. I will try this. Thank you so much. :)

avatar image Gummibeer JedBeryll · Aug 09, 2016 at 08:57 AM 0
Share

I also thought about something like this - thanks for verification! :)

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Edy · Aug 11, 2016 at 10:48 PM

Compute the dot product among the velocity vector (Rigidbody.velocity) and the car's heading (Transform.forward):

  • If result is 1, the car is just driving normally.

  • If result is 0, the car is sliding laterally.

Values in between can represent the amount of "drifting" of the car. You can also get the exact angle of drifting in degrees, and give more points with more angle and velocity:

 float driftValue = Vector3.Dot(GetComponent<Rigidbody>.velocity, transform.forward);
 float driftAngle = Mathf.Acos(driftValue) * Mathf.Rad2Deg;
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 meMUmar · Mar 11, 2017 at 10:31 AM 0
Share

Hi @Edy. I have tried it, but on reverse movement of car result is zero. I'm trying to count car drifts in a game and i am using car with RCC. Please help to sort out this issue. Thanks

avatar image vectorlabzunity · Jul 29, 2021 at 08:48 PM 0
Share

if you use normalized velocity then you will get more accurate results secondly @meMUmar when you reverse the car then you should multiply the transformed with -1 float driftValue = Vector3.Dot(GetComponent.velocity.normalized, transform.forward); float driftAngle = Mathf.Acos(driftValue) * Mathf.Rad2Deg;

avatar image
0

Answer by AnderSystems · May 17 at 04:25 AM

try this:

Vector3 driftValue = transform.InverseTransformVector(rb.velocity); _driftAngle = (Mathf.Atan2(driftValue.x, driftValue.z) * Mathf.Rad2Deg);

it returns the positive and negative angle of drifting value.

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

10 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to make a system that will let elements interact with other elements? 1 Answer

2d game platform physics 1 Answer

How to change CC script to Rigidbody script 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