Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 mabit · Jul 09, 2014 at 10:21 AM · rotateturningover time

Stay in a pipe

I am working on a game where players fly on rails through a pipe.

The solution I have at present is that when you approach a turn you hit a trigger and turn 90 degrees over time. This works as long as the turn is 90 degrees and only at one speed.

I am looking for some suggestions of a better way of doing this so I can have any shape turn at any speed.

Below is a video of the prototype

https://www.youtube.com/watch?v=ikjEM1xlXHg

Any help is most appreciated.

Kenny

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 mabit · Jul 10, 2014 at 02:08 AM 0
Share

If you are giving an answer please can you provide some code too. I am not the strongest coder.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Armand · Jul 09, 2014 at 10:31 AM

One way to accomplish that would be to cast a ray to either side of the bend. Make the player ship keep a constant distance from the hit point of the raycast, and rotate the ship so that its rotation is perpendicular to the surface normal of the raycast hit point on the matching axis. This way it will work inside any pipe, though you have to make sure you are casting rays on the right plane - that is, if the bend turns left or right, you have to shoot the ray left or right, not up or down.

Comment
Add comment · Show 4 · 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 mabit · Jul 09, 2014 at 10:52 AM 0
Share

Thanks for the reply.

I think I understand what you are saying. To take that a step further could that work by raycasting in all 4 directions (up, down, left, right) then by taking the sharpest normal from the sharpest angle as that would be the inside turn.

The reason I am saying this is that once you start turning up and around in the pipe a left turn is not always a left turn it depends on where you are in the space. It was one of the headaches when designing the Jam level.

avatar image Armand · Jul 09, 2014 at 11:05 AM 1
Share

That is indeed true, which is why you should use the local space of the ship, and translate the surface normal to that space as well. Then it won't matter how the ship is rotated in relation to the world space.

Also, you could cast rays to four directions like you said, but keep left/right and up/down separate. That way you can make bends that turn both left AND up, or right and down, and so on. Just turn the ship on the corresponding plane independent of the perpendicular plane.

avatar image mabit · Jul 09, 2014 at 11:08 AM 0
Share

Thanks for the answers. Will have a look at coding that.

avatar image mabit · Jul 10, 2014 at 02:35 AM 0
Share

I have spent a few hours working on this. I can get the normal from the hit.normal, but its very jerky.

Do you have a small code example to show how to do this?

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

22 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

Related Questions

How do I rotate my character smoothly? 1 Answer

Rotate object horizontal with local position and localrotation 0 Answers

Flip over an object (smooth transition) 3 Answers

How can I rotate a Transform over time? 1 Answer

Rotate Texture Over Time 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