Search Unity

Question How do I spin a sprite with smaller sprites "on" it, w/o rotating the small ones around own axis?

Discussion in '2D' started by Tuonela93, Mar 21, 2023.

  1. Tuonela93

    Tuonela93

    Joined:
    Apr 7, 2018
    Posts:
    27
    This will be hard to describe, so here's a picture: carddescription.png

    How do I achieve this effect? The cards and the disk are sprites. When I make a sprite the child of another sprite, the child objects instantly acquire the direction of the parent object. In this case though, I want the card sprites to be almost perpendicular to the disk sprite, while they spin together with the disk, but still they should be facing the camera all the time. rotation constraint didn't yield any results.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    Two random approaches:

    - simplest: parent the cards to the rotating disk. After the disk rotates each frame, iterate the cards and rotate them to face the way you want

    - next-simplest: put empty GameObjects parented to the rotating disk, then have a "copy target Transform position" script on each card that only moves it to each of the target empty GameObjects.
     
    Tuonela93 and MelvMay like this.
  3. Tuonela93

    Tuonela93

    Joined:
    Apr 7, 2018
    Posts:
    27
    With the first approach I set transform.rotation = Quaternion.identity in LateUpdate, but somehow the cards stay flat on the disk still. Some weird behaviors in rotation.

    However the second approach worked! Thanks. :)
     
    Kurt-Dekker likes this.
  4. Torbach78

    Torbach78

    Joined:
    Aug 10, 2013
    Posts:
    296
    Chubzdoomer likes this.