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
1
Question by W1k3 · Jul 06, 2013 at 04:39 AM · rotationpositionlerpangledegree

How to use the lerp function with rotation? (C#)

First of all, I'm kind of an idiot. I don't fully grasp the concept of position changing; rotating especially. I went ahead and replaced tranform.position with .rotate in the official unity lerp tutorial.

using UnityEngine; using System.Collections;

public class rotate : MonoBehaviour

{

 public float speed;
 
 private Vector3 newPosition;

 
 void Awake ()
 {
     newPosition = transform.rotate;
 }
 
 
 void Update ()
 {
     PositionChanging();     
 }
 
 
 void PositionChanging ()
 {
     Vector3 positionA = new Vector3(0, -20, 0);
     Vector3 positionB = new Vector3(0, 20, 0);
     
     if(Input.GetKeyDown(KeyCode.Q))
         newPosition = positionA;
     if(Input.GetKeyDown(KeyCode.E))
         newPosition = positionB;
     
     transform.rotation = Vector3.Lerp(transform.rotate, newPosition, speed * Time.deltaTime);
 }
 

}

Didn't work. Not too sure what I was expecting. If someone would be so kind as to show me the proper way to rotate and object to a degree with lerp, and better yet, explain how and why. It would be a huge step in my learning.

Thanks so much!

  • Michael

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 Kiloblargh · Jul 06, 2013 at 05:03 AM

"transform.rotate" isn't a thing.

"transform.Rotate" is a function.

"transform.rotation" is a Quaternion and should not be messed with.

"transform.eulerAngles" is what you want to be modifying.

(And the manual is that way—>.)

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 Lo0NuhtiK · Jul 06, 2013 at 05:06 AM 0
Share

Quaternion.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

16 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

Related Questions

How to get offset postition after rotation ? (Spent hours figuring it out) 3 Answers

Position from rotation problem. 1 Answer

How to get 0-360 bearing in 2D? 3 Answers

Mathf.Lerp not working 2 Answers

Quaternion lerp is not rotating my object to the desired rotation? 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