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 /
  • Help Room /
avatar image
0
Question by DwarvenGaming · Nov 02, 2016 at 05:29 AM · vector3quaternionquaternion.slerp

Lerping Quaternion Eulers.

Is there anyway to Lerp/Slerp these values so that it takes time to reach them, and it isn't just instant. Vector3 dir = target.transform.position - turretBase.transform.position; Vector3 dir1 = target.transform.position - turretGun.transform.position;

             Quaternion lookRot = Quaternion.LookRotation(dir);
             Quaternion lookRot1 = Quaternion.LookRotation(dir1);
 
             turretBase.transform.rotation = Quaternion.Euler(0, lookRot.eulerAngles.y, 0);
             turretGun.transform.localRotation = Quaternion.Euler(lookRot1.eulerAngles.x, 0, 0);
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 doublemax · Nov 02, 2016 at 07:51 AM

You can use Quaternion.Lerp or Mathf.LerpAngle

https://docs.unity3d.com/ScriptReference/Quaternion.Lerp.html

https://docs.unity3d.com/ScriptReference/Mathf.LerpAngle.html

Comment
Add comment · Show 2 · 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 DwarvenGaming · Nov 03, 2016 at 03:14 AM 0
Share

Yes but I don't understand how I could implement a lerp to my code so that it's a smooth and not instant transition.

avatar image doublemax DwarvenGaming · Nov 03, 2016 at 11:37 AM 0
Share

This is usually done in a coroutine.

Here's a sample that moves one gameobject to a new position over time:

  IEnumerator $$anonymous$$oveObjectToPosition( Transform trans, Vector3 end_position, float duration )
  {
    Vector3 start_position = trans.position;
    float elapsed = 0.0f;
    while( elapsed < duration )
    {
      trans.position = Vector3.Lerp(start_position, end_position, elapsed / duration );
      elapsed += Time.deltaTime;
      yield return null;
    }
    trans.position = end_position;
  }

Alternatively i would recommend the "iTween" asset which is free and solves these kind of problems with a one-liner: https://www.assetstore.unity3d.com/en/#!/content/84

Another options is "LeanTween" which i have never used myself though. https://www.assetstore.unity3d.com/en/#!/content/3595

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

84 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

Related Questions

Look Rotation Viewing Vector is Zero 0 Answers

Maintaining look at target between two cameras 1 Answer

Rotate clockwise/counterclockwise using Quaternion.Slerp() 0 Answers

Rotational Velocity, Quaternions, Vector3 & Transfrom.rotation - Help 1 Answer

Quaternion.AngleAxis multiplied by vector gives wrong result 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