Search Unity

2D IK, 2D Animation and PSD Files - Animate different GO with single AC

Discussion in 'Animation' started by kaji0tt, Jan 13, 2021.

  1. kaji0tt

    kaji0tt

    Joined:
    Mar 4, 2019
    Posts:
    2
    Hey Guys,

    I'm trying to animate my game with the 2D IK & 2D Animation - so im trying to Rig different Sprites i created.
    From what i got so far, the "rigged" sprites are single GO's. However, i have 4 different States of Sprites which need to be animated in dependency of where my character is. (2.5D Game).

    My concern:
    To animate these different sprites, i got a script attacked to Ghost-Crawler Parent object. Each state of the mob (front, back, left, right) is currently a single 2D GameObject with Rig thats easy to animate. Currently im looping through all of them, to activate them accordingly of the player.position. however, this seems to get quite CPU heavy once the game gets bigger with hundreds of mobs and i'm looking for a way to animate all 4 different 2D sprite rigs in one single animation.controler, whitout the need to constantly loop through those GO's and activate them in dependency of player position on runtime.

    Picture for clearance:
    GO:

    Script:

    //open direct link for better size

    Maybe anyone of you got a workaround how to avoid this looping,
    thanks in regard for any help!
     
  2. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    Hello @kaji0tt,
    Could you share your profiler data so we can see what part of your solution is heavy and could use some optimizations?