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 me136703 · May 16, 2020 at 12:31 PM · vector3physics.raycast

How to lock a vehicle to a curve normal in two dimensions?

I realise that the question isn't a very good explanation so I've included a picture. I would like a vehicle (which is floating above the ground) to be locked to the curve of the ramp all the way around, and also to the yellow lines in order to stay perpendicular to the centre of the circle of which the ramp is the radius. alt text

I've kind of fixed the first part with this code from another thread:

  RaycastHit hit;
  if
  (Physics.Raycast(transform.position, -curNormal, out hit)){
       curNormal = Vector3.Lerp(curNormal, hit.normal, 4*Time.deltaTime);
       Quaternion grndTilt = Quaternion.FromToRotation(Vector3.up, curNormal);
       transform.rotation = grndTilt * Quaternion.Euler(0, curDir, 0);

I tried to fix the issue with this code but it hasn't worked:

  Vector3 fromCentre = new
  Vector3(34.16f, 23.05f, 60.66f);
          Vector3 centreToShip = (transform.position - fromCentre);
          Vector3 shipNormal = (hit.normal);
          Debug.Log(shipNormal);
          //matches vehicle to normal of ramp (vertical)
          curNormal = Vector3.Lerp(curNormal, shipNormal, Time.deltaTime);
          Quaternion grndTilt = Quaternion.FromToRotation(Vector3.up, curNormal);
          transform.rotation = grndTilt;

I would really appreciate any help or direction with this.

screenshot-2-compress-min.png (274.5 kB)
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 viesc123 · May 29, 2020 at 05:31 PM 0
Share

Can you pls clarify: Do you want to create a scripted animation along the road and calculate the vehicles position, rotation and speed or are you working on a vehicle-controller and want to calculate the next position on the track according to some user-input?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by misun1191 · May 29, 2020 at 04:09 PM

I'm also searching answers for the same question. I haven't found a definite answer, but this thread contains lots of helpful comments. https://forum.unity.com/threads/how-in-the-world-were-the-physics-in-f-zero-x-done.204747/?_ga=2.122614923.1056452554.1590671745-1716890399.1557168250

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

158 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

Related Questions

Problem with converting RaycastHit to Vector3 2 Answers

Trying to click an object and have that object see what objects are near it and manipulate them based on certain rules 0 Answers

Raycasts in opposite directions only returning RaycastHits on right 1 Answer

Offsetting Raycasting 1 Answer

Relative Rotation 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