Search Unity

Animation A which changes the rotation prevents Animation B to change rotation by event and script

Discussion in 'Animation' started by CodingCoon101, Nov 7, 2021.

  1. CodingCoon101

    CodingCoon101

    Joined:
    Nov 7, 2021
    Posts:
    1
    Hello,
    I'm working on a 2D game, where units can have have melee and range attacks.
    Every unit contains 4 GameObjects in the following composition
    upload_2021-11-7_23-29-10.png

    In the melee attack the units have a basic animation, where they raise the weapon and hit their enemies.
    So when the MeleeAttack Animation is running it changes the position and rotation of the hand and with it the weapon.


    The RangeAttack shall only change the position of the hand to represent a shot. But at the beginning of the Animation I have a event to call the method "BeforeAttack". There I want to adjust the rotation of the hand to shot into the right direction, as an example where the target enemy stands.

    upload_2021-11-7_23-34-52.png

    I tried out many variation to edit the rotation by script but nothing works.

    Only when I remove the MeleeAttack from the AnimationController everything is fine and the hand gets a useful rotation:
    upload_2021-11-7_23-36-32.png

    I assume, that changes on a property in one AnimationClip has an impact on changes by script in another AnimationClip.
    Why is one Animation affecting another one, although only one can run. What can I do?
     

    Attached Files: