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 20, 2019 at 02:58 PM by LittleJ for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by LittleJ · Dec 19, 2019 at 05:38 PM · spline

Movement On Spline

Hello,

Its just a quick question. I am creating a sort of "Runner" Game where the player moves along a spline.

My end goal is to be able to have the player switch from center, left and right.

I have 2 ideas which I would be grateful for advice on how to make possible.

Idea 1: Keep just the one spline however jumping from each position (Left , Center, Right) would be controlled by an offset still following the center line just more to the left or right. Im not sure how I can achieve this as my player follows the spline perfectly no matter how i alter vector updates.

Idea 2: Have 3 splines and when the player switches track it jumps to the other spline however I am not sure if this is possible.

If I could get any advice on how to achieve this I would be very grateful.

Thankyou

P.S I code in c sharp, I do not want the player to have full movement just the ability to switch from Left right and center tracks with the keys ASD. 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
0

Answer by Statement · Dec 19, 2019 at 05:52 PM

Splines are a bit tricky as "tavelelled distance" along them may vary a bit depending on the curve of the spline but simply changing between them shouldn't be that hard.


Supply a variable, let's say trackFactor which goes from 0 to 1, where 0 is left track, 0.5 is middle track and 1 is right track. Then, calculate the position of each track based of your distance travelled so you get three position, say positionLeft, positionMiddle, positionRight for example. Then, lerp between each position. For example if trackFactor is between 0 and 0.5, multiply trackFactor with 2 so it ranges between 0 and 1, then use that as a parameter to lerping between positionLeft and positionMiddle. trackFactor you'd change based on which track you want the character to move along. I'd assume you'd make a quick lerp or such between trackFactor 0, 0.5 and 1.0 to let the system know which track you want to run along.

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

Follow this Question

Answers Answers and Comments

117 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

Related Questions

object follow a spline path 1 Answer

Player Camera Spline messes up camera direction 0 Answers

How do i create points along a spline??? 0 Answers

(unity 3d) Trying to make rail griding/sliding mechanic using PathCreator asset. 0 Answers

how to start "spline controller" with trigger? 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