Unity Community


Results 1 to 5 of 5

  1. Location
    Australia
    Posts
    261

    Quaternion/Vector 3 rotate/rotation

    Read the comments in //below

    Code:  
    1. var spawnRot : Quaternion;
    2.  
    3. function Start () {
    4. spawnRot = transform.rotation;
    5. }
    6.  
    7. function Update () {
    8. //if something then do following
    9. //narrowed code down to simplify problem
    10. transform.rotation = spawnRot;
    11.  
    12. //would like to slerp/gently rotate transform towards spawnRot - however transform.Rotate is vector3 and cannot
    13. //didn't quite understand quaternion.operator* in docs
    14. //an example would be great ;)
    15. }

    Cheers.
    Aspiring tech artist. Previous experience in several 3D/Compositing programs, Web Dev & IT.
    Doesn't quite matter how much I know about Unity, or scripting, for I'll always learn more.


  2. Location
    Germany
    Posts
    343
    Quaternion.Lerp or Quarernion.RotateTowards do the job. Maybe next time you look at the docs before posting here?
    // Time of Day - Realistic sky dome with day/night cycle, atmospheric scattering, cloud layers and cloud shadows.
    // I'm also on this thing called Twitter and have a website, feel free to step by!


  3. Location
    Australia
    Posts
    261
    Tried that before.
    Code:  
    1. transform.rotation = Quaternion.Lerp (transform.rotation, spawnRot.rotation, Time.time);

    Error:
    Assets/Code/~.js(46,6: BCE0019: 'rotation' is not a member of 'UnityEngine.Quaternion'.
    Aspiring tech artist. Previous experience in several 3D/Compositing programs, Web Dev & IT.
    Doesn't quite matter how much I know about Unity, or scripting, for I'll always learn more.


  4. Location
    Germany
    Posts
    343
    spawnRot is already of type Quaternion, you cannot acces .rotation because this is a member of the Transform class. Instead you can use the variable directly to pass it to Quaternion.Lerp. This is basic code understanding, you might want to improve your understanding of object-oriented programming and C# in general.
    // Time of Day - Realistic sky dome with day/night cycle, atmospheric scattering, cloud layers and cloud shadows.
    // I'm also on this thing called Twitter and have a website, feel free to step by!


  5. Location
    Australia
    Posts
    261
    Code:  
    1. transform.rotation = Quaternion.Lerp (transform.rotation, spawnRot, Time.deltaTime * Time.deltaTime);
    There we go. Which I swore I tried earlier - perhaps mistyped it. Odd.

    I understand what you mean, to a degree, but I prefer to work with trial and error and generate my own understanding of how everything works - which takes time, and this has added to that.
    Aspiring tech artist. Previous experience in several 3D/Compositing programs, Web Dev & IT.
    Doesn't quite matter how much I know about Unity, or scripting, for I'll always learn more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •