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 TurboHermit · Nov 30, 2012 at 08:58 AM · vector3lerptargetlookrotation

Lerp problem

Hi I have a snippet of code wherein a target goes to mouse position and another object looks at it.

                     if(Input.GetMouseButton(0)){
                         var temp = Input.mousePosition;
                         var New = Camera.main.ScreenToWorldPoint(temp);
                     }
                     Target.transform.position = Vector3.Lerp(Target.transform.position, Vector3(New.x,New.y,0), 1);    
                     
                     ThisTransform.rotation = Quaternion.LookRotation(Target.position);

If I do it like that, the target will pop to the center of the screen after a second or so. What causes the target to go to the center? If I put the Lerp in the if statement it doesn't pop back to the center. What am I missing?

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
Best Answer

Answer by fafase · Nov 30, 2012 at 09:04 AM

Yep check this one:http://unitygems.com/mistakes1/ Find the How to move with Vector3.Lerp section.

Your issue is the 1 as ratio parameter. It means full move at once.

Comment
Add comment · Show 7 · 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 TurboHermit · Nov 30, 2012 at 09:09 AM 0
Share

No that's not the issue. I have it on 1 for testing purposes. And it does move at once, which is fine for now, but after the movement is complete, the target that moves just goes to the center of the screen.

avatar image fafase · Nov 30, 2012 at 09:14 AM 0
Share

Does the target has other scripts on?

avatar image TurboHermit · Nov 30, 2012 at 09:18 AM 0
Share

Nope, nothing outside of this script is manipulating Target, it doesn't have a rigidbody or collider attached to it and the only recurring code snippet for Target is when I declare it in Start().

avatar image TurboHermit · Nov 30, 2012 at 09:20 AM 0
Share

I have found that the variable New goes back to 0,0,0 at that time.

avatar image TurboHermit · Nov 30, 2012 at 09:22 AM 0
Share

And so does the mouseInput

Show more comments

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

12 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

Related Questions

Using Lerp in a Constant Moving Object 1 Answer

LookRotation Vector3 is Zero, Yet Slerp Still Rotates? 2 Answers

Not Sure How to Get Around this Problem 1 Answer

Vector3.Lerp making my object invisible. 2 Answers

Object movement with smooth start and end? 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