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 /
avatar image
0
Question by imM4TT · Jan 26, 2018 at 02:22 PM · transformsmoothly

Smoothly transform forward ?

Hi I'm currently trying to update the transform of my game object with that Vector3.Lerp.
Before trying to implement that Lerp effect my transform scritp was this one :

 ship.transform.Translate(Vector3.forward * currentSpeed * Time.deltaTime);  

Now I tried this but that not work :

 public Vector3 destination;
     private void Start()
     {
         Photonview = GetComponent<PhotonView>();
         if (Photonview.isMine)
         {
             destination = transform.position;
         }
     }

 private void Update()
 {
   destination += ( Vector3.forward * currentSpeed );
   ship.transform.position = Vector3.Lerp( Vector3.forward, destination, 0.5f * Time.deltaTime );
 }

Any idea please ?

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

· Add your reply
  • Sort: 
avatar image
0

Answer by gordiri · Jan 26, 2018 at 02:26 PM

You are using Lerp wrong. Lerp interpolates between first and second parameters. You should pass as first parameter ship.transform.position instead Vector3.forward

Comment
Add comment · Show 5 · 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 imM4TT · Jan 26, 2018 at 02:56 PM 0
Share

Yep I can see that Lerp effect works but now my GameObject which have the script attached to is moving to the left.
It's probably because the destination var, is there any way to says " ship.destination += his destination " ?
Thank !

avatar image gordiri imM4TT · Jan 26, 2018 at 03:04 PM 0
Share

It can move left bc you are using Vector3.forward which is always (0, 0, 1). I think you should use
transform.forward

avatar image imM4TT gordiri · Jan 26, 2018 at 03:09 PM 0
Share

All right thx !

Show more comments
avatar image Commoble · Jan 28, 2018 at 01:47 AM 0
Share

That's still using Lerp wrong. You shouldn't pass in Time.deltaTime as the third parameter. The third parameter is a value between 0F and 1F, and Lerp (a, b, x) returns a if x == 0, b if x == 1, and a weighted value between a and b if x is between 0 and 1. $$anonymous$$eanwhile, Time.deltaTime returns the amount of time the last Update loop took; if your game is running at 60 frames per second, it'll return roughly (1F/60F), making it pointless to use with Lerp.

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

97 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

Related Questions

How can I rotate the transform by a specific angle at a certain speed? 2 Answers

Instantiated object's transform changes according to parent object's rotation 1 Answer

Children's position going haywire (Unity bug?) 1 Answer

Make a GameObject a Child of What it Collides With 2 Answers

Adding data to a set of transforms 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