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 shane.rachel · Nov 15, 2012 at 05:11 PM · charactercontrollervelocitylerp

Lerp can someone explain please

okay, so I've been trying hard to get my charactercontroller to lerp between it's current position and a position some distance away in the x direction. I have it to where it works now, except that it happens instantly. I would like a smooth transition, but it seems like nothing works, and when I follow others advice I end up with error codes that are impossible to resolve. There is NOT a lot of info on this subject, and the game engine doesn't recognize algebraic functions that dictate velocity over time.

could someone please fill me in on how to do this. any information or advice is helpful.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by kramcomposer · Nov 15, 2012 at 06:16 PM

You have a couple options, some not built into unity:

First, Ill explain how lerp works: Ill use Mathf.lerp for ease of understanding This is what Lerp basicly does internaly

SUDO CODE:

 float Mathf.lerp(float from, float to,float percent){
   differnce =  to - from;
   return = from + (differance*percent);
 }

So in otherwords, If you feed in 0.10 or 10% Lerp will move the from 10% closer to the to; so the thing to remember is the distance it moves gets smaller and small... IE: Lerp(100,0,0.1) = 90 , Lerp(90,0,.1) = 81 , Lerp(81,0,.1) = 72.9 , etc , etc

You may want to use Vector3.movetowards or Mathf.moveTowards you put in a from, and to positions, but instead of a % along path, it will never move faster than the speed you feed into it;

finanaly if you need a different solution such as smooth out, and smooth in. You may want to check out iTween : http://itween.pixelplacement.com/index.php

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 Loius · Nov 15, 2012 at 06:27 PM 1
Share

sudo movehowiwant

/nerdjokes :)

avatar image
1

Answer by kramcomposer · Nov 15, 2012 at 06:27 PM

you also said:

There is NOT a lot of info on this subject, and the game engine doesn't recognize algebraic functions that dictate velocity over time.

Also, to address this, You have to build you velocity over time around the update loop, meaning, you ether need to track time yourself using Time.time or Time.deltaTime or System.DataTime.Now

IE:

 public Vector3 myWorldVelecoity = new Vector3(10,0,0); //Move along the world X at 10 units per second                
 public void Update(){
     this.transform.Translate(myWorldVelecoity * Time.deltaTime);
     // OR
     this.transform.position = this.transform.position + (myWorldVelecoity * Time.deltaTime);
 }
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 shane.rachel · Nov 17, 2012 at 03:46 AM 0
Share

thank you, this is definitely what I needed, I can tweak it to work more appropriately but thanks for this starting point :)

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

11 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

Related Questions

CharacterController.velocity always return 0 0 Answers

How can I find the velocity on a rigidbody which moves using Lerp? 1 Answer

Apply force to character controller? 1 Answer

i am getting velocity when ever my player with character controller collides with a Enemy With character controller.kindly suggest me solutions. 0 Answers

Trying to Lerp knock-back on Character Controller 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