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 May 17, 2019 at 02:50 AM by knuckles209cp for the following reason:

Other

avatar image
0
Question by knuckles209cp · Apr 16, 2019 at 01:11 PM · javascriptplayercurvesplinerail

Keep object on rail?

I am creating a snowboarding game, I would like the snowboarder to be able to jump onto a rail and stick on it if hes holding c. I can't think of any possible way to do this with my knowledge and I can't find anything similar online with any sample code. If my character touches the rail, It should be center locked on it until the end of it or until he jumps off.

For reference, Im aiming for this ( go to 5:54 ) : https://www.youtube.com/watch?v=cjXlBHEzTXQ

Any help will be appreciated, Will give points to anyone who can help me with a starter code too ( JAVA SCRIPT )

Thanks

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
1

Answer by highpockets · Apr 16, 2019 at 02:44 PM

I would suggest that you get whatever the direction of the rail is running parallel to in world space and when the snowboard’s bottom collides with the rail and the player is pressing the C button, then keep your player constrained to only move in that direction.

I think you should try to do something with that info and come back showing some coding attempt if it doesn’t workout and then we can help out.

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 knuckles209cp · Apr 16, 2019 at 11:01 PM 0
Share

Hi, Thanks for the response.

I am wanting to have curved rails ins$$anonymous$$d of one direction. I have no clue how to make it follow a curve.

avatar image knuckles209cp · Apr 17, 2019 at 03:05 AM 0
Share
 if(OnRail == true){
 GetComponent(TrailRenderer).enabled = true;
 snowTrail.active = true;
 var hitRail : RaycastHit;
      if (Physics.Raycast(transform.position, Vector3.down, hit)) {
          var distanceToRail = hitRail.distance;
         transform.rotation = Quaternion.FromToRotation(transform.up, hitRail.normal) * transform.rotation;
          Snow$$anonymous$$esh.transform.rotation = Quaternion.FromToRotation(transform.up, hitRail.normal) * transform.rotation;
          distToGround = distanceToRail;   
 
     }  
 }
avatar image highpockets knuckles209cp · Apr 17, 2019 at 12:37 PM 0
Share

That’s definitely a little more difficult. But is it possible to setup waypoints within the curve. Then get the direction from the closest waypoint to the next waypoint in line and once you reach the next waypoint you get the direction from that waypoint to the next, etc.. Either that or you could setup some pivot points to rotate around, the pivot point would obviously have to be the same distance away from any point in the curve.

Follow this Question

Answers Answers and Comments

170 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Curved transform.translate 1 Answer

Pause online game 1 Answer

Spline Controller (javascript) error 2 Answers

how to continue spline? 0 Answers

How can I zoom out my Field of View slowly? 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