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 samz · Jun 25, 2012 at 12:14 PM · lerpropeclimb

Lerp doesnt seem to work

i have a rope with 12 empty gameobjects with triggered colliders. when the user presses the up and down arrows the players position is changed to that of the triggered colliders and this allows me to climb up and down.

How the problem is that is travels up and and down too fast when holding down the buttons and i cant seem to slow this down...any ideas? tried lerping but that didnt fix it at all

EDIT: HERES IS MY CODE

 // Moving up and down the Vine
 if( Input.GetKey("up") )
 {
         playerTransform.position            =    Vector3.Lerp(playerTransform.position, curSegment.position, 50);
         playerTransform.transform.parent    =    curSegment.transform;
 }
Comment
Add comment · Show 5
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 delstrega · Jun 25, 2012 at 12:20 PM 1
Share

Since the 't' parameter of lerp controls the resulting value it should normally work as intended if the formula for calculating 't' is chosen correctly. Could you provide some code so we can check what's going wrong?

avatar image samz · Jun 25, 2012 at 04:09 PM 0
Share

thanx, i put my code up now :)

avatar image Wolfram · Jun 25, 2012 at 04:13 PM 0
Share

You are using a fixed value of 50 for the third parameter, which must be between 0 and 1 (values >1 will be clamped to 1). The way that Lerp is "abused" most often is by applying a value of Time.deltatime*arbitraryFactor ins$$anonymous$$d (assu$$anonymous$$g yuo are doing this in Update(), otherwise it won't work), which will smoothly transform from parameter 1 towards parameter 2.

avatar image samz · Jun 25, 2012 at 04:18 PM 0
Share

oh, i was doing it in another funciton. my own function. ah ok...im trying to get the slowest movement so i thought a high number will get me that result

avatar image Wolfram · Jun 25, 2012 at 04:22 PM 0
Share

It is explained in the docs.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by flamy · Jun 25, 2012 at 12:32 PM

usually the t parameter of lerp will take a value of 0 to 1. so if you want your object to reach the destination in 3 seconds, what you should be doing is

first on keypress save the time,

 float initialTime=Time.time;

and in update or somewhere call this,

 float t=(Time.time-initialTime)/3.0f;

and pass the value to as the parameter to Lerp function.

so the general formulae should be

 (finalTime-initialTime)/duration;

make sure that the initialTime is global and is set only when the keypress happens.

Comment
Add comment · Show 1 · 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 samz · Jun 25, 2012 at 04:09 PM 0
Share

thnx ill have a try at this and will let you know

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to rope climb 0 Answers

Climbing up solution 0 Answers

How to climb a rope? 1 Answer

MoveTowards based on time 2 Answers

Movement (left/right) and jumping = laggy motions.. please help! 0 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