Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Question about transform.rotation

Discussion in 'Documentation' started by CustardWallop, Sep 15, 2023.

  1. CustardWallop

    CustardWallop

    Joined:
    Aug 10, 2023
    Posts:
    1
    The documentation for transform.rotation at https://docs.unity3d.com/ScriptReference/Transform-rotation.html
    says "Do not attempt to edit/modify rotation".

    A few questions about this.
    (1) a large percentage of unity tutorials I find on the web do exactly this to rotate an object. Are they doing it wrong?
    (2) why is rotation publicly settable then?
    (3) the Unity documentation has an example:
    Code (CSharp):
    1. transform.rotation = Quaternion.Slerp(transform.rotation, target,  Time.deltaTime * smooth);
    Isn't that doing what they said not to do?
     
  2. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    746
    I think it means don't modify its components directly, since it won't behave as it looks in the inspector. But it's fine to modify its value as a Quaternion.