Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Handling Rotation On Scaled Object

Discussion in 'Entity Component System' started by bpeake-contigo, Mar 5, 2020.

  1. bpeake-contigo

    bpeake-contigo

    Joined:
    Mar 14, 2017
    Posts:
    6
    I have a pretty simple setup with a Game Object that has been scaled down. I want to have a script that simply rotates the object about an axis. This is the code I am using:


    Code (CSharp):
    1. public void Execute(ref Rotation rotation,
    2.   [ReadOnly] ref AutoRotateComponent autoRotateData) {
    3.   var rotationAmount = autoRotateData.DegsPerSecond * Time;
    4.  
    5.    rotation.Value = quaternion.AxisAngle(
    6.                     math.normalize(autoRotateData.Axis),
    7.                     math.radians(rotationAmount));
    8. }
    9.  
    This is a port over from some code I had in old unity, however the math no longer seems to work with scaled objects here, is there something else I need to be doing?