Search Unity

Turn based prefab animations

Discussion in 'Animation' started by Flash427, Mar 10, 2014.

  1. Flash427

    Flash427

    Joined:
    Jun 16, 2013
    Posts:
    9
    Hello,

    I'm making a game so that has characters set up on a board like chess and can attack/move to other squares. So because of the turn based 3rd person view, all of my characters in the game need to have a parent (empty) and then have the character in it
    AssassinParent holds Assassin
    I then made an animation so when the Assassin is instantiated into the game and thus moved to another location, the animation would would be played based on the position of the character on my board. Then put that character in my prefabs section and my game calls the child (Assassin) to play and when it needs to call the animation it looks up to the parent and gets it.
    My 2 problems are:
    1) The animation should only play if the character attacks
    Code (csharp):
    1.             Animation AttackingAnimation;
    2.             AttackingAnimation = AssassinPrefab.transform.parent.animation;
    3.             //Attackingamimatin = GameObject.Find ("AssassinP");
    4.             Debug.Log ("????????????????????????");
    5.             AttackingAnimation.animation.Play("AttackAnimation");
    But right from the start the character is placed randomly on the board doing the attack animation.

    and 2) if I switch Legacy on(2 to 1) it removes the animation entirely. When the Assassin attacks, nothing happens but the debug does spit out the "???...".

    Obviously I want to have it so when the Assassin attacks, the animation happens from that location and that is it. Any suggestions would be amazing!

    Thanks